import gradio as gr from app import depth_map_global # Import ảnh Depth Map từ FastAPI def get_depth_map(): """Trả về ảnh Depth Map mới nhất để hiển thị trên Gradio""" if depth_map_global is None: return "Chưa có ảnh Depth Map nào được xử lý!" return depth_map_global # 🟢 Tạo UI trên Hugging Face Spaces với Gradio gr.Interface( fn=get_depth_map, inputs=[], outputs=gr.Image(type="pil"), title="🔍 Depth Map Viewer", description="Hiển thị ảnh Depth Map mới nhất từ FastAPI", live=True, # Cập nhật theo thời gian thực ).launch(share=True) # `share=True` để tạo link truy cập từ bên ngoài