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
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
<img src="assets/stability-brand-color.svg" alt="Stability AI" width="80" height="60" />
<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" />
</div>

## 1. Introduction
Expand Down Expand Up @@ -56,6 +57,9 @@
- `Baidu ERNIE irag-1.0`
- `Stable Diffusion 3.5 large turbo`
- `Luma Photon`
- `Ideogram V_2`


项目架构流程如下:

```mermaid
Expand Down Expand Up @@ -239,6 +243,12 @@ MLLM 模型主要用于自动切片后的切片标题生成,此功能默认关

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

##### 3.3.7 Ideogram V_2 模型

> 如需使用 Ideogram V_2 模型,请将 `IMAGE_GEN_MODEL` 参数设置为 `ideogram`。

请自行[注册账号](https://ideogram.ai/manage-api)并申请 API Key,填写到 `bilive.toml` 文件中对应的 `IDEOGRAM_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/ideogram.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,11 +37,12 @@ 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"
image_gen_model = "minimax" # the image generation model, can be "minimax" or "siliconflow" or "tencent" or "baidu" or "stability" or "luma" or "ideogram"
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
tencent_secret_key = "" # Apply for your own Tencent Cloud secret key as above
baidu_api_key = "" # Apply for your own Baidu API key at https://console.bce.baidu.com/iam/key/list
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
3 changes: 2 additions & 1 deletion src/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,4 +80,5 @@ def get_interface_config():
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')
LUMA_API_KEY = config.get('cover', {}).get('luma_api_key')
IDEOGRAM_API_KEY = config.get('cover', {}).get('ideogram_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 @@ -77,6 +77,10 @@ def wrapper(video_path):
from .image_model_sdk.luma_sdk import luma_generate_cover

return luma_generate_cover(cover_path)
elif model_type == "ideogram":
from .image_model_sdk.ideogram_sdk import ideogram_generate_cover

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


def ideogram_generate_cover(your_file_path):
"""Generater cover image using ideogram V_2 model
Args:
your_file_path: str, path to the image file
Returns:
str, local download path of the generated cover image file
"""
try:
url = "https://api.ideogram.ai/remix"

files = {"image_file": open(your_file_path, "rb")}
payload = {
"image_request": json.dumps(
{
"prompt": "This is a video screenshot, please generate a cover in the style of a manga",
"aspect_ratio": "ASPECT_10_16",
"image_weight": 75,
"magic_prompt_option": "ON",
"model": "V_2",
}
)
}
headers = {"Api-Key": f"{IDEOGRAM_API_KEY}"}

response = requests.post(url, data=payload, files=files, headers=headers)
if response.status_code == 200:
response_json = response.json()
image_url = response_json["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
else:
raise Exception(response.text)
except Exception as e:
print(e, flush=True)
return None


if __name__ == "__main__":
print(ideogram_generate_cover(""))