import gradio as gr from PIL import Image def get_depth_map(): """Trả về ảnh Depth Map mới nhất từ FastAPI""" try: return Image.open("depth_map.png") # 🟢 Lấy ảnh đã lưu từ FastAPI except FileNotFoundError: return "Chưa có ảnh Depth Map nào được xử lý!" # 🟢 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 # 🎯 **Tự động cập nhật ảnh mới** ).launch()