[GH-ISSUE #224] Use_webapi #184

Open
opened 2026-10-26 21:13:45 +00:00 by bsakaguchi · 0 comments
Owner

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?

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?
Sign in to join this conversation.
No labels
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
deepseek-ai/Janus#184
No description provided.