fffiloni commited on
Commit
6dd1a7f
1 Parent(s): 3af7001

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +27 -10
app.py CHANGED
@@ -1,31 +1,48 @@
1
  import gradio as gr
2
  from gradio_client import Client
3
  import os
 
4
 
5
  hf_token = os.environ.get("HF_TKN")
6
 
 
 
7
  from style_template import styles
8
  STYLE_NAMES = list(styles.keys())
9
  DEFAULT_STYLE_NAME = "(No style)"
10
 
 
 
 
 
 
11
  def get_instantID(portrait_in, condition_pose, prompt, style):
12
- client = Client("https://fffiloni-instantid.hf.space/", hf_token=hf_token)
13
  negative_prompt = "(lowres, low quality, worst quality:1.2), (text:1.2), watermark, (frame:1.2), deformed, ugly, deformed eyes, blur, out of focus, blurry, deformed, monochrome, gun, weapon"
 
 
 
14
  result = client.predict(
15
  portrait_in, # filepath in 'Upload a photo of your face' Image component
16
- condition_pose, # filepath in 'Upload a reference pose image (optional)' Image component
17
- prompt, # str in 'Prompt' Textbox component
18
  negative_prompt, # str in 'Negative Prompt' Textbox component
19
- style, # Literal['(No style)', 'Watercolor', 'Film Noir', 'Neon', 'Jungle', 'Mars', 'Vibrant Color', 'Snow', 'Line art'] in 'Style template' Dropdown component
20
- True, # bool in 'Enhance non-face region' Checkbox component
21
- 20, # float (numeric value between 20 and 100) in 'Number of sample steps' Slider component
22
- 0.8, # float (numeric value between 0 and 1.5) in 'IdentityNet strength (for fedility)' Slider component
23
  0.8, # float (numeric value between 0 and 1.5) in 'Image adapter strength (for detail)' Slider component
24
- 5, # float (numeric value between 0.1 and 10.0) in 'Guidance scale' Slider component
 
 
 
 
25
  0, # float (numeric value between 0 and 2147483647) in 'Seed' Slider component
26
- True, # bool in 'Randomize seed' Checkbox component
 
 
27
  api_name="/generate_image"
28
  )
 
29
  print(result)
30
  return result[0]
31
 
@@ -42,7 +59,7 @@ def get_video_i2vgen(image_in, prompt):
42
  def get_video_svd(image_in):
43
  from gradio_client import Client
44
 
45
- client = Client("https://multimodalart-stable-video-diffusion.hf.space/--replicas/ej45m/")
46
  result = client.predict(
47
  image_in, # filepath in 'Upload your image' Image component
48
  0, # float (numeric value between 0 and 9223372036854775807) in 'Seed' Slider component
 
1
  import gradio as gr
2
  from gradio_client import Client
3
  import os
4
+ import random
5
 
6
  hf_token = os.environ.get("HF_TKN")
7
 
8
+ # global variable
9
+ MAX_SEED = np.iinfo(np.int32).max
10
  from style_template import styles
11
  STYLE_NAMES = list(styles.keys())
12
  DEFAULT_STYLE_NAME = "(No style)"
13
 
14
+ def randomize_seed_fn(seed: int, randomize_seed: bool) -> int:
15
+ if randomize_seed:
16
+ seed = random.randint(0, MAX_SEED)
17
+ return seed
18
+
19
  def get_instantID(portrait_in, condition_pose, prompt, style):
20
+
21
  negative_prompt = "(lowres, low quality, worst quality:1.2), (text:1.2), watermark, (frame:1.2), deformed, ugly, deformed eyes, blur, out of focus, blurry, deformed, monochrome, gun, weapon"
22
+ seed = random.randint(0, MAX_SEED)
23
+
24
+ client = Client("https://instantx-instantid.hf.space/")
25
  result = client.predict(
26
  portrait_in, # filepath in 'Upload a photo of your face' Image component
27
+ condition_pose, # filepath in 'Upload a reference pose image (Optional)' Image component
28
+ prompt, # str in 'Prompt' Textbox component
29
  negative_prompt, # str in 'Negative Prompt' Textbox component
30
+ style, # Literal['(No style)', 'Spring Festival', 'Watercolor', 'Film Noir', 'Neon', 'Jungle', 'Mars', 'Vibrant Color', 'Snow', 'Line art'] in 'Style template' Dropdown component
31
+ 20, # float (numeric value between 1 and 100) in 'Number of sample steps' Slider component
32
+ 0.8, # float (numeric value between 0 and 1.5) in 'IdentityNet strength (for fidelity)' Slider component
 
33
  0.8, # float (numeric value between 0 and 1.5) in 'Image adapter strength (for detail)' Slider component
34
+ 0.4, # float (numeric value between 0 and 1.5) in 'Pose strength' Slider component
35
+ 0.4, # float (numeric value between 0 and 1.5) in 'Canny strength' Slider component
36
+ 0.4, # float (numeric value between 0 and 1.5) in 'Depth strength' Slider component
37
+ ["pose"], # List[Literal['pose', 'canny', 'depth']] in 'Controlnet' Checkboxgroup component
38
+ 5, # float (numeric value between 0.1 and 20.0) in 'Guidance scale' Slider component
39
  0, # float (numeric value between 0 and 2147483647) in 'Seed' Slider component
40
+ "EulerDiscreteScheduler", # Literal['DEISMultistepScheduler', 'HeunDiscreteScheduler', 'EulerDiscreteScheduler', 'DPMSolverMultistepScheduler', 'DPMSolverMultistepScheduler-Karras', 'DPMSolverMultistepScheduler-Karras-SDE'] in 'Schedulers' Dropdown component
41
+ True, # bool in 'Enable Fast Inference with LCM' Checkbox component
42
+ True, # bool in 'Enhance non-face region' Checkbox component
43
  api_name="/generate_image"
44
  )
45
+
46
  print(result)
47
  return result[0]
48
 
 
59
  def get_video_svd(image_in):
60
  from gradio_client import Client
61
 
62
+ client = Client("https://multimodalart-stable-video-diffusion.hf.space/")
63
  result = client.predict(
64
  image_in, # filepath in 'Upload your image' Image component
65
  0, # float (numeric value between 0 and 9223372036854775807) in 'Seed' Slider component