Ashrafb commited on
Commit
bee0a16
·
1 Parent(s): 3b30c4d

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +17 -27
app.py CHANGED
@@ -233,9 +233,7 @@ with gr.Blocks(
233
  css=".gradio-container {background-color: #FDF5E6;} .dark .gradio-container {background-color: black;} footer{display:none !important;}",
234
  ) as demo:
235
  with gr.Column(elem_id="col-container"):
236
- # Step 1: Perform Face Swap
237
  with gr.Row(variant="compact"):
238
- # Define input components
239
  upload_source_image = gr.Image(label="Upload Source Image", source="upload").style(
240
  box={'height': '400px'}
241
  )
@@ -243,7 +241,7 @@ with gr.Blocks(
243
  precision=0,
244
  value=1,
245
  label='Destination Face Position',
246
- info='Specify which face to use from the uploaded image',
247
  visible=False
248
  )
249
  destination_face_position = gr.Number(
@@ -262,7 +260,6 @@ with gr.Blocks(
262
  textarea={'height': '400px'}
263
  )
264
 
265
- # Accordion for advanced options
266
  with gr.Accordion("Advanced options", open=False):
267
  with gr.Row():
268
  style_selection = gr.Radio(
@@ -272,45 +269,38 @@ with gr.Blocks(
272
  label='Image Style'
273
  )
274
  noise_level = gr.Slider(minimum=0.0, maximum=3, step=0.1, label="Noise Level")
 
275
  with gr.Row():
276
  with gr.Row():
277
- # Define buttons
278
- generate_button = gr.Button("AI Image").style(full_width=False)
279
- swap_button = gr.Button("Run").style(full_width=False)
280
 
281
- # Output section
282
  with gr.Row():
283
  with gr.Row():
284
- # Set source to None to disable upload functionality for this output
285
  output_generated_image = gr.Image(label="AI Image", show_share_button=False, interactive=False)
286
- output_face_swap_result = gr.Image(label="Result", show_share_button=False)
287
 
288
- # Define click events for buttons
289
  generate_button.click(send_it1, inputs=[input_text], outputs=[output_generated_image])
290
  swap_button.click(
291
  swap_faces,
292
  inputs=[
293
- output_generated_image, # Source image for face swap
294
- source_face_position, # Referred component for source face position
295
- upload_source_image, # Another image for face swap
296
- destination_face_position # Referred component for destination face position
297
  ],
298
  outputs=[output_face_swap_result]
299
  )
300
 
301
-
302
  with gr.Accordion("Upscaling options", open=False):
303
- with gr.Row():
304
- version = gr.Radio(['v1.2', 'v1.3', 'v1.4',], type="value", default='v1.4', label='version'),
305
- scale = gr.Number(label="Rescaling factor", default=2),
306
- with gr.Row():
307
- Upscale_button = gr.Button("Upscale")
308
- with gr.Row():
309
  with gr.Row():
310
- # Set source to None to disable upload functionality for this output
311
- output_upscaled_image = gr.Image(label="upscaled Image", show_share_button=False, interactive=False)
312
-
313
- Upscale_button.click(inference, inputs=[output_face_swap_result,version, scale], outputs=[output_upscaled_image])
 
 
 
 
314
 
315
-
316
  demo.launch(inline=True).queue
 
233
  css=".gradio-container {background-color: #FDF5E6;} .dark .gradio-container {background-color: black;} footer{display:none !important;}",
234
  ) as demo:
235
  with gr.Column(elem_id="col-container"):
 
236
  with gr.Row(variant="compact"):
 
237
  upload_source_image = gr.Image(label="Upload Source Image", source="upload").style(
238
  box={'height': '400px'}
239
  )
 
241
  precision=0,
242
  value=1,
243
  label='Destination Face Position',
244
+ info='Specify which face to use from the uploaded image',
245
  visible=False
246
  )
247
  destination_face_position = gr.Number(
 
260
  textarea={'height': '400px'}
261
  )
262
 
 
263
  with gr.Accordion("Advanced options", open=False):
264
  with gr.Row():
265
  style_selection = gr.Radio(
 
269
  label='Image Style'
270
  )
271
  noise_level = gr.Slider(minimum=0.0, maximum=3, step=0.1, label="Noise Level")
272
+
273
  with gr.Row():
274
  with gr.Row():
275
+ generate_button = gr.Button("AI Image").style(full_width=False)
276
+ swap_button = gr.Button("Run").style(full_width=False)
 
277
 
 
278
  with gr.Row():
279
  with gr.Row():
 
280
  output_generated_image = gr.Image(label="AI Image", show_share_button=False, interactive=False)
281
+ output_face_swap_result = gr.Image(type="filepath",label="Result", show_share_button=False)
282
 
 
283
  generate_button.click(send_it1, inputs=[input_text], outputs=[output_generated_image])
284
  swap_button.click(
285
  swap_faces,
286
  inputs=[
287
+ output_generated_image,
288
+ source_face_position,
289
+ upload_source_image,
290
+ destination_face_position
291
  ],
292
  outputs=[output_face_swap_result]
293
  )
294
 
 
295
  with gr.Accordion("Upscaling options", open=False):
 
 
 
 
 
 
296
  with gr.Row():
297
+ version = gr.Radio(['v1.2', 'v1.3', 'v1.4'], type="value", default='v1.4', label='version')
298
+ scale = gr.Number(label="Rescaling factor", default=2)
299
+ with gr.Row():
300
+ Upscale_button = gr.Button("Upscale")
301
+ Upscale_button.click(inference, inputs=[output_face_swap_result, version, scale], outputs=[output_upscaled_image])
302
+ with gr.Row():
303
+ with gr.Row():
304
+ output_upscaled_image = gr.Image(type="numpy",label="upscaled Image", show_share_button=False, interactive=False)
305
 
 
306
  demo.launch(inline=True).queue