Skip to content

Commit 5aa1e6e

Browse files
authored
feat: sensenova and unittest (#280)
* feat: sensenova and unittest * docs: update images
1 parent 30ae1d5 commit 5aa1e6e

File tree

12 files changed

+190
-25
lines changed

12 files changed

+190
-25
lines changed

README.md

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
<img src="assets/zhipu-color.svg" alt="Zhipu GLM-4V-PLUS" width="60" height="60" />
1818
<img src="assets/gemini-brand-color.svg" alt="Google Gemini 1.5 Pro" width="60" height="60" />
1919
<img src="assets/qwen-color.svg" alt="Qwen-2.5-72B-Instruct" width="60" height="60" />
20+
<img src="assets/sensenova-brand-color.svg" alt="SenseNova V6 Pro" width="100" height="60" />
2021
</div>
2122

2223
<img src="assets/hunyuan-color.svg" alt="Tencent Hunyuan" width="50" height="60" />
@@ -56,6 +57,7 @@
5657
- `GLM-4V-PLUS`
5758
- `Gemini-2.0-flash`
5859
- `Qwen-2.5-72B-Instruct`
60+
- `SenseNova V6 Pro`
5961
- **( :tada: NEW)持久化登录/下载/上传视频(支持多p投稿)**[bilitool](https://github.com/timerring/bilitool) 已经开源,实现持久化登录,下载视频及弹幕(含多p)/上传视频(可分p投稿),查询投稿状态,查询详细信息等功能,一键pip安装,可以使用命令行 cli 操作,也可以作为api调用。
6062
- **( :tada: NEW)自动多平台循环直播推流**:该工具已经开源 [looplive](https://github.com/timerring/looplive) 是一个 7 x 24 小时全自动**循环多平台同时推流**直播工具。
6163
- **( :tada: NEW)自动生成风格变换的视频封面**:采用图生图多模态模型,自动获取视频截图并上传风格变换后的视频封面。
@@ -71,7 +73,7 @@
7173

7274
项目架构流程如下:
7375

74-
![](https://cdn.jsdelivr.net/gh/timerring/scratchpad2023/2024/2025-04-10-17-08-35.png)
76+
![](https://cdn.jsdelivr.net/gh/timerring/scratchpad2023/2024/2025-04-12-14-46-16.png)
7577

7678
## 3. 测试硬件
7779

@@ -168,8 +170,9 @@ pip install -r requirements.txt
168170
> [!TIP]
169171
> - 有关自动切片的配置在 `bilive.toml` 文件的 `[slice]` 部分。
170172
> - `auto_slice` 默认为 false, 即不进行自动切片。
173+
> - 可以通过单元测试调试你自己的 prompt,单元测试在 `tests/test_autoslice.py`,执行 `python -m unittest` 即可,后接 `tests.test_autoslice` 测试整个模块,`tests.test_autoslice.TestXXXMain` 测试某个模型。
171174
172-
MLLM 模型主要用于自动切片后的切片标题生成,此功能默认关闭,如果需要打开请将 `auto_slice` 参数设置为 `true`,并且写下你自己的 prompt,其他配置分别有:
175+
MLLM 模型主要用于自动切片后的切片标题生成,此功能默认关闭,如果需要打开请将 `auto_slice` 参数设置为 `true`,并且写下你自己的 `slice_prompt`(请包含关键词 `{artist}`会自动替换),其他配置分别有:
173176
- `slice_duration` 以秒为单位设置切片时长(不建议超过 180 秒)。
174177
- `slice_num` 设置切片数量。
175178
- `slice_overlap` 设置切片重叠时长。切片采用滑动窗口法处理,细节内容请见 [auto-slice-video](https://github.com/timerring/auto-slice-video)
@@ -178,11 +181,11 @@ MLLM 模型主要用于自动切片后的切片标题生成,此功能默认关
178181

179182
接下来配置模型有关的 `mllm_model` 参数即对应的 api-key,请自行根据链接注册账号并且申请对应 api key,填写在对应的参数中,请注意以下模型只有你在 `mllm_model` 参数中设置的那个模型会生效。
180183

181-
| Company | Alicloud | zhipu | Google |
182-
|----------------|-----------------------|------------------|-------------------|
183-
| Name | Qwen-2.5-72B-Instruct | GLM-4V-PLUS | Gemini-2.0-flash |
184-
| `mllm_model` | `qwen` | `zhipu` | `gemini` |
185-
| `API key` | [qwen_api_key](https://bailian.console.aliyun.com/?apiKey=1) | [zhipu_api_key](https://www.bigmodel.cn/invite?icode=shBtZUfNE6FfdMH1R6NybGczbXFgPRGIalpycrEwJ28%3D) | [gemini_api_key](https://aistudio.google.com/app/apikey) |
184+
| Company | Alicloud | zhipu | Google | SenseNova |
185+
|----------------|-----------------------|------------------|-------------------|-------------------|
186+
| Name | Qwen-2.5-72B-Instruct | GLM-4V-PLUS | Gemini-2.0-flash | SenseNova V6 Pro |
187+
| `mllm_model` | `qwen` | `zhipu` | `gemini` | `sensenova` |
188+
| `API key` | [qwen_api_key](https://bailian.console.aliyun.com/?apiKey=1) | [zhipu_api_key](https://www.bigmodel.cn/invite?icode=shBtZUfNE6FfdMH1R6NybGczbXFgPRGIalpycrEwJ28%3D) | [gemini_api_key](https://aistudio.google.com/app/apikey) | [sensenova_api_key](https://console.sensecore.cn/aistudio/management/api-key) |
186189

187190

188191
#### 2.3 Image Generation Model(自动生成视频封面)

assets/sensenova-brand-color.svg

Lines changed: 1 addition & 0 deletions
Loading

bilive.toml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,23 +17,24 @@ inference_model = "small" # If you choose "deploy", you should download the infe
1717
# You can change the title as you like, eg.
1818
title = "{date}直播" # Key words: {artist}, {date}, {title}, {source_link}
1919
description = "录制请征求主播同意,若未经同意就录制,所引起的任何法律问题均由该违规录制的 b 站账号承担。" # Key words: {artist}, {date}, {title}, {source_link}
20-
tid = # The tid of the video, see https://bilitool.timerring.com/tid.html
20+
tid = # The tid of the video(int), see https://bilitool.timerring.com/tid.html
2121
gift_price_filter = 1 # The gift whose price is less than this value will be filtered, unit: RMB
2222
reserve_for_fixing = false # If encounter MOOV crash error, delete the video or reserve for fixing
2323
upload_line = "auto" # The upload line to be used, default None is auto detect(recommended), if you want to specify, it can be "bldsa", "ws", "tx", "qn", "bda2".
2424

2525
[slice]
2626
auto_slice = false # General control: true or false
27+
slice_prompt = "" # Write your own slice prompt here, key word: {artist}
2728
slice_duration = 60 # better not exceed 300 seconds
2829
slice_num = 2 # the number of slices
2930
slice_overlap = 30 # the overlap of slices(seconds) see my package https://github.com/timerring/auto-slice-video for more details
3031
slice_step = 1 # the step of slices(seconds)
3132
min_video_size = 200 # The minimum video size to be sliced (MB)
3233
mllm_model = "qwen" # the multi-model LLMs, can be "qwen" or "gemini" or "zhipu"
33-
slice_prompt = "" # Write your own slice prompt here
3434
qwen_api_key = "" # Apply for your own Qwen API key at https://bailian.console.aliyun.com/?apiKey=1
3535
zhipu_api_key = "" # Apply for your own GLM-4v-Plus API key at https://www.bigmodel.cn/invite?icode=shBtZUfNE6FfdMH1R6NybGczbXFgPRGIalpycrEwJ28%3D
3636
gemini_api_key = "" # Apply for your own Gemini API key at https://aistudio.google.com/app/apikey
37+
sensenova_api_key = "" # Apply for your own SenseNova API key at https://console.sensecore.cn/aistudio/management/api-key
3738

3839
[cover]
3940
generate_cover = false # whether to generate cover

src/autoslice/mllm_sdk/gemini_new_sdk.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,14 @@ def gemini_generate_title(video_path, artist):
1515
model="models/gemini-2.0-flash",
1616
contents=types.Content(
1717
parts=[
18-
types.Part(text=SLICE_PROMPT),
18+
types.Part(text=SLICE_PROMPT.format(artist=artist)),
1919
types.Part(
2020
inline_data=types.Blob(data=video_bytes, mime_type="video/mp4")
2121
),
2222
]
2323
),
2424
)
25-
scan_log.info("使用 Gemini-2.0-flash 生成切片标题")
26-
scan_log.info(f"Prompt: {SLICE_PROMPT}")
27-
scan_log.info(f"生成的切片标题为: {response.text}")
25+
scan_log.info("Using Gemini-2.0-flash to generate slice title")
26+
scan_log.info(f"Prompt: {SLICE_PROMPT.format(artist=artist)}")
27+
scan_log.info(f"Generated slice title: {response.text}")
2828
return response.text

src/autoslice/mllm_sdk/gemini_old_sdk.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ def gemini_generate_title(video_path, artist):
2323
raise ValueError(video_file.state.name)
2424

2525
# Create the prompt.
26-
prompt = SLICE_PROMPT
26+
prompt = SLICE_PROMPT.format(artist=artist)
2727

2828
# Set the model to Gemini Flash.
2929
model = genai.GenerativeModel(model_name="models/gemini-2.0-flash")
@@ -33,7 +33,7 @@ def gemini_generate_title(video_path, artist):
3333
)
3434
# delete the video file
3535
genai.delete_file(video_file.name)
36-
scan_log.info("使用 Gemini-2.0-flash 生成切片标题")
37-
scan_log.info(f"Prompt: {SLICE_PROMPT}")
38-
scan_log.info(f"生成的切片标题为: {response.text}")
36+
scan_log.info("Using Gemini-2.0-flash to generate slice title")
37+
scan_log.info(f"Prompt: {SLICE_PROMPT.format(artist=artist)}")
38+
scan_log.info(f"Generated slice title: {response.text}")
3939
return response.text

src/autoslice/mllm_sdk/qwen_sdk.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,12 @@ def qwen_generate_title(video_path, artist):
3131
"type": "video_url",
3232
"video_url": {"url": f"data:video/mp4;base64,{base64_video}"},
3333
},
34-
{"type": "text", "text": SLICE_PROMPT},
34+
{"type": "text", "text": SLICE_PROMPT.format(artist=artist)},
3535
],
3636
},
3737
],
3838
)
39-
scan_log.info("使用 Qwen-2.5-72B-Instruct 生成切片标题")
40-
scan_log.info(f"Prompt: {SLICE_PROMPT}")
41-
scan_log.info(f"生成的切片标题为: {completion.choices[0].message.content}")
39+
scan_log.info("Using Qwen-2.5-72B-Instruct to generate slice title")
40+
scan_log.info(f"Prompt: {SLICE_PROMPT.format(artist=artist)}")
41+
scan_log.info(f"Generated slice title: {completion.choices[0].message.content}")
4242
return completion.choices[0].message.content.strip('"')

0 commit comments

Comments
 (0)