sandhyasinha655 commited on
Commit
769b917
·
verified ·
1 Parent(s): 740593e

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -9
app.py CHANGED
@@ -13,41 +13,38 @@ def face_swap(source_img, target_media):
13
  if source_img is None or target_media is None:
14
  raise gr.Error("Please upload both source image and target media.")
15
 
16
- # ===== YAHAN MERI GALTI THI, AB THEEK HAI =====
17
- # OLD: source_path = source_img.name
18
- # NEW: Gradio 'filepath' type mein seedha path (string) deta hai.
19
  source_path = source_img
20
  target_path = target_media
21
- # ===============================================
22
 
23
  # Output file ka naam tay karna
24
  output_filename = os.path.basename(target_path)
25
  os.makedirs("output", exist_ok=True)
26
  output_path = os.path.join("output", f"result_{output_filename}")
27
 
28
- # Roop ko chalane ke liye arguments set karna
 
 
29
  args = [
30
  "run.py",
31
  "--source", source_path,
32
  "--target", target_path,
33
  "--output", output_path,
34
  "--execution-provider", "cpu",
35
- "-e"
 
36
  ]
 
37
  sys.argv = args
38
 
39
  print(f"Running roop with args: {sys.argv}")
40
 
41
- # Asli face swap process yahan run hoga
42
  try:
43
  roop_run()
44
  except Exception as e:
45
- # Error aane par user ko message dikhana
46
  raise gr.Error(f"Face swap failed. Error: {str(e)}")
47
 
48
  print(f"Processing complete. Result at: {output_path}")
49
 
50
- # Result ko UI mein dikhana
51
  return output_path
52
 
53
  # --- Gradio UI ---
 
13
  if source_img is None or target_media is None:
14
  raise gr.Error("Please upload both source image and target media.")
15
 
 
 
 
16
  source_path = source_img
17
  target_path = target_media
 
18
 
19
  # Output file ka naam tay karna
20
  output_filename = os.path.basename(target_path)
21
  os.makedirs("output", exist_ok=True)
22
  output_path = os.path.join("output", f"result_{output_filename}")
23
 
24
+ # ===== YAHAN AAKHRI CHANGE HAI =====
25
+ # OLD: "-e"
26
+ # NEW: Face enhancer ke liye poora command
27
  args = [
28
  "run.py",
29
  "--source", source_path,
30
  "--target", target_path,
31
  "--output", output_path,
32
  "--execution-provider", "cpu",
33
+ # Face Enhancer ko chalu karne ka sahi tarika:
34
+ "--frame-processor", "face_swapper", "face_enhancer"
35
  ]
36
+ # ===================================
37
  sys.argv = args
38
 
39
  print(f"Running roop with args: {sys.argv}")
40
 
 
41
  try:
42
  roop_run()
43
  except Exception as e:
 
44
  raise gr.Error(f"Face swap failed. Error: {str(e)}")
45
 
46
  print(f"Processing complete. Result at: {output_path}")
47
 
 
48
  return output_path
49
 
50
  # --- Gradio UI ---