DegMaTsu commited on
Commit
aaa7bc5
·
verified ·
1 Parent(s): f4d9286

Upload 2 files

Browse files
Files changed (2) hide show
  1. README.md +5 -5
  2. app.py +40 -30
README.md CHANGED
@@ -1,13 +1,13 @@
1
  ---
2
- title: ComfyUI Reactor Fast Face Swap HYPERSWAP
3
- emoji: 🌌
4
- colorFrom: indigo
5
- colorTo: gray
6
  sdk: gradio
7
  app_file: app.py
8
  pinned: false
9
  license: mit
10
- short_description: ComfyUI Reactor Fast Face Swap HYPERSWAP 256!
11
  ---
12
  <div align="center">
13
 
 
1
  ---
2
+ title: ComfyUI Reactor Fast Face Swap HYPERSWAP (CPU)
3
+ emoji:
4
+ colorFrom: yellow
5
+ colorTo: green
6
  sdk: gradio
7
  app_file: app.py
8
  pinned: false
9
  license: mit
10
+ short_description: CPU = UNLIMIT (DUPLICATE this Space!)
11
  ---
12
  <div align="center">
13
 
app.py CHANGED
@@ -161,7 +161,7 @@ loadimage = NODE_CLASS_MAPPINGS["LoadImage"]()
161
  reactorfaceswap = NODE_CLASS_MAPPINGS["ReActorFaceSwap"]()
162
  saveimage = NODE_CLASS_MAPPINGS["SaveImage"]()
163
 
164
- @spaces.GPU
165
  def generate_image(source_image, target_image, target_index, swap_model, face_restore_model, restore_strength):
166
  with torch.inference_mode():
167
  loadimage_2 = loadimage.load_image(image=source_image)
@@ -193,52 +193,62 @@ def generate_image(source_image, target_image, target_index, swap_model, face_re
193
 
194
  if __name__ == "__main__":
195
  with gr.Blocks() as app:
196
- # Заголовок
197
- gr.Markdown("# ComfyUI Reactor Fast Face Swap Hyperswap")
198
-
199
  with gr.Row():
200
  with gr.Column():
201
- # Вложенный Row для групп
202
  with gr.Row():
203
  # Первая группа
204
  with gr.Group():
205
- source_image = gr.Image(label="Source Image (Face)", type="filepath")
206
  swap_model = gr.Dropdown(
207
  choices=["inswapper_128.onnx", "hyperswap_1a_256.onnx", "hyperswap_1b_256.onnx", "hyperswap_1c_256.onnx"],
208
  value="hyperswap_1b_256.onnx",
209
  label="Swap Model"
210
  )
211
- face_restore_model = gr.Dropdown(choices=["none", "GPEN-BFR-512.onnx"], value="none", label="Face Restore Model")
212
- restore_strength = gr.Slider(minimum=0, maximum=1, step=0.05, value=0.7, label="Face Restore Strength")
213
-
214
- # Вторая группа (обратите внимание — она должна быть на том же уровне, что и первая)
 
 
 
 
 
 
 
 
 
 
215
  with gr.Group():
216
- target_image = gr.Image(label="Target Image (Body)", type="filepath")
217
- # restore_strength = gr.Slider(minimum=0, maximum=1, step=0.05, value=0.7, label="Face Restore Strength")
218
- target_index = gr.Dropdown(choices=[0, 1, 2, 3, 4], value=0, label="Target Face Index")
 
 
 
219
  gr.Markdown("Index_0 = Largest Face. To switch for another target face - switch to Index_1, Index_2, e.t.c")
220
-
221
- # Кнопка генерации
222
- generate_btn = gr.Button("Generate")
 
 
 
 
223
  gr.Markdown("***Hyperswap_1b_256.onnx is the best (in most cases) - but sometimes model produce FAIL swap (do not do any swapping). It's known inner bug.")
224
  gr.Markdown("***Hyperswap models do not need Face Restorer - use it with None. Inswapper_128 need Face Restorer - use it with GPEN-BFR-512 at strenght 0.7-0.8.")
225
- gr.Markdown("***Standard time of one generation - 23 sec per image.")
226
- gr.Markdown("***Use Private window in your browser (this clear coockies) and SoftEther VPN (this change your IP) - for expand your limit.")
227
  gr.Markdown(
228
  "***ComfyUI Reactor Fast Face Swap Hyperswap running directly on Gradio. - "
229
  "[How to convert your any ComfyUI workflow to Gradio]"
230
  "(https://huggingface.co/blog/run-comfyui-workflows-on-spaces)"
231
  )
232
-
233
- with gr.Column():
234
- # Вывод изображения
235
- output_image = gr.Image(label="Generated Image")
236
-
237
- # Связываем клик кнопки с функцией
238
- generate_btn.click(
239
- fn=generate_image,
240
- inputs=[source_image, target_image, target_index, swap_model, face_restore_model, restore_strength],
241
- outputs=[output_image]
242
- )
243
-
244
  app.launch(share=True)
 
161
  reactorfaceswap = NODE_CLASS_MAPPINGS["ReActorFaceSwap"]()
162
  saveimage = NODE_CLASS_MAPPINGS["SaveImage"]()
163
 
164
+ #@spaces.GPU
165
  def generate_image(source_image, target_image, target_index, swap_model, face_restore_model, restore_strength):
166
  with torch.inference_mode():
167
  loadimage_2 = loadimage.load_image(image=source_image)
 
193
 
194
  if __name__ == "__main__":
195
  with gr.Blocks() as app:
 
 
 
196
  with gr.Row():
197
  with gr.Column():
198
+ # Вложенный Row для групп (группы расположены горизонтально)
199
  with gr.Row():
200
  # Первая группа
201
  with gr.Group():
202
+ source_image = gr.Image(label="Source (Face)", type="filepath")
203
  swap_model = gr.Dropdown(
204
  choices=["inswapper_128.onnx", "hyperswap_1a_256.onnx", "hyperswap_1b_256.onnx", "hyperswap_1c_256.onnx"],
205
  value="hyperswap_1b_256.onnx",
206
  label="Swap Model"
207
  )
208
+ face_restore_model = gr.Dropdown(
209
+ choices=["none", "GPEN-BFR-512.onnx"],
210
+ value="none",
211
+ label="Face Restore Model"
212
+ )
213
+ restore_strength = gr.Slider(
214
+ minimum=0,
215
+ maximum=1,
216
+ step=0.05,
217
+ value=0.7,
218
+ label="Face Restore Strength"
219
+ )
220
+
221
+ # Вторая группа
222
  with gr.Group():
223
+ target_image = gr.Image(label="Target (Body)", type="filepath")
224
+ target_index = gr.Dropdown(
225
+ choices=[0, 1, 2, 3, 4],
226
+ value=0,
227
+ label="Target Face Index"
228
+ )
229
  gr.Markdown("Index_0 = Largest Face. To switch for another target face - switch to Index_1, Index_2, e.t.c")
230
+ generate_btn = gr.Button("Generate") # Кнопка генерации
231
+
232
+ with gr.Column():
233
+ output_image = gr.Image(label="Generated Image") # Вывод изображения
234
+
235
+ with gr.Row():
236
+ with gr.Column(scale=1):
237
  gr.Markdown("***Hyperswap_1b_256.onnx is the best (in most cases) - but sometimes model produce FAIL swap (do not do any swapping). It's known inner bug.")
238
  gr.Markdown("***Hyperswap models do not need Face Restorer - use it with None. Inswapper_128 need Face Restorer - use it with GPEN-BFR-512 at strenght 0.7-0.8.")
239
+ gr.Markdown("*** This Space uses only CPU. You have unlimited usage in HF Spaces on CPU.")
240
+ gr.Markdown("*** For avoiding queue - duplicate this space to your account (it's free). Top right corner - Three dots - Duplicate this Space. Make them Private. Enjoy!")
241
  gr.Markdown(
242
  "***ComfyUI Reactor Fast Face Swap Hyperswap running directly on Gradio. - "
243
  "[How to convert your any ComfyUI workflow to Gradio]"
244
  "(https://huggingface.co/blog/run-comfyui-workflows-on-spaces)"
245
  )
246
+
247
+ # Связываем клик кнопки с функцией
248
+ generate_btn.click(
249
+ fn=generate_image,
250
+ inputs=[source_image, target_image, target_index, swap_model, face_restore_model, restore_strength],
251
+ outputs=[output_image]
252
+ )
253
+
 
 
 
 
254
  app.launch(share=True)