From 79ffcae3d6f027630189a45fe8ce416a5880f439 Mon Sep 17 00:00:00 2001
From: SOULOFCINDER <841135647@qq.com>
Date: Thu, 6 Apr 2023 13:10:02 +0800
Subject: [PATCH] update

---
 git_large_coco/app.py | 52 +++++++++++--------------------------------
 1 file changed, 13 insertions(+), 39 deletions(-)

diff --git a/git_large_coco/app.py b/git_large_coco/app.py
index 079c684..67d4ad1 100644
--- a/git_large_coco/app.py
+++ b/git_large_coco/app.py
@@ -15,46 +15,20 @@ def inference(img):
     return generated_caption
 
 title = "Image to text:git-large-coco"
-description = "Gradio Demo for git-large-coco. To use it, simply upload your image, or click one of the examples to load them."
 article = "<p style='text-align: center'><a href='https://github.com/bryandlee/animegan2-pytorch' target='_blank'>Github Repo Pytorch</a></p> <center><img src='https://visitor-badge.glitch.me/badge?page_id=akhaliq_animegan' alt='visitor badge'></center></p>"
 examples=[['example_cat.jpg'],['Masahiro.png']]
 
-demo = gr.Interface(
-    fn=inference,
-    inputs=[gr.inputs.Image(type="pil")],
-    outputs=gr.outputs.Textbox(),
-    title=title,
-    description=description,
-    article=article,
-    examples=examples)
+with gr.Blocks() as demo:
+    gr.Markdown(
+        """
+    # Image to text:git-large-coco
+    这是一个git-large-coco的Gradio Demo。 上传你想要的图像或者点击下面的示例来加载它。
+    """)
+    with gr.Row():
+        text_input = gr.Image()
+        text_output = gr.Textbox()
+    image_button = gr.Button("上传")
+    image_button.click(inference, inputs=text_input, outputs=text_output)
+    gr.Examples(examples, inputs=text_input)
 
-demo.launch(server_name="0.0.0.0")
-
-
-##
-
-
-# model_dir = "hub/animegan2-pytorch-main"
-# model_dir_weight = "hub/checkpoints/face_paint_512_v1.pt"
-#
-# model2 = torch.hub.load(
-#     model_dir,
-#     "generator",
-#     pretrained=True,
-#     progress=False,
-#     source="local"
-# )
-# model1 = torch.load(model_dir_weight)
-# face2paint = torch.hub.load(
-#     model_dir, 'face2paint',
-#     size=512,side_by_side=False,
-#     source="local"
-# )
-#
-# def inference(img, ver):
-#     if ver == 'version 2 (🔺 robustness,🔻 stylization)':
-#         out = face2paint(model2, img)
-#     else:
-#         out = face2paint(model1, img)
-#     return out
-#
+demo.launch()