mirror of
https://github.com/deepseek-ai/Janus.git
synced 2026-11-05 00:57:18 +00:00
[GH-ISSUE #224] Use_webapi #184
Labels
No labels
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
deepseek-ai/Janus#184
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @hcscysh on GitHub (Aug 12, 2025).
Original GitHub issue: https://github.com/deepseek-ai/Janus/issues/224
from gradio_client import Client, file
import os
SERVER_URL = "http://192.168.9.58:7860/" # <--- 在这里填入您的服务器 IP 地址
IMAGE_PATH = "./Janus/temp.png" # <--- 在这里填入您的图片路径
QUESTION = "请详细描述这张图片里的内容。"
def call_image_to_text_api(server_url, image_path, question):
if not os.path.exists(image_path):
print(f"❌ 错误:无法找到图片文件,请检查路径是否正确: {image_path}")
return
client = Client(server_url)
image_arg = file(image_path) # 图片文件,使用 file() 包装
question_arg = question # 问题文本
seed_arg = 42 # Seed 值 (与服务器默认值保持一致)
top_p_arg = 0.95 # Top_p 值 (与服务器默认值保持一致)
temperature_arg = 0.1 # Temperature 值 (与服务器默认值保持一致)
result = client.predict(
image_arg,
question_arg,
seed_arg,
top_p_arg,
temperature_arg,
fn_index=0 # 0 对应
multimodal_understanding)
print(result)
if name == "main":
call_image_to_text_api(SERVER_URL, IMAGE_PATH, QUESTION)
I want to use the code to calling the web_api, but failed, can you supply any suggestions?