Spaces:
Sleeping
Sleeping
Hongyang Li
commited on
Update app.py
Browse files
app.py
CHANGED
|
@@ -8,8 +8,13 @@ model_path = snapshot_download(repo_id='Cangshanqingshi/SuperRetinaDemo')
|
|
| 8 |
inference_engine = Inference(model_path=model_path)
|
| 9 |
|
| 10 |
def main(source_image, target_image):
|
| 11 |
-
|
| 12 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 13 |
|
| 14 |
with gr.Blocks() as demo:
|
| 15 |
gr.Markdown("SuperRetina CFP Registration Demo")
|
|
@@ -22,7 +27,7 @@ with gr.Blocks() as demo:
|
|
| 22 |
output_image = gr.Image(type="numpy", label="Output")
|
| 23 |
match_show_image = gr.Image(type="numpy", label="Match Show")
|
| 24 |
|
| 25 |
-
#
|
| 26 |
source_image_input.change(
|
| 27 |
fn=main,
|
| 28 |
inputs=[source_image_input, target_image_input],
|
|
|
|
| 8 |
inference_engine = Inference(model_path=model_path)
|
| 9 |
|
| 10 |
def main(source_image, target_image):
|
| 11 |
+
# 只有当两个图像都存在时才执行推理
|
| 12 |
+
if source_image is not None and target_image is not None:
|
| 13 |
+
merged, match_show = inference_engine.inference(source_image, target_image)
|
| 14 |
+
return merged, match_show
|
| 15 |
+
else:
|
| 16 |
+
# 如果任何一个图像为空,则返回空结果
|
| 17 |
+
return None, None
|
| 18 |
|
| 19 |
with gr.Blocks() as demo:
|
| 20 |
gr.Markdown("SuperRetina CFP Registration Demo")
|
|
|
|
| 27 |
output_image = gr.Image(type="numpy", label="Output")
|
| 28 |
match_show_image = gr.Image(type="numpy", label="Match Show")
|
| 29 |
|
| 30 |
+
# 当任一图像输入发生变化时触发推理(但实际推理只在两个图像都存在时执行)
|
| 31 |
source_image_input.change(
|
| 32 |
fn=main,
|
| 33 |
inputs=[source_image_input, target_image_input],
|