fffiloni commited on
Commit
6d1d2e6
1 Parent(s): b6c501b

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +15 -5
app.py CHANGED
@@ -1,8 +1,11 @@
 
1
  import gradio as gr
2
  from gradio_client import Client
3
 
 
 
4
  sdxl_client = Client("https://fffiloni-sdxl-dpo.hf.space/")
5
- faceswap_client = Client("https://tonyassi-face-swap.hf.space/")
6
 
7
  def infer(portrait_in, prompt_in):
8
  # Generate Image from SDXL
@@ -12,12 +15,19 @@ def infer(portrait_in, prompt_in):
12
  api_name="/infer"
13
  )
14
 
 
 
15
  # Face Swap
16
- gr.Info("Face swap your face on result ... This can take a while depending on @tonyassi Face Swap demo queue.")
17
  faceswap_result = faceswap_client.predict(
18
- portrait_in,
19
- sdxl_result,
20
- api_name="/predict"
 
 
 
 
 
21
  )
22
 
23
  return faceswap_result
 
1
+ import os
2
  import gradio as gr
3
  from gradio_client import Client
4
 
5
+ hf_token = os.environ.get('HF_TOKEN')
6
+
7
  sdxl_client = Client("https://fffiloni-sdxl-dpo.hf.space/")
8
+ faceswap_client = Client("https://fffiloni-deepfakeai.hf.space/", hf_token=hf_token)
9
 
10
  def infer(portrait_in, prompt_in):
11
  # Generate Image from SDXL
 
15
  api_name="/infer"
16
  )
17
 
18
+ unique_id = str(uuid.uuid4())
19
+
20
  # Face Swap
21
+ gr.Info("Face swap your face on result ...")
22
  faceswap_result = faceswap_client.predict(
23
+ portrait_in, # str (filepath or URL to image) in 'SOURCE IMAGE' Image component
24
+ sdxl_result, # str (filepath or URL to image) in 'TARGET IMAGE' Image component
25
+ unique_id, # str in 'parameter_12' Textbox component
26
+ ["face_swapper"], # List[str] in 'FRAME PROCESSORS' Checkboxgroup component
27
+ "left-right", # str (Option from: ['left-right', 'right-left', 'top-bottom', 'bottom-top', 'small-large', 'large-small']) in 'FACE ANALYSER DIRECTION' Dropdown component
28
+ "none", # str (Option from: ['none', 'reference', 'many']) in 'FACE RECOGNITION' Dropdown component
29
+ "none", # str (Option from: ['none', 'male', 'female']) in 'FACE ANALYSER GENDER' Dropdown component
30
+ fn_index=1
31
  )
32
 
33
  return faceswap_result