diff --git a/README.md b/README.md index 8630314..6662051 100644 --- a/README.md +++ b/README.md @@ -12,10 +12,13 @@ 支持模型 +
OpenAI whisper Zhipu GLM-4V-PLUS Google Gemini 1.5 Pro Qwen-2.5-72B-Instruct +
+ Tencent Hunyuan Minimax Minimax @@ -26,6 +29,7 @@ Luma Photon Luma Photon Ideogram V_2 + Recraft ## 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): diff --git a/assets/recraft.svg b/assets/recraft.svg new file mode 100644 index 0000000..b4ea390 --- /dev/null +++ b/assets/recraft.svg @@ -0,0 +1 @@ +Recraft \ No newline at end of file diff --git a/bilive.toml b/bilive.toml index 2292541..83de0b5 100644 --- a/bilive.toml +++ b/bilive.toml @@ -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 \ No newline at end of file diff --git a/src/config.py b/src/config.py index 569d569..4cff7b8 100644 --- a/src/config.py +++ b/src/config.py @@ -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') \ No newline at end of file +IDEOGRAM_API_KEY = config.get('cover', {}).get('ideogram_api_key') +RECRAFT_API_KEY = config.get('cover', {}).get('recraft_api_key') \ No newline at end of file diff --git a/src/cover/cover_generator.py b/src/cover/cover_generator.py index 45b7b21..0c47ca1 100644 --- a/src/cover/cover_generator.py +++ b/src/cover/cover_generator.py @@ -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 diff --git a/src/cover/image_model_sdk/recraft_sdk.py b/src/cover/image_model_sdk/recraft_sdk.py new file mode 100644 index 0000000..04663ed --- /dev/null +++ b/src/cover/image_model_sdk/recraft_sdk.py @@ -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 \ No newline at end of file