ysharma HF staff commited on
Commit
e5f16f0
1 Parent(s): eb96bac

update layout

Browse files
Files changed (1) hide show
  1. app.py +6 -6
app.py CHANGED
@@ -5,7 +5,7 @@ import gradio as gr
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
7
  # BLIP-generated caption prompt is saved as output/test_cat/prompt/image-name.txt - eg., a painting of a cat sitting on top of a ball
8
- def inversion(image_in, progress=gr.Progress(track_tqdm=True)):
9
  progress(0, desc="Starting...")
10
  # saving the input image
11
  image_in.save("assets/test_images/cats/input_image.png")
@@ -20,7 +20,7 @@ def inversion(image_in, progress=gr.Progress(track_tqdm=True)):
20
 
21
  # Performing image editing with the editing directions
22
  # This will save the edited image as output/test_cat/edit/image-name.png
23
- def image_edit(task_name, progress=gr.Progress(track_tqdm=True)):
24
  progress(0, desc="Starting...")
25
  # Run the script file
26
  subprocess.run(["python", "src/edit_real.py", "--inversion", "output/test_cat/inversion/input_image.pt",
@@ -30,7 +30,7 @@ def image_edit(task_name, progress=gr.Progress(track_tqdm=True)):
30
 
31
 
32
  #Similarly, we can edit the synthetic images generated by Stable Diffusion with the following command.
33
- def synthetic_image_edit(prompt, task_name, progress=gr.Progress(track_tqdm=True)):
34
  progress(0, desc="Starting...")
35
  # Run the script file
36
  subprocess.run(["python", "src/edit_synthetic.py", "--prompt_str", prompt,
@@ -64,7 +64,7 @@ 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
  with gr.Row():
67
- image_in = gr.Image(type="pil", label="Upload the image of a cat or a dog you want to translate")
68
  with gr.Column():
69
  btn_inversion = gr.Button("Get input noise",visible=False )
70
  with gr.Row():
@@ -72,10 +72,10 @@ with gr.Blocks() as demo:
72
  inversion_file = gr.File(visible=False)
73
  #task_name = gr.Textbox()
74
  with gr.Row():
75
- image_out = gr.Image(visible=False, label="Trnaslated Image output")
76
  with gr.Column():
77
  task_name_radio = gr.Radio(choices = ["cat2dog", "dog2cat",], type="value", visible=False, label="Select a task that you want to accomplish") #, value="cat2dog"),
78
- btn_imageedit = gr.Button(value="Edit the image!",visible=False)
79
  html_tag = gr.HTML(value="""<h3 style="font-weight: 900; margin-bottom: 7px; margin-top: 5px;">
80
  Generate synthetic images using Stable Diffusion and Translate them on the fly using Pix2Pix-Zero</h3>""", visible=False)
81
  prompt_synth = gr.Textbox(visible=False, label="Type in a prompt to generate an Image using SD")
 
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
7
  # BLIP-generated caption prompt is saved as output/test_cat/prompt/image-name.txt - eg., a painting of a cat sitting on top of a ball
8
+ def inversion(image_in): #, progress=gr.Progress(track_tqdm=True)):
9
  progress(0, desc="Starting...")
10
  # saving the input image
11
  image_in.save("assets/test_images/cats/input_image.png")
 
20
 
21
  # Performing image editing with the editing directions
22
  # This will save the edited image as output/test_cat/edit/image-name.png
23
+ def image_edit(task_name): #, progress=gr.Progress(track_tqdm=True)):
24
  progress(0, desc="Starting...")
25
  # Run the script file
26
  subprocess.run(["python", "src/edit_real.py", "--inversion", "output/test_cat/inversion/input_image.pt",
 
30
 
31
 
32
  #Similarly, we can edit the synthetic images generated by Stable Diffusion with the following command.
33
+ def synthetic_image_edit(prompt, task_name): #, progress=gr.Progress(track_tqdm=True)):
34
  progress(0, desc="Starting...")
35
  # Run the script file
36
  subprocess.run(["python", "src/edit_synthetic.py", "--prompt_str", prompt,
 
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
  with gr.Row():
67
+ image_in = gr.Image(type="pil", label="Start by uploading an image of a Cat or a Dog that you want to translate")
68
  with gr.Column():
69
  btn_inversion = gr.Button("Get input noise",visible=False )
70
  with gr.Row():
 
72
  inversion_file = gr.File(visible=False)
73
  #task_name = gr.Textbox()
74
  with gr.Row():
75
+ image_out = gr.Image(visible=False, label="Translated Image output")
76
  with gr.Column():
77
  task_name_radio = gr.Radio(choices = ["cat2dog", "dog2cat",], type="value", visible=False, label="Select a task that you want to accomplish") #, value="cat2dog"),
78
+ btn_imageedit = gr.Button(value="Translate the image!",visible=False)
79
  html_tag = gr.HTML(value="""<h3 style="font-weight: 900; margin-bottom: 7px; margin-top: 5px;">
80
  Generate synthetic images using Stable Diffusion and Translate them on the fly using Pix2Pix-Zero</h3>""", visible=False)
81
  prompt_synth = gr.Textbox(visible=False, label="Type in a prompt to generate an Image using SD")