Linoy Tsaban commited on
Commit
7bb8383
1 Parent(s): b30a076

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +57 -57
app.py CHANGED
@@ -94,69 +94,69 @@ def edit(input_image,
94
 
95
 
96
  ####################################
97
-
98
- with gr.Blocks() as demo:
99
- gr.HTML("""<h1 style="font-weight: 900; margin-bottom: 7px;">
100
  Edit Friendly DDPM X Semantic Guidance: Editing Real Images
101
  </h1>
102
  <p>For faster inference without waiting in queue, you may duplicate the space and upgrade to GPU in settings.
103
  <br/>
104
  <a href="https://huggingface.co/spaces/LinoyTsaban/ddpm_sega?duplicate=true">
105
  <img style="margin-top: 0em; margin-bottom: 0em" src="https://bit.ly/3gLdBN6" alt="Duplicate Space"></a>
106
- <p/>""")
107
- with gr.Row():
108
- with gr.Column(scale=1, min_width=100):
109
- generate_button = gr.Button("Generate")
110
- # with gr.Column(scale=1, min_width=100):
111
- # reset_button = gr.Button("Reset")
112
- # with gr.Column(scale=3):
113
- # instruction = gr.Textbox(lines=1, label="Edit Instruction", interactive=True)
114
-
115
- with gr.Row():
116
- input_image = gr.Image(label="Input Image", type="pil", interactive=True)
117
- ddpm_edited_image = gr.Image(label=f"Reconstructed Image", type="pil", interactive=False)
118
- sega_edited_image = gr.Image(label=f"Edited Image", type="pil", interactive=False)
119
- input_image.style(height=512, width=512)
120
- ddpm_edited_image.style(height=512, width=512)
121
- sega_edited_image.style(height=512, width=512)
122
-
123
- with gr.Row():
124
- src_prompt = gr.Textbox(lines=1, label="Source Prompt", interactive=True)
125
- #edit
126
- tar_prompt = gr.Textbox(lines=1, label="Target Prompt", interactive=True)
127
-
128
- with gr.Row():
129
- #inversion
130
- steps = gr.Number(value=100, precision=0, label="Steps", interactive=True)
131
- src_cfg_scale = gr.Number(value=3.5, label=f"Source CFG", interactive=True)
132
- # reconstruction
133
- skip = gr.Number(value=100, precision=0, label="Skip", interactive=True)
134
- tar_cfg_scale = gr.Number(value=15, label=f"Reconstruction CFG", interactive=True)
135
- # edit
136
- edit_concept = gr.Textbox(lines=1, label="Edit Concept", interactive=True)
137
- sega_edit_guidance = gr.Number(value=5, label=f"SEGA CFG", interactive=True)
138
- warm_up = gr.Number(value=5, label=f"Warm-up Steps", interactive=True)
139
- neg_guidance = gr.Checkbox(label="SEGA negative_guidance")
140
-
141
-
142
- gr.Markdown(help_text)
143
-
144
- generate_button.click(
145
- fn=edit,
146
- inputs=[input_image,
147
- src_prompt,
148
- tar_prompt,
149
- steps,
150
- src_cfg_scale,
151
- skip,
152
- tar_cfg_scale,
153
- edit_concept,
154
- sega_edit_guidance,
155
- warm_up,
156
- neg_guidance
157
- ],
158
- outputs=[input_image, ddpm_edited_image, sega_edited_image],
159
- )
 
 
160
 
161
 
162
  demo.queue(concurrency_count=1)
 
94
 
95
 
96
  ####################################
97
+ intro = """<h1 style="font-weight: 900; margin-bottom: 7px;">
 
 
98
  Edit Friendly DDPM X Semantic Guidance: Editing Real Images
99
  </h1>
100
  <p>For faster inference without waiting in queue, you may duplicate the space and upgrade to GPU in settings.
101
  <br/>
102
  <a href="https://huggingface.co/spaces/LinoyTsaban/ddpm_sega?duplicate=true">
103
  <img style="margin-top: 0em; margin-bottom: 0em" src="https://bit.ly/3gLdBN6" alt="Duplicate Space"></a>
104
+ <p/>"""
105
+ with gr.Blocks() as demo:
106
+ gr.HTML(intro)
107
+ with gr.Row():
108
+ with gr.Column(scale=1, min_width=100):
109
+ generate_button = gr.Button("Generate")
110
+ # with gr.Column(scale=1, min_width=100):
111
+ # reset_button = gr.Button("Reset")
112
+ # with gr.Column(scale=3):
113
+ # instruction = gr.Textbox(lines=1, label="Edit Instruction", interactive=True)
114
+
115
+ with gr.Row():
116
+ input_image = gr.Image(label="Input Image", type="pil", interactive=True)
117
+ ddpm_edited_image = gr.Image(label=f"Reconstructed Image", type="pil", interactive=False)
118
+ sega_edited_image = gr.Image(label=f"Edited Image", type="pil", interactive=False)
119
+ input_image.style(height=512, width=512)
120
+ ddpm_edited_image.style(height=512, width=512)
121
+ sega_edited_image.style(height=512, width=512)
122
+
123
+ with gr.Row():
124
+ src_prompt = gr.Textbox(lines=1, label="Source Prompt", interactive=True)
125
+ #edit
126
+ tar_prompt = gr.Textbox(lines=1, label="Target Prompt", interactive=True)
127
+
128
+ with gr.Row():
129
+ #inversion
130
+ steps = gr.Number(value=100, precision=0, label="Steps", interactive=True)
131
+ src_cfg_scale = gr.Number(value=3.5, label=f"Source CFG", interactive=True)
132
+ # reconstruction
133
+ skip = gr.Number(value=100, precision=0, label="Skip", interactive=True)
134
+ tar_cfg_scale = gr.Number(value=15, label=f"Reconstruction CFG", interactive=True)
135
+ # edit
136
+ edit_concept = gr.Textbox(lines=1, label="Edit Concept", interactive=True)
137
+ sega_edit_guidance = gr.Number(value=5, label=f"SEGA CFG", interactive=True)
138
+ warm_up = gr.Number(value=5, label=f"Warm-up Steps", interactive=True)
139
+ neg_guidance = gr.Checkbox(label="SEGA negative_guidance")
140
+
141
+
142
+ gr.Markdown(help_text)
143
+
144
+ generate_button.click(
145
+ fn=edit,
146
+ inputs=[input_image,
147
+ src_prompt,
148
+ tar_prompt,
149
+ steps,
150
+ src_cfg_scale,
151
+ skip,
152
+ tar_cfg_scale,
153
+ edit_concept,
154
+ sega_edit_guidance,
155
+ warm_up,
156
+ neg_guidance
157
+ ],
158
+ outputs=[input_image, ddpm_edited_image, sega_edited_image],
159
+ )
160
 
161
 
162
  demo.queue(concurrency_count=1)