WolseyTheCat commited on
Commit
47500db
·
1 Parent(s): 450775e

update spaces

Browse files
Files changed (1) hide show
  1. app.py +6 -2
app.py CHANGED
@@ -2,13 +2,16 @@ import cv2
2
  import numpy as np
3
  from PIL import Image
4
  import os
 
5
  import gradio as gr
6
  from huggingface_hub import hf_hub_download, snapshot_download
7
  import shlex
8
  import subprocess
9
 
 
10
  subprocess.run(shlex.split('pip install flash-attn --no-build-isolation'),
11
  env=os.environ | {'FLASH_ATTENTION_SKIP_CUDA_BUILD': "TRUE"})
 
12
 
13
  def resolve_hf_path(path):
14
  if isinstance(path, str) and path.startswith("hf://"):
@@ -50,7 +53,7 @@ from inference.registry import INFERENCES
50
  config_path = os.path.join("config", "ace_plus_fft.yaml")
51
  cfg = Config(load=True, cfg_file=config_path)
52
  # Instantiate the ACEInference object.
53
- ace_infer = ACEInference(cfg)
54
 
55
  def create_face_mask(pil_image):
56
  """
@@ -94,6 +97,7 @@ def create_face_mask(pil_image):
94
  print(f"Error: {e}")
95
  raise ValueError('A very specific bad thing happened.')
96
 
 
97
  def face_swap_app(target_img, face_img):
98
  if target_img is None or face_img is None:
99
  raise ValueError("Both a target image and a face image must be provided.")
@@ -108,7 +112,7 @@ def face_swap_app(target_img, face_img):
108
  reference_image=target_img,
109
  edit_image=face_img,
110
  edit_mask=edit_mask,
111
- prompt="retain face",
112
  output_height=1024,
113
  output_width=1024,
114
  sampler='flow_euler',
 
2
  import numpy as np
3
  from PIL import Image
4
  import os
5
+ import spaces
6
  import gradio as gr
7
  from huggingface_hub import hf_hub_download, snapshot_download
8
  import shlex
9
  import subprocess
10
 
11
+ subprocess.run("rm -rf /data-nvme/zerogpu-offload/*", env={}, shell=True)
12
  subprocess.run(shlex.split('pip install flash-attn --no-build-isolation'),
13
  env=os.environ | {'FLASH_ATTENTION_SKIP_CUDA_BUILD': "TRUE"})
14
+ subprocess.run(shlex.split('pip install scepter --no-deps'))
15
 
16
  def resolve_hf_path(path):
17
  if isinstance(path, str) and path.startswith("hf://"):
 
53
  config_path = os.path.join("config", "ace_plus_fft.yaml")
54
  cfg = Config(load=True, cfg_file=config_path)
55
  # Instantiate the ACEInference object.
56
+ ace_infer = INFERENCES.build(cfg) # ACEInference(cfg)
57
 
58
  def create_face_mask(pil_image):
59
  """
 
97
  print(f"Error: {e}")
98
  raise ValueError('A very specific bad thing happened.')
99
 
100
+ @spaces.GPU(duration=80)
101
  def face_swap_app(target_img, face_img):
102
  if target_img is None or face_img is None:
103
  raise ValueError("Both a target image and a face image must be provided.")
 
112
  reference_image=target_img,
113
  edit_image=face_img,
114
  edit_mask=edit_mask,
115
+ prompt="maintain the facial features as much as possible",
116
  output_height=1024,
117
  output_width=1024,
118
  sampler='flow_euler',