Create gradio_app.py
Browse files- gradio_app.py +18 -0
gradio_app.py
ADDED
@@ -0,0 +1,18 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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(
|
12 |
+
fn=get_depth_map,
|
13 |
+
inputs=[],
|
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
|