ysharma HF staff commited on
Commit
8184a64
1 Parent(s): f65d83c

updated layout

Browse files
Files changed (1) hide show
  1. app.py +14 -2
app.py CHANGED
@@ -1,6 +1,7 @@
1
  import subprocess
2
  from PIL import Image
3
  import gradio as gr
 
4
 
5
  # First, running the inversion command to obtain the input noise that will reconstruct the image.
6
  # It will save the inversion as output/test_cat/inversion/image-name.pt
@@ -64,8 +65,16 @@ with gr.Blocks() as demo:
64
  Please visit their website and <a href="https://github.com/pix2pixzero/pix2pix-zero" target="_blank">github repo</a> for more details.
65
  </p></div>""")
66
  gr.HTML("""<a href="https://huggingface.co/spaces/ysharma/pix2pix-zero-01?duplicate=true"><img src="https://bit.ly/3gLdBN6" alt="Duplicate Space"></a>Duplicate this Space and upgrade to a GPU for fast Inference & no queue<br>""")
67
-
68
  with gr.Row():
 
 
 
 
 
 
 
 
69
  image_in = gr.Image(type="pil", label="Start by uploading an image of a Cat or a Dog that you want to translate")
70
  with gr.Column():
71
  btn_inversion = gr.Button("Get input noise and image caption",visible=False )
@@ -87,10 +96,13 @@ with gr.Blocks() as demo:
87
  image_synth = gr.Image(visible=False, label="Synthetic image generated by Stable Diffusion on the fly")
88
  image_synth_translated = gr.Image(visible=False, label="Translated synthetic image")
89
 
 
 
90
  btn_inversion.click(inversion,[image_in],[inversion_file, blip_prompt])
91
- btn_inversion.click(set_visible_true, [], task_name_radio) #inversion_file, blip_prompt,
92
  btn_inversion.click(set_visible_False, [], btn_inversion)
93
 
 
94
  #task_initial_radio.change(set_visible_true, [], btn_imageedit)
95
 
96
  task_name_radio.change(set_visible_true, [], btn_imageedit)
 
1
  import subprocess
2
  from PIL import Image
3
  import gradio as gr
4
+ import os
5
 
6
  # First, running the inversion command to obtain the input noise that will reconstruct the image.
7
  # It will save the inversion as output/test_cat/inversion/image-name.pt
 
65
  Please visit their website and <a href="https://github.com/pix2pixzero/pix2pix-zero" target="_blank">github repo</a> for more details.
66
  </p></div>""")
67
  gr.HTML("""<a href="https://huggingface.co/spaces/ysharma/pix2pix-zero-01?duplicate=true"><img src="https://bit.ly/3gLdBN6" alt="Duplicate Space"></a>Duplicate this Space and upgrade to a GPU for fast Inference & no queue<br>""")
68
+
69
  with gr.Row():
70
+ gr.Examples(
71
+ examples=[os.path.join(os.path.dirname(__file__), "dog11.jpg"), os.path.join(os.path.dirname(__file__), "cat11.jpg")],
72
+ inputs=image_in,
73
+ #outputs=im_2,
74
+ fn=inversion,
75
+ cache_examples=True,
76
+ )
77
+ direction_html = gr.HTML(value="<h4>👈Click on this example or Upload a Dog or a Cat image to get started👉</h4>", visible=True)
78
  image_in = gr.Image(type="pil", label="Start by uploading an image of a Cat or a Dog that you want to translate")
79
  with gr.Column():
80
  btn_inversion = gr.Button("Get input noise and image caption",visible=False )
 
96
  image_synth = gr.Image(visible=False, label="Synthetic image generated by Stable Diffusion on the fly")
97
  image_synth_translated = gr.Image(visible=False, label="Translated synthetic image")
98
 
99
+ image_in.change(set_visible_False, [], direction_html)
100
+
101
  btn_inversion.click(inversion,[image_in],[inversion_file, blip_prompt])
102
+ #btn_inversion.click(set_visible_true, [], task_name_radio) #inversion_file, blip_prompt,
103
  btn_inversion.click(set_visible_False, [], btn_inversion)
104
 
105
+ inversion_file.change(set_visible_true, [], task_name_radio) #inversion_file, blip_prompt,
106
  #task_initial_radio.change(set_visible_true, [], btn_imageedit)
107
 
108
  task_name_radio.change(set_visible_true, [], btn_imageedit)