daquanzhou commited on
Commit
17fa1b2
1 Parent(s): 196ce97

add slider

Browse files
Files changed (1) hide show
  1. app.py +29 -23
app.py CHANGED
@@ -5,6 +5,7 @@ from typing import Sequence, Mapping, Any, Union
5
  import torch
6
  import gradio as gr
7
  from glob import glob
 
8
 
9
  import logging.config
10
  LOGGING_CONFIG = {
@@ -229,14 +230,14 @@ class MagicMeController:
229
 
230
  def refresh_id_embed(self):
231
  id_embed_list = glob(os.path.join(self.id_embed_dir, "*.pt"))
232
- self.id_embed_list = [os.path.basename(p) for p in id_embed_list]
233
 
234
  def update_id_embed(self, id_embed_dropdown):
235
  self.selected_id_embed = id_embed_dropdown
236
  return gr.Dropdown.update()
237
 
238
 
239
- def run_once(self, prompt_text_box, negative_prompt_text_box, id_embed_dropdown):
240
  if self.selected_id_embed != id_embed_dropdown: self.update_id_embed(id_embed_dropdown)
241
 
242
  category = "woman" if self.selected_id_embed in self.woman_id_embed_list else "man"
@@ -304,8 +305,8 @@ class MagicMeController:
304
  width=512,
305
  height=512,
306
  batch_size=get_value_at_index(self.impactint_204, 0),
307
- seed=random.randint(1, 2**64),
308
- cov_factor=0.15,
309
  )
310
 
311
  bnk_injectnoise_253 = self.bnk_injectnoise.inject_noise(
@@ -316,7 +317,7 @@ class MagicMeController:
316
 
317
  ksampleradvanced_248 = self.ksampleradvanced.sample(
318
  add_noise="disable",
319
- noise_seed=random.randint(1, 2**64),
320
  steps=20,
321
  cfg=8,
322
  sampler_name="dpmpp_2m",
@@ -341,7 +342,7 @@ class MagicMeController:
341
  filename_prefix="orig",
342
  format="video/h264-mp4",
343
  pingpong=False,
344
- save_output=False,
345
  images=get_value_at_index(vaedecode_10, 0),
346
  unique_id=2001771405939721385,
347
  )
@@ -366,7 +367,7 @@ class MagicMeController:
366
  guide_size=512,
367
  guide_size_for=False,
368
  max_size=512,
369
- seed=random.randint(1, 2**64),
370
  steps=20,
371
  cfg=8,
372
  sampler_name="euler",
@@ -391,7 +392,7 @@ class MagicMeController:
391
  filename_prefix="face_detailer",
392
  format="video/h264-mp4",
393
  pingpong=False,
394
- save_output=False,
395
  images=get_value_at_index(segspaste_49, 0),
396
  unique_id=7104489750160636615,
397
  )
@@ -408,7 +409,7 @@ class MagicMeController:
408
 
409
  ultimatesdupscale_172 = self.ultimatesdupscale.upscale(
410
  upscale_by=2,
411
- seed=random.randint(1, 2**64),
412
  steps=20,
413
  cfg=8,
414
  sampler_name="euler",
@@ -450,14 +451,18 @@ class MagicMeController:
450
  )
451
 
452
 
453
- save_sample_path = sorted(glob(self.save_dir, 'SR*.mp4'))[-1]
 
 
454
 
455
  json_config = {
456
  "prompt": prompt,
457
  "n_prompt": negative_prompt_text_box,
458
  "id_embed_dropdown": id_embed_dropdown,
 
 
459
  }
460
- return gr.Video.update(value=save_sample_path), gr.Json.update(value=json_config)
461
 
462
 
463
 
@@ -556,23 +561,24 @@ def ui():
556
  prompt_textbox = gr.Textbox( label="Prompt", info="a photo of <V*> man/woman ", lines=3, value="in superman costume in the outer space, stars in the background" )
557
  negative_prompt_textbox = gr.Textbox( label="Negative Prompt", lines=3, value="(deformed iris, deformed pupils, semi-realistic, cgi, 3d, render, sketch, cartoon, drawing, anime), text, cropped, out of frame, worst quality, low quality, jpeg artifacts, ugly, duplicate, morbid, mutilated, extra fingers, mutated hands, poorly drawn hands, poorly drawn face, mutation, deformed, blurry, dehydrated, bad anatomy, bad proportions, extra limbs, cloned face, disfigured, gross proportions, malformed limbs, missing arms, missing legs, extra arms, extra legs, fused fingers, too many fingers, long neck, UnrealisticDream")
558
 
559
- # with gr.Accordion("Advance", open=False):
560
- # with gr.Row():
561
- # width_slider = gr.Slider( label="Width", value=512, minimum=256, maximum=1024, step=64 )
562
- # height_slider = gr.Slider( label="Height", value=512, minimum=256, maximum=1024, step=64 )
563
- # with gr.Row():
564
- # seed_textbox = gr.Textbox( label="Seed", value=-1)
565
- # seed_button = gr.Button(value="\U0001F3B2", elem_classes="toolbutton")
566
- # seed_button.click(fn=lambda: gr.Textbox.update(value=random.randint(1, 1e16)), inputs=[], outputs=[seed_textbox])
567
 
568
  generate_button = gr.Button( value="Generate", variant='primary' )
569
 
570
  with gr.Column():
571
- result_video = gr.Video( label="Generated Animation", interactive=False )
572
- json_config = gr.Json( label="Config", value=None )
 
 
573
 
574
- inputs = [prompt_textbox, negative_prompt_textbox, id_embed_dropdown]
575
- outputs = [result_video, json_config]
576
 
577
  generate_button.click( fn=c.run_once, inputs=inputs, outputs=outputs )
578
 
 
5
  import torch
6
  import gradio as gr
7
  from glob import glob
8
+ from pathlib import Path
9
 
10
  import logging.config
11
  LOGGING_CONFIG = {
 
230
 
231
  def refresh_id_embed(self):
232
  id_embed_list = glob(os.path.join(self.id_embed_dir, "*.pt"))
233
+ self.id_embed_list = [Path(p).stem for p in id_embed_list]
234
 
235
  def update_id_embed(self, id_embed_dropdown):
236
  self.selected_id_embed = id_embed_dropdown
237
  return gr.Dropdown.update()
238
 
239
 
240
+ def run_once(self, prompt_text_box, negative_prompt_text_box, id_embed_dropdown, gaussian_slider, seed_text_box):
241
  if self.selected_id_embed != id_embed_dropdown: self.update_id_embed(id_embed_dropdown)
242
 
243
  category = "woman" if self.selected_id_embed in self.woman_id_embed_list else "man"
 
305
  width=512,
306
  height=512,
307
  batch_size=get_value_at_index(self.impactint_204, 0),
308
+ seed=seed_text_box,
309
+ cov_factor=gaussian_slider,
310
  )
311
 
312
  bnk_injectnoise_253 = self.bnk_injectnoise.inject_noise(
 
317
 
318
  ksampleradvanced_248 = self.ksampleradvanced.sample(
319
  add_noise="disable",
320
+ noise_seed=seed_text_box,
321
  steps=20,
322
  cfg=8,
323
  sampler_name="dpmpp_2m",
 
342
  filename_prefix="orig",
343
  format="video/h264-mp4",
344
  pingpong=False,
345
+ save_output=True,
346
  images=get_value_at_index(vaedecode_10, 0),
347
  unique_id=2001771405939721385,
348
  )
 
367
  guide_size=512,
368
  guide_size_for=False,
369
  max_size=512,
370
+ seed=seed_text_box,
371
  steps=20,
372
  cfg=8,
373
  sampler_name="euler",
 
392
  filename_prefix="face_detailer",
393
  format="video/h264-mp4",
394
  pingpong=False,
395
+ save_output=True,
396
  images=get_value_at_index(segspaste_49, 0),
397
  unique_id=7104489750160636615,
398
  )
 
409
 
410
  ultimatesdupscale_172 = self.ultimatesdupscale.upscale(
411
  upscale_by=2,
412
+ seed=seed_text_box,
413
  steps=20,
414
  cfg=8,
415
  sampler_name="euler",
 
451
  )
452
 
453
 
454
+ orig_video_path = sorted(glob(os.path.join(self.save_dir, 'orig*.mp4')))[-1]
455
+ face_detailer_video_path = sorted(glob(os.path.join(self.save_dir, 'face_detailer*.mp4')))[-1]
456
+ sr_video_path = sorted(glob(os.path.join(self.save_dir, 'SR*.mp4')))[-1]
457
 
458
  json_config = {
459
  "prompt": prompt,
460
  "n_prompt": negative_prompt_text_box,
461
  "id_embed_dropdown": id_embed_dropdown,
462
+ "gaussian_slider": gaussian_slider,
463
+ "seed_text_box": seed_text_box
464
  }
465
+ return gr.Video.update(value=orig_video_path), gr.Video.update(value=face_detailer_video_path),gr.Video.update(value=sr_video_path), gr.Json.update(value=json_config)
466
 
467
 
468
 
 
561
  prompt_textbox = gr.Textbox( label="Prompt", info="a photo of <V*> man/woman ", lines=3, value="in superman costume in the outer space, stars in the background" )
562
  negative_prompt_textbox = gr.Textbox( label="Negative Prompt", lines=3, value="(deformed iris, deformed pupils, semi-realistic, cgi, 3d, render, sketch, cartoon, drawing, anime), text, cropped, out of frame, worst quality, low quality, jpeg artifacts, ugly, duplicate, morbid, mutilated, extra fingers, mutated hands, poorly drawn hands, poorly drawn face, mutation, deformed, blurry, dehydrated, bad anatomy, bad proportions, extra limbs, cloned face, disfigured, gross proportions, malformed limbs, missing arms, missing legs, extra arms, extra legs, fused fingers, too many fingers, long neck, UnrealisticDream")
563
 
564
+ with gr.Accordion("Advance", open=False):
565
+ with gr.Row():
566
+ gaussian_slider = gr.Slider( label="3D Gaussian Noise Covariance", value=0.2, minimum=0, maximum=1, step=0.05 )
567
+ with gr.Row():
568
+ seed_textbox = gr.Textbox( label="Seed", value=-1)
569
+ seed_button = gr.Button(value="\U0001F3B2", elem_classes="toolbutton")
570
+ seed_button.click(fn=lambda: gr.Textbox.update(value=random.randint(1, 1e16)), inputs=[], outputs=[seed_textbox])
 
571
 
572
  generate_button = gr.Button( value="Generate", variant='primary' )
573
 
574
  with gr.Column():
575
+ orig_video = gr.Video( label="Video after T2I VCD", interactive=False )
576
+ face_detailer_video = gr.Video( label="Video after Face VCD", interactive=False )
577
+ sr_video = gr.Video( label="Video after Tiled VCD", interactive=False )
578
+ json_config = gr.Json(label="Config", value=None )
579
 
580
+ inputs = [prompt_textbox, negative_prompt_textbox, id_embed_dropdown, gaussian_slider, seed_textbox]
581
+ outputs = [orig_video, face_detailer_video, sr_video, json_config]
582
 
583
  generate_button.click( fn=c.run_once, inputs=inputs, outputs=outputs )
584