Rishi Desai commited on
Commit
bf54c2a
·
1 Parent(s): a973422

basics for demo done

Browse files
FaceEnhancementProd.py CHANGED
@@ -188,7 +188,7 @@ def main(
188
  output_image: str,
189
  dist_image: str = None,
190
  positive_prompt: str = "",
191
- # models: dict = None
192
  ):
193
  global models
194
  if models is None:
@@ -241,7 +241,7 @@ def main(
241
  saveimage = SaveImage()
242
 
243
  applypulidflux_133 = applypulidflux.apply_pulid_flux(
244
- weight=0.7500000000000001,
245
  start_at=0.10000000000000002,
246
  end_at=1,
247
  fusion="mean",
@@ -317,9 +317,9 @@ def save_comfy_images(images, output_dirs):
317
  pil_image.save(output_dirs[idx])
318
 
319
 
320
- def enhance_face(face_image: str, input_image: str, output_image: str, dist_image: str = None, positive_prompt: str = ""):
321
  initialize_models() # Ensure models are loaded
322
- main(face_image, input_image, output_image, dist_image, positive_prompt)
323
 
324
  if __name__ == "__main__":
325
  pass
 
188
  output_image: str,
189
  dist_image: str = None,
190
  positive_prompt: str = "",
191
+ id_weight: float = 0.75,
192
  ):
193
  global models
194
  if models is None:
 
241
  saveimage = SaveImage()
242
 
243
  applypulidflux_133 = applypulidflux.apply_pulid_flux(
244
+ weight=id_weight,
245
  start_at=0.10000000000000002,
246
  end_at=1,
247
  fusion="mean",
 
317
  pil_image.save(output_dirs[idx])
318
 
319
 
320
+ def enhance_face(face_image: str, input_image: str, output_image: str, dist_image: str = None, positive_prompt: str = "", id_weight: float = 0.75):
321
  initialize_models() # Ensure models are loaded
322
+ main(face_image, input_image, output_image, dist_image, positive_prompt, id_weight)
323
 
324
  if __name__ == "__main__":
325
  pass
demo.py CHANGED
@@ -4,6 +4,8 @@ import tempfile
4
  from main import process_face
5
  from PIL import Image
6
 
 
 
7
  def enhance_face_gradio(input_image, ref_image):
8
  """
9
  Wrapper function for process_face that works with Gradio.
@@ -87,18 +89,25 @@ def create_gradio_interface():
87
  # Add examples using gr.Examples
88
  gr.Markdown("## Examples")
89
  example_inps = [
90
- ["examples/chatgpt_dany_1.png", "examples/dany_face.jpg"],
91
- ["examples/chatgpt_dany_2.png", "examples/dany_face.jpg"]
92
  ]
93
  gr.Examples(examples=example_inps, inputs=[input_image, ref_image], outputs=output_image)
94
 
95
  # Launch the Gradio app with queue
96
- demo.queue(max_size=20)
97
- demo.launch(
98
- share=True, # Set to True if you want a public link
99
- server_name="0.0.0.0", # Make available on all network interfaces
100
- server_port=7860,
101
- )
 
 
 
 
 
 
 
102
 
103
 
104
  if __name__ == "__main__":
 
4
  from main import process_face
5
  from PIL import Image
6
 
7
+ PORT = 7860
8
+
9
  def enhance_face_gradio(input_image, ref_image):
10
  """
11
  Wrapper function for process_face that works with Gradio.
 
89
  # Add examples using gr.Examples
90
  gr.Markdown("## Examples")
91
  example_inps = [
92
+ ["examples/dany_gpt_1.png", "examples/dany_face.jpg"],
93
+ ["examples/dany_gpt_2.png", "examples/dany_face.jpg"],
94
  ]
95
  gr.Examples(examples=example_inps, inputs=[input_image, ref_image], outputs=output_image)
96
 
97
  # Launch the Gradio app with queue
98
+ demo.queue(max_size=99)
99
+
100
+ try:
101
+ demo.launch(
102
+ share=True,
103
+ server_name="0.0.0.0",
104
+ server_port=PORT,
105
+ quiet=True,
106
+ show_error=True,
107
+ )
108
+ except OSError as e:
109
+ print(f"Error starting server: {e}")
110
+ sys.exit(1)
111
 
112
 
113
  if __name__ == "__main__":
examples/{enhanced_dany_1.png → dany_enhanced_1.png} RENAMED
File without changes
examples/{enhanced_dany_2.png → dany_enhanced_2.png} RENAMED
File without changes
examples/{chatgpt_dany_1.png → dany_gpt_1.png} RENAMED
File without changes
examples/{chatgpt_dany_2.png → dany_gpt_2.png} RENAMED
File without changes
examples/{enhanced_elon.png → elon_enhanced.png} RENAMED
File without changes
examples/{chatgpt_elon.png → elon_gpt.png} RENAMED
File without changes
main.py CHANGED
@@ -83,7 +83,7 @@ def process_face(input_path, ref_path, crop=False, upscale=False, output_path=No
83
  comfy_ref_path = os.path.relpath(scratch_ref, "./ComfyUI/input")
84
  comfy_input_path = os.path.relpath(scratch_input, "./ComfyUI/input")
85
 
86
- enhance_face(comfy_ref_path, comfy_input_path, output_path, dist_image=f"{output_path}_dist.png")
87
 
88
  print(f"Enhanced image saved to: {output_path}")
89
  print(f"Working files are in: {scratch_dir}")
 
83
  comfy_ref_path = os.path.relpath(scratch_ref, "./ComfyUI/input")
84
  comfy_input_path = os.path.relpath(scratch_input, "./ComfyUI/input")
85
 
86
+ enhance_face(comfy_ref_path, comfy_input_path, output_path, dist_image=f"{output_path}_dist.png", id_weight=0.75)
87
 
88
  print(f"Enhanced image saved to: {output_path}")
89
  print(f"Working files are in: {scratch_dir}")