Spaces:
Sleeping
Sleeping
Hongyang Li
commited on
Create app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
+
from inference import Inference
|
| 3 |
+
import os
|
| 4 |
+
from huggingface_hub import snapshot_download
|
| 5 |
+
|
| 6 |
+
model_path = snapshot_download(repo_id='Cangshanqingshi/SuperRetinaDemo')
|
| 7 |
+
|
| 8 |
+
inference_engine = Inference(model_path=model_path)
|
| 9 |
+
|
| 10 |
+
def main(source_image, target_image):
|
| 11 |
+
merged, match_show = inference_engine.inference(source_image, target_image)
|
| 12 |
+
return merged, match_show
|
| 13 |
+
|
| 14 |
+
with gr.Blocks() as demo:
|
| 15 |
+
gr.Markdown("SuperRetina CFP Registration Demo")
|
| 16 |
+
|
| 17 |
+
with gr.Row():
|
| 18 |
+
with gr.Column():
|
| 19 |
+
image_input = [gr.Image(type="numpy", label="Source Image"),
|
| 20 |
+
gr.Image(type="numpy", label="Target Image")]
|
| 21 |
+
with gr.Column():
|
| 22 |
+
image_output = [gr.Image(type="numpy", label="Output"),
|
| 23 |
+
gr.Image(type="numpy", label="Match Show")]
|
| 24 |
+
|
| 25 |
+
# 当图像输入发生变化时自动触发推理
|
| 26 |
+
image_input.change(
|
| 27 |
+
fn=main,
|
| 28 |
+
inputs=image_input,
|
| 29 |
+
outputs=image_output
|
| 30 |
+
)
|
| 31 |
+
|
| 32 |
+
demo.launch()
|