rishi commited on
Commit
2b8d1f6
·
1 Parent(s): 2915200

more readme updates; demo cleanup

Browse files
Files changed (3) hide show
  1. README.md +6 -9
  2. demo.py +15 -8
  3. test.py +1 -5
README.md CHANGED
@@ -21,7 +21,7 @@ A tool for improving facial consistency and quality in AI-generated images. Dram
21
  ### Prerequisites
22
  - Python 3.11 or higher
23
  - 1 GPU with 48GB VRAM
24
- - At least 50GB of free disk space
25
 
26
  ### Setup
27
 
@@ -33,7 +33,7 @@ A tool for improving facial consistency and quality in AI-generated images. Dram
33
  export HUGGINGFACE_TOKEN=your_token_here
34
  export HF_HOME=/path/to/your/huggingface_cache
35
  ```
36
- - Models will be downloaded to `$HF_HOME` and symlinked to `./ComfyUI/models/`
37
 
38
  2. Create the virtual environment:
39
  ```
@@ -73,9 +73,6 @@ A tool for improving facial consistency and quality in AI-generated images. Dram
73
  - `--input` (str): Path to the input image.
74
  - `--ref` (str): Path to the reference face image.
75
  - `--output` (str): Path to save the output image.
76
- - `--crop` (store_true): Flag to face crop the reference image. Default: False.
77
- - `--upscale` (store_true): Flag to upscale the (cropped) reference image. Default: False.
78
- - `--caption` (store_true): Flag to caption the input image. Default: False.
79
  - `--id_weight` (float): Face ID weight. Default: 0.75.
80
  </details>
81
 
@@ -89,15 +86,15 @@ A simple web interface for the face enhancement workflow.
89
 
90
  ## Running on ComfyUI
91
 
92
- Using the ComfyUI workflows is the fastest way to get started. Run `python run_comfy.py`. There are two workflows:
93
- - `./workflows/FaceEnhancementProd.json` for face enhancement
94
- - `./workflows/FaceEmbedDist.json` for computing the [face embedding distance](https://github.com/cubiq/ComfyUI_FaceAnalysis)
95
 
96
 
97
  ### Notes
98
  - The script and demo run a ComfyUI server ephemerally
99
  - Gradio demo is faster than the script because the models remain loaded in memory and ComfyUI server is booted up.
100
- - All images are saved in `./ComfyUI/input/scratch/`
101
  - `FaceEnhancementProd.py` was created with the [ComfyUI-to-Python-Extension](https://github.com/pydn/ComfyUI-to-Python-Extension) and re-engineered for efficiency and function.
102
  - Face cropping, upscaling, and captioning are unavailable; these will be added in an update.
103
 
 
21
  ### Prerequisites
22
  - Python 3.11 or higher
23
  - 1 GPU with 48GB VRAM
24
+ - At least 60GB of free disk space
25
 
26
  ### Setup
27
 
 
33
  export HUGGINGFACE_TOKEN=your_token_here
34
  export HF_HOME=/path/to/your/huggingface_cache
35
  ```
36
+ - Models will be downloaded to `$HF_HOME` and symlinked to `FaceEnhance/ComfyUI/models/`
37
 
38
  2. Create the virtual environment:
39
  ```
 
73
  - `--input` (str): Path to the input image.
74
  - `--ref` (str): Path to the reference face image.
75
  - `--output` (str): Path to save the output image.
 
 
 
76
  - `--id_weight` (float): Face ID weight. Default: 0.75.
77
  </details>
78
 
 
86
 
87
  ## Running on ComfyUI
88
 
89
+ Run `python run_comfy.py`. There are two workflows:
90
+ - `FaceEnhance/workflows/FaceEnhancementProd.json` for face enhancement
91
+ - `FaceEnhance/workflows/FaceEmbedDist.json` for computing the [face embedding distance](https://github.com/cubiq/ComfyUI_FaceAnalysis)
92
 
93
 
94
  ### Notes
95
  - The script and demo run a ComfyUI server ephemerally
96
  - Gradio demo is faster than the script because the models remain loaded in memory and ComfyUI server is booted up.
97
+ - Images are saved in `FaceEnhance/ComfyUI/input/scratch/`
98
  - `FaceEnhancementProd.py` was created with the [ComfyUI-to-Python-Extension](https://github.com/pydn/ComfyUI-to-Python-Extension) and re-engineered for efficiency and function.
99
  - Face cropping, upscaling, and captioning are unavailable; these will be added in an update.
100
 
demo.py CHANGED
@@ -98,17 +98,15 @@ def enhance_face_gradio(input_image, ref_image):
98
  return result_img
99
 
100
  def create_gradio_interface():
101
- with gr.Blocks(title="Face Enhancement Demo") as demo:
102
  gr.Markdown("""
103
- # Face Enhancement
104
  ### Instructions
105
  1. Upload the target image you want to enhance
106
- 2. Upload a high-quality reference face image
107
  3. Click 'Enhance Face'
108
 
109
- Processing takes about 60 seconds. Due to the constraints of this demo, face cropping and upscaling are not applied to the reference image.
110
-
111
- For more information, check out my [blog post](https://rishidesai.github.io/posts/face-enhancement-techniques/).
112
  """, elem_id="instructions")
113
 
114
  gr.Markdown("---")
@@ -128,8 +126,10 @@ def create_gradio_interface():
128
  outputs=output_image,
129
  queue=True # Enable queue for sequential processing
130
  )
131
-
132
- gr.Markdown("## Examples\nClick on an example to load the images into the interface.")
 
 
133
  example_inps = [
134
  ["examples/dany_gpt_1.png", "examples/dany_face.jpg"],
135
  ["examples/dany_gpt_2.png", "examples/dany_face.jpg"],
@@ -139,6 +139,13 @@ def create_gradio_interface():
139
  ]
140
  gr.Examples(examples=example_inps, inputs=[input_image, ref_image], outputs=output_image)
141
 
 
 
 
 
 
 
 
142
  # Launch the Gradio app with queue
143
  demo.queue(max_size=99)
144
 
 
98
  return result_img
99
 
100
  def create_gradio_interface():
101
+ with gr.Blocks(title="Face Enhancement") as demo:
102
  gr.Markdown("""
103
+ # Face Enhance
104
  ### Instructions
105
  1. Upload the target image you want to enhance
106
+ 2. Upload a high-quality face image
107
  3. Click 'Enhance Face'
108
 
109
+ Processing takes about 60 seconds.
 
 
110
  """, elem_id="instructions")
111
 
112
  gr.Markdown("---")
 
126
  outputs=output_image,
127
  queue=True # Enable queue for sequential processing
128
  )
129
+ gr.Markdown("""
130
+ ## Examples
131
+ Click on an example to load the images into the interface.
132
+ """)
133
  example_inps = [
134
  ["examples/dany_gpt_1.png", "examples/dany_face.jpg"],
135
  ["examples/dany_gpt_2.png", "examples/dany_face.jpg"],
 
139
  ]
140
  gr.Examples(examples=example_inps, inputs=[input_image, ref_image], outputs=output_image)
141
 
142
+ gr.Markdown("""
143
+ ## Notes
144
+ Check out the code [here](https://github.com/RishiDesai/FaceEnhance) and see my [blog post](https://rishidesai.github.io/posts/face-enhancement-techniques/) for more information.
145
+
146
+ Due to the constraints of this demo, face cropping and upscaling are not applied to the reference image.
147
+ """)
148
+
149
  # Launch the Gradio app with queue
150
  demo.queue(max_size=99)
151
 
test.py CHANGED
@@ -7,8 +7,6 @@ def parse_args():
7
  parser = argparse.ArgumentParser(description='Face Enhancement Tool')
8
  parser.add_argument('--input', type=str, required=True, help='Path to the input image')
9
  parser.add_argument('--ref', type=str, required=True, help='Path to the reference image')
10
- parser.add_argument('--crop', action='store_true', help='Whether to crop the image')
11
- parser.add_argument('--upscale', action='store_true', help='Whether to upscale the image')
12
  parser.add_argument('--output', type=str, required=True, help='Path to save the output image')
13
  parser.add_argument('--id_weight', type=float, default=0.75, help='face ID weight')
14
  args = parser.parse_args()
@@ -41,7 +39,7 @@ def create_scratch_dir():
41
 
42
  return new_dir
43
 
44
- def process_face(input_path, ref_path, crop=False, upscale=False, output_path=None, id_weight=0.75):
45
  """
46
  Process a face image using the given parameters.
47
 
@@ -83,8 +81,6 @@ def main():
83
  return process_face(
84
  input_path=args.input,
85
  ref_path=args.ref,
86
- crop=args.crop,
87
- upscale=args.upscale,
88
  output_path=args.output,
89
  id_weight=args.id_weight
90
  )
 
7
  parser = argparse.ArgumentParser(description='Face Enhancement Tool')
8
  parser.add_argument('--input', type=str, required=True, help='Path to the input image')
9
  parser.add_argument('--ref', type=str, required=True, help='Path to the reference image')
 
 
10
  parser.add_argument('--output', type=str, required=True, help='Path to save the output image')
11
  parser.add_argument('--id_weight', type=float, default=0.75, help='face ID weight')
12
  args = parser.parse_args()
 
39
 
40
  return new_dir
41
 
42
+ def process_face(input_path, ref_path, output_path=None, id_weight=0.75):
43
  """
44
  Process a face image using the given parameters.
45
 
 
81
  return process_face(
82
  input_path=args.input,
83
  ref_path=args.ref,
 
 
84
  output_path=args.output,
85
  id_weight=args.id_weight
86
  )