adpro commited on
Commit
6205c6e
·
verified ·
1 Parent(s): 3bdfe12

Update gradio_app.py

Browse files
Files changed (1) hide show
  1. gradio_app.py +7 -6
gradio_app.py CHANGED
@@ -1,11 +1,12 @@
1
  import gradio as gr
2
- from app import depth_map_global # Import ảnh Depth Map từ FastAPI
3
 
4
  def get_depth_map():
5
- """Trả về ảnh Depth Map mới nhất để hiển thị trên Gradio"""
6
- if depth_map_global is None:
 
 
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, # Cập nhật theo thời gian thực
18
- ).launch(share=True) # `share=True` để tạo link truy cập từ bên ngoài
 
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)