georgefen radames commited on
Commit
8828684
β€’
1 Parent(s): 71b2c26

Examples (#1)

Browse files

- Examples (ffd54f81d3b1b5f3ef7f90a2495ca70a168bddb7)


Co-authored-by: RadamΓ©s Ajna <radames@users.noreply.huggingface.co>

app.py CHANGED
@@ -51,6 +51,8 @@ def get_68landmarks_img(img):
51
  return con_img
52
 
53
  def process(input_image, prompt, a_prompt, n_prompt, num_samples, image_resolution, ddim_steps, guess_mode, landmark_direct_mode, strength, scale, seed, eta):
 
 
54
  with torch.no_grad():
55
  img = resize_image(HWC3(input_image), image_resolution)
56
  H, W, C = img.shape
@@ -66,7 +68,7 @@ def process(input_image, prompt, a_prompt, n_prompt, num_samples, image_resoluti
66
  control = einops.rearrange(control, 'b h w c -> b c h w').clone()
67
 
68
  if seed == -1:
69
- seed = random.randint(0, 65535)
70
  seed_everything(seed)
71
 
72
  if config.save_memory:
@@ -105,7 +107,7 @@ with block:
105
  prompt = gr.Textbox(label="Prompt")
106
  run_button = gr.Button(label="Run")
107
  with gr.Accordion("Advanced options", open=False):
108
- num_samples = gr.Slider(label="Images", minimum=1, maximum=12, value=1, step=1)
109
  image_resolution = gr.Slider(label="Image Resolution", minimum=256, maximum=768, value=512, step=64)
110
  strength = gr.Slider(label="Control Strength", minimum=0.0, maximum=2.0, value=1.0, step=0.01)
111
  guess_mode = gr.Checkbox(label='Guess Mode', value=False)
@@ -120,6 +122,13 @@ with block:
120
  with gr.Column():
121
  result_gallery = gr.Gallery(label='Output', show_label=False, elem_id="gallery").style(grid=2, height='auto')
122
  ips = [input_image, prompt, a_prompt, n_prompt, num_samples, image_resolution, ddim_steps, guess_mode, landmark_direct_mode, strength, scale, seed, eta]
 
 
 
 
 
 
 
123
  run_button.click(fn=process, inputs=ips, outputs=[result_gallery])
124
 
125
 
 
51
  return con_img
52
 
53
  def process(input_image, prompt, a_prompt, n_prompt, num_samples, image_resolution, ddim_steps, guess_mode, landmark_direct_mode, strength, scale, seed, eta):
54
+ input_image = np.flip(input_image, axis=2)
55
+ num_samples = min(num_samples, 2) # Limit the number of samples to 2 for Spaces only
56
  with torch.no_grad():
57
  img = resize_image(HWC3(input_image), image_resolution)
58
  H, W, C = img.shape
 
68
  control = einops.rearrange(control, 'b h w c -> b c h w').clone()
69
 
70
  if seed == -1:
71
+ seed = random.randint(0, 2**32 - 1)
72
  seed_everything(seed)
73
 
74
  if config.save_memory:
 
107
  prompt = gr.Textbox(label="Prompt")
108
  run_button = gr.Button(label="Run")
109
  with gr.Accordion("Advanced options", open=False):
110
+ num_samples = gr.Slider(label="Images", minimum=1, maximum=2, value=1, step=1)
111
  image_resolution = gr.Slider(label="Image Resolution", minimum=256, maximum=768, value=512, step=64)
112
  strength = gr.Slider(label="Control Strength", minimum=0.0, maximum=2.0, value=1.0, step=0.01)
113
  guess_mode = gr.Checkbox(label='Guess Mode', value=False)
 
122
  with gr.Column():
123
  result_gallery = gr.Gallery(label='Output', show_label=False, elem_id="gallery").style(grid=2, height='auto')
124
  ips = [input_image, prompt, a_prompt, n_prompt, num_samples, image_resolution, ddim_steps, guess_mode, landmark_direct_mode, strength, scale, seed, eta]
125
+ gr.Examples(fn=process, examples=[
126
+ ["examples/image0.jpg", "a silly clown face", "best quality, extremely detailed", "cartoon, disfigured, bad art, deformed, poorly drawn, extra limbs, weird colors, blurry, lowres, bad anatomy, bad hands, missing fingers, extra digit, fewer digits, cropped, worst quality, low quality", 1, 512, 20, False, False, 1.0, 9.0, -1, 0.0],
127
+ ["examples/image1.png", "a photo of a woman wearing glasses", "best quality, extremely detailed", "cartoon, disfigured, bad art, deformed, poorly drawn, extra limbs, weird colors, blurry, lowres, bad anatomy, bad hands, missing fingers, extra digit, fewer digits, cropped, worst quality, low quality", 1, 512, 20, False, False, 1.0, 9.0, -1, 0.0],
128
+ ["examples/image2.png", "a silly portrait of man with head tilted and a beautiful hair on the side", "best quality, extremely detailed", "cartoon, disfigured, bad art, deformed, poorly drawn, extra limbs, weird colors, blurry, lowres, bad anatomy, bad hands, missing fingers, extra digit, fewer digits, cropped, worst quality, low quality", 1, 512, 20, False, False, 1.0, 9.0, -1, 0.0],
129
+ ["examples/image3.png", "portrait handsome men", "best quality, extremely detailed", "cartoon, disfigured, bad art, deformed, poorly drawn, extra limbs, weird colors, blurry, lowres, bad anatomy, bad hands, missing fingers, extra digit, fewer digits, cropped, worst quality, low quality", 1, 512, 20, False, False, 1.0, 9.0, -1, 0.0],
130
+ ["examples/image4.jpg", "a beautiful woman looking at the sky", "best quality, extremely detailed", "cartoon, disfigured, bad art, deformed, poorly drawn, extra limbs, weird colors, blurry, lowres, bad anatomy, bad hands, missing fingers, extra digit, fewer digits, cropped, worst quality, low quality", 1, 512, 20, False, False, 1.0, 9.0, -1, 0.0],
131
+ ],inputs=ips, outputs=[result_gallery], cache_examples=True)
132
  run_button.click(fn=process, inputs=ips, outputs=[result_gallery])
133
 
134
 
examples/image0.jpg ADDED
examples/image1.png ADDED
examples/image2.png ADDED
examples/image3.png ADDED
examples/image4.jpg ADDED
requirements.txt CHANGED
@@ -21,4 +21,5 @@ yapf==0.32.0
21
  prettytable==3.6.0
22
  safetensors==0.2.7
23
  basicsr==1.4.2
24
- dlib==19.24.0
 
 
21
  prettytable==3.6.0
22
  safetensors==0.2.7
23
  basicsr==1.4.2
24
+ dlib==19.24.0
25
+ xformers