AshanGimhana commited on
Commit
959dfe6
·
verified ·
1 Parent(s): 281e227

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -5
app.py CHANGED
@@ -25,23 +25,23 @@ FACE_ANALYSER = insightface.app.FaceAnalysis(
25
  name="buffalo_l",
26
  root=".", providers=providers, allowed_modules=["landmark_3d_68", "landmark_2d_106", "detection", "recognition"]
27
  )
28
- FACE_ANALYSER.prepare(ctx_id=0 if cv2.cuda.getCudaEnabledDeviceCount() > 0 else -1, det_size=(768, 512))
29
 
30
  # Function to update template choices based on gender
31
  def update_templates(gender):
32
  if gender == 'Male':
33
- return gr.Dropdown(choices=['Boy Template 1.JPG', 'Boy Template 2.JPG', 'Boy Template 3.JPG'],interactive=True)
34
  elif gender == 'Female':
35
- return gr.Dropdown(choices=['Girl Template 1.JPG', 'Girl Template 2.JPG', 'Girl Template 3.JPG'], interactive=True)
36
  else:
37
- return gr.Dropdown(choices=[], interactive=True)
38
 
39
  # Main function for face swapping
40
  def face_swap_and_merge(src_image, gender, template_choice):
41
  # Resize the source image to 700x400 for uniform processing
42
  src_image = cv2.resize(src_image, (1181, 1772))
43
 
44
- template_image_path = f'/AshanGimhana/Fanta_App{template_choice}'
45
  template_image = cv2.imread(template_image_path, cv2.IMREAD_UNCHANGED)
46
 
47
  # Resize the template image to 700x400 for uniform processing
@@ -86,3 +86,4 @@ with gr.Blocks(theme='upsatwal/mlsc_tiet') as iface:
86
  clear_all_button.click(fn=clear_all, inputs=[], outputs=[src_image, gender, template_choice, result_image])
87
 
88
  iface.launch(debug=True)
 
 
25
  name="buffalo_l",
26
  root=".", providers=providers, allowed_modules=["landmark_3d_68", "landmark_2d_106", "detection", "recognition"]
27
  )
28
+ FACE_ANALYSER.prepare(ctx_id=0 if cv2.cuda.getCudaEnabledDeviceCount() > 0 else -1, det_size=(640, 640))
29
 
30
  # Function to update template choices based on gender
31
  def update_templates(gender):
32
  if gender == 'Male':
33
+ return gr.Dropdown.update(choices=['Boy Template 1.JPG', 'Boy Template 2.JPG', 'Boy Template 3.JPG'])
34
  elif gender == 'Female':
35
+ return gr.Dropdown.update(choices=['Girl Template 1.JPG', 'Girl Template 2.JPG', 'Girl Template 3.JPG'])
36
  else:
37
+ return gr.Dropdown.update(choices=[])
38
 
39
  # Main function for face swapping
40
  def face_swap_and_merge(src_image, gender, template_choice):
41
  # Resize the source image to 700x400 for uniform processing
42
  src_image = cv2.resize(src_image, (1181, 1772))
43
 
44
+ template_image_path = f'/AshanGimhana/Fanta_App/{template_choice}'
45
  template_image = cv2.imread(template_image_path, cv2.IMREAD_UNCHANGED)
46
 
47
  # Resize the template image to 700x400 for uniform processing
 
86
  clear_all_button.click(fn=clear_all, inputs=[], outputs=[src_image, gender, template_choice, result_image])
87
 
88
  iface.launch(debug=True)
89
+