Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,13 @@

支持模型

<div>
<img src="assets/openai.svg" alt="OpenAI whisper" width="60" height="60" />
<img src="assets/zhipu-color.svg" alt="Zhipu GLM-4V-PLUS" width="60" height="60" />
<img src="assets/gemini-brand-color.svg" alt="Google Gemini 1.5 Pro" width="60" height="60" />
<img src="assets/qwen-color.svg" alt="Qwen-2.5-72B-Instruct" width="60" height="60" />
</div>

<img src="assets/hunyuan-color.svg" alt="Tencent Hunyuan" width="50" height="60" />
<img src="assets/minimax-color.svg" alt="Minimax" width="20" height="60" />
<img src="assets/minimax-text.svg" alt="Minimax" width="60" height="60" />
Expand All @@ -26,6 +29,7 @@
<img src="assets/luma-color.svg" alt="Luma Photon" width="20" height="60" />
<img src="assets/luma-text.svg" alt="Luma Photon" width="60" height="60" />
<img src="assets/ideogram.svg" alt="Ideogram V_2" width="50" height="60" />
<img src="assets/recraft.svg" alt="Recraft" width="50" height="60" />
</div>

## 1. Introduction
Expand Down Expand Up @@ -58,6 +62,7 @@
- `Stable Diffusion 3.5 large turbo`
- `Luma Photon`
- `Ideogram V_2`
- `Recraft`


项目架构流程如下:
Expand Down Expand Up @@ -249,6 +254,12 @@ MLLM 模型主要用于自动切片后的切片标题生成,此功能默认关

请自行[注册账号](https://ideogram.ai/manage-api)并申请 API Key,填写到 `bilive.toml` 文件中对应的 `IDEOGRAM_API_KEY` 中。

##### 3.3.8 Recraft 模型

> 如需使用 Recraft 模型,请将 `IMAGE_GEN_MODEL` 参数设置为 `recraft`。

请自行[注册账号](https://www.recraft.ai/profile/api)并申请 API Key,填写到 `bilive.toml` 文件中对应的 `RECRAFT_API_KEY` 中。

#### 4. bilitool 登录

> 由于一般日志打印不出二维码效果(docker 的日志不确定是否能打印,等发布新image时再修改,docker 版本请先参考文档 [bilive](https://bilive.timerring.com),本 README 只针对源码部署),所以这步需要提前在机器上安装 [bilitool](https://github.com/timerring/bilitool):
Expand Down
1 change: 1 addition & 0 deletions assets/recraft.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 2 additions & 1 deletion bilive.toml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ qwen_api_key = "" # Apply for your own Qwen API key at https://bailian.console.a

[cover]
generate_cover = false # whether to generate cover
image_gen_model = "minimax" # the image generation model, can be "minimax" or "siliconflow" or "tencent" or "baidu" or "stability" or "luma" or "ideogram"
image_gen_model = "minimax" # the image generation model, can be "minimax" or "siliconflow" or "tencent" or "baidu" or "stability" or "luma" or "ideogram" or "recraft"
minimax_api_key = "" # Apply for your own Minimax API key at https://platform.minimaxi.com/user-center/basic-information/interface-key
siliconflow_api_key = "" # Apply for your own SiliconFlow API key at https://cloud.siliconflow.cn/i/3Szr5BVg
tencent_secret_id = "" # Apply for your own Tencent Cloud API key at https://console.cloud.tencent.com/cam/capi
Expand All @@ -46,3 +46,4 @@ baidu_api_key = "" # Apply for your own Baidu API key at https://console.bce.bai
stability_api_key = "" # Apply for your own Stability API key at https://platform.stability.ai/account/keys
luma_api_key = "" # Apply for your own Luma API key at https://lumalabs.ai/api/keys
ideogram_api_key = "" # Apply for your own Ideogram API key at https://ideogram.ai/manage-api
recraft_api_key = "" # Apply for your own Recraft API key at https://www.recraft.ai/profile/api
3 changes: 2 additions & 1 deletion src/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,4 +81,5 @@ def get_interface_config():
BAIDU_API_KEY = config.get('cover', {}).get('baidu_api_key')
STABILITY_API_KEY = config.get('cover', {}).get('stability_api_key')
LUMA_API_KEY = config.get('cover', {}).get('luma_api_key')
IDEOGRAM_API_KEY = config.get('cover', {}).get('ideogram_api_key')
IDEOGRAM_API_KEY = config.get('cover', {}).get('ideogram_api_key')
RECRAFT_API_KEY = config.get('cover', {}).get('recraft_api_key')
4 changes: 4 additions & 0 deletions src/cover/cover_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,10 @@ def wrapper(video_path):
from .image_model_sdk.ideogram_sdk import ideogram_generate_cover

return ideogram_generate_cover(cover_path)
elif model_type == "recraft":
from .image_model_sdk.recraft_sdk import recraft_generate_cover

return recraft_generate_cover(cover_path)
else:
upload_log.error(f"Unsupported model type: {model_type}")
return None
Expand Down
37 changes: 37 additions & 0 deletions src/cover/image_model_sdk/recraft_sdk.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
from openai import OpenAI
from src.config import RECRAFT_API_KEY
import requests
import os
import time


def recraft_generate_cover(your_file_path):
try:
client = OpenAI(
base_url='https://external.api.recraft.ai/v1',
api_key=RECRAFT_API_KEY,
)

response = client.post(
path='/images/imageToImage',
cast_to=object,
options={'headers': {'Content-Type': 'multipart/form-data'}},
files={
'image': open(your_file_path, 'rb'),
},
body={
'prompt': 'This is a video screenshot, please generate a cover in the style of a manga',
'strength': 0.75,
},
)
image_url = response['data'][0]['url']
img_data = requests.get(image_url).content
cover_name = time.strftime("%Y%m%d%H%M%S") + ".png"
temp_cover_path = os.path.join(os.path.dirname(your_file_path), cover_name)
with open(temp_cover_path, "wb") as handler:
handler.write(img_data)
os.remove(your_file_path)
return temp_cover_path
except Exception as e:
print(e, flush=True)
return None