mirror of
https://github.com/timerring/bilive.git
synced 2026-05-06 21:40:20 +08:00
11
README.md
11
README.md
@@ -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" />
|
||||
@@ -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
|
||||
@@ -58,6 +62,7 @@
|
||||
- `Stable Diffusion 3.5 large turbo`
|
||||
- `Luma Photon`
|
||||
- `Ideogram V_2`
|
||||
- `Recraft`
|
||||
|
||||
|
||||
项目架构流程如下:
|
||||
@@ -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):
|
||||
|
||||
1
assets/recraft.svg
Normal file
1
assets/recraft.svg
Normal file
@@ -0,0 +1 @@
|
||||
<svg fill="currentColor" fill-rule="evenodd" height="1em" style="flex:none;line-height:1" viewBox="0 0 24 24" width="1em" xmlns="http://www.w3.org/2000/svg"><title>Recraft</title><path d="M19.667 8.275c0-4.57-4.15-8.275-9.27-8.275-1.774 0-3.213 3.705-3.213 8.275 0 1.143.09 2.233.253 3.224H4.29L1 23h9.4v-6.447c5.117 0 9.266-3.707 9.266-8.275l.001-.002zm-9.27-6.76c.93 0 1.682 3.028 1.682 6.76 0 3.733-.752 6.76-1.681 6.76-.93 0-1.681-3.027-1.681-6.76 0-3.732.752-6.76 1.68-6.76z"></path><path d="M19.848 16.552h-9.44L14.028 23h9.438l-3.618-6.448z"></path></svg>
|
||||
|
After Width: | Height: | Size: 562 B |
@@ -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
|
||||
@@ -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
|
||||
@@ -81,4 +81,5 @@ TENCENT_SECRET_KEY = config.get('cover', {}).get('tencent_secret_key')
|
||||
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')
|
||||
@@ -81,6 +81,10 @@ def cover_generator(model_type):
|
||||
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
|
||||
|
||||
37
src/cover/image_model_sdk/recraft_sdk.py
Normal file
37
src/cover/image_model_sdk/recraft_sdk.py
Normal file
@@ -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
|
||||
Reference in New Issue
Block a user