Spaces:
Running
on
Zero
Running
on
Zero
Update app.py
Browse files
app.py
CHANGED
|
@@ -444,13 +444,12 @@ with gr.Blocks(theme=gr.themes.Soft(), title="MedCrab Translation") as demo:
|
|
| 444 |
gr.Markdown("### 📄 Kết quả dịch tiếng Việt (Streaming)")
|
| 445 |
translation_output = gr.HTML(label="", value="")
|
| 446 |
|
| 447 |
-
# Note: Upload ảnh qua Web UI sau khi space chạy, rồi uncomment phần này:
|
| 448 |
with gr.Accordion("📚 Ví dụ mẫu", open=True):
|
| 449 |
gr.Markdown("**Thử ngay với các ví dụ có sẵn:**")
|
| 450 |
gr.Examples(
|
| 451 |
examples=[
|
| 452 |
-
["images/
|
| 453 |
-
["images/
|
| 454 |
],
|
| 455 |
inputs=[file_in, mode, page_input],
|
| 456 |
outputs=[translation_output],
|
|
@@ -490,6 +489,17 @@ with gr.Blocks(theme=gr.themes.Soft(), title="MedCrab Translation") as demo:
|
|
| 490 |
[translation_output]
|
| 491 |
)
|
| 492 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 493 |
if __name__ == "__main__":
|
| 494 |
print("🚀 Starting MedCrab Translation on Hugging Face Spaces...")
|
| 495 |
demo.queue(max_size=20).launch()
|
|
|
|
| 444 |
gr.Markdown("### 📄 Kết quả dịch tiếng Việt (Streaming)")
|
| 445 |
translation_output = gr.HTML(label="", value="")
|
| 446 |
|
|
|
|
| 447 |
with gr.Accordion("📚 Ví dụ mẫu", open=True):
|
| 448 |
gr.Markdown("**Thử ngay với các ví dụ có sẵn:**")
|
| 449 |
gr.Examples(
|
| 450 |
examples=[
|
| 451 |
+
["images/example1.png", "Crab", "1"],
|
| 452 |
+
["images/example2.png", "Crab", "1"],
|
| 453 |
],
|
| 454 |
inputs=[file_in, mode, page_input],
|
| 455 |
outputs=[translation_output],
|
|
|
|
| 489 |
[translation_output]
|
| 490 |
)
|
| 491 |
|
| 492 |
+
def load_default_example():
|
| 493 |
+
file_path = "images/example1.png"
|
| 494 |
+
img = Image.open(file_path)
|
| 495 |
+
return file_path, img
|
| 496 |
+
|
| 497 |
+
demo.load(
|
| 498 |
+
load_default_example,
|
| 499 |
+
inputs=None,
|
| 500 |
+
outputs=[file_in, input_img] # cập nhật cả file_in và input_img
|
| 501 |
+
)
|
| 502 |
+
|
| 503 |
if __name__ == "__main__":
|
| 504 |
print("🚀 Starting MedCrab Translation on Hugging Face Spaces...")
|
| 505 |
demo.queue(max_size=20).launch()
|