Update gradio_app.py
Browse files- gradio_app.py +7 -6
gradio_app.py
CHANGED
@@ -1,11 +1,12 @@
|
|
1 |
import gradio as gr
|
2 |
-
from
|
3 |
|
4 |
def get_depth_map():
|
5 |
-
"""Trả về ảnh Depth Map mới nhất
|
6 |
-
|
|
|
|
|
7 |
return "Chưa có ảnh Depth Map nào được xử lý!"
|
8 |
-
return depth_map_global
|
9 |
|
10 |
# 🟢 Tạo UI trên Hugging Face Spaces với Gradio
|
11 |
gr.Interface(
|
@@ -14,5 +15,5 @@ gr.Interface(
|
|
14 |
outputs=gr.Image(type="pil"),
|
15 |
title="🔍 Depth Map Viewer",
|
16 |
description="Hiển thị ảnh Depth Map mới nhất từ FastAPI",
|
17 |
-
live=True, #
|
18 |
-
).launch(share=True)
|
|
|
1 |
import gradio as gr
|
2 |
+
from PIL import Image
|
3 |
|
4 |
def get_depth_map():
|
5 |
+
"""Trả về ảnh Depth Map mới nhất từ FastAPI"""
|
6 |
+
try:
|
7 |
+
return Image.open("depth_map.png") # 🟢 Lấy ảnh đã lưu từ FastAPI
|
8 |
+
except FileNotFoundError:
|
9 |
return "Chưa có ảnh Depth Map nào được xử lý!"
|
|
|
10 |
|
11 |
# 🟢 Tạo UI trên Hugging Face Spaces với Gradio
|
12 |
gr.Interface(
|
|
|
15 |
outputs=gr.Image(type="pil"),
|
16 |
title="🔍 Depth Map Viewer",
|
17 |
description="Hiển thị ảnh Depth Map mới nhất từ FastAPI",
|
18 |
+
live=True, # 🎯 **Tự động cập nhật ảnh mới**
|
19 |
+
).launch(share=True)
|