Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -33,47 +33,18 @@ def process_image(image, model_name, inference_engine):
|
|
33 |
return f"Error: {str(e)}"
|
34 |
|
35 |
# 创建Gradio界面
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
label="Model Name",
|
48 |
-
value=DEFAULT_MODEL,
|
49 |
-
info="Input Hugging Face model ID or local model path"
|
50 |
-
)
|
51 |
-
|
52 |
-
# 推理引擎选择
|
53 |
-
inference_engine = gr.Dropdown(
|
54 |
-
choices=["transformers", "vllm"],
|
55 |
-
value=DEFAULT_ENGINE,
|
56 |
-
label="Inference Engine"
|
57 |
-
)
|
58 |
-
|
59 |
-
# 提交按钮
|
60 |
-
submit_btn = gr.Button("Start", variant="primary")
|
61 |
-
|
62 |
-
with gr.Column():
|
63 |
-
# 结果显示
|
64 |
-
output = gr.Textbox(
|
65 |
-
label="Result",
|
66 |
-
lines=10,
|
67 |
-
placeholder="The result will be displayed here..."
|
68 |
-
)
|
69 |
-
|
70 |
-
# 设置提交按钮的回调函数
|
71 |
-
submit_btn.click(
|
72 |
-
fn=process_image,
|
73 |
-
inputs=[image_input, model_name, inference_engine],
|
74 |
-
outputs=output
|
75 |
-
)
|
76 |
|
77 |
# 启动应用
|
78 |
if __name__ == "__main__":
|
79 |
-
demo.launch()
|
|
|
33 |
return f"Error: {str(e)}"
|
34 |
|
35 |
# 创建Gradio界面
|
36 |
+
demo = gr.Interface(
|
37 |
+
fn=process_image,
|
38 |
+
inputs=[
|
39 |
+
gr.Image(type="pil", label="Upload Image"),
|
40 |
+
gr.Textbox(label="Model Name", value=DEFAULT_MODEL),
|
41 |
+
gr.Dropdown(choices=["transformers", "vllm"], value=DEFAULT_ENGINE, label="Inference Engine")
|
42 |
+
],
|
43 |
+
outputs=gr.Textbox(label="Result"),
|
44 |
+
title="Geolocation Reasoning App",
|
45 |
+
description="Upload an image, and the system will identify the country and region where the image was taken."
|
46 |
+
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
47 |
|
48 |
# 启动应用
|
49 |
if __name__ == "__main__":
|
50 |
+
demo.launch(share=True)
|