Vvaann commited on
Commit
2e1abcc
·
verified ·
1 Parent(s): d009a69

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +11 -18
app.py CHANGED
@@ -101,7 +101,7 @@ def generate_with_embs(text_embeddings, text_input, seed,num_inference_steps,gui
101
  height = 512 # default height of Stable Diffusion
102
  width = 512 # default width of Stable Diffusion
103
  num_inference_steps = num_inference_steps # 10 # Number of denoising steps
104
- guidance_scale = guidance_scale # 7.5 # Scale for classifier-free guidance
105
  generator = torch.manual_seed(seed) # Seed generator to create the inital latent noise
106
  batch_size = 1
107
 
@@ -376,7 +376,7 @@ def blue_loss_variant(images, use_mean=False, alpha=1.0):
376
 
377
  return loss
378
 
379
- def generate_with_prompt_style_guidance(prompt, style, seed,num_inference_steps,guidance_scale,loss_function):
380
 
381
  prompt = prompt + ' in style of s'
382
 
@@ -385,7 +385,7 @@ def generate_with_prompt_style_guidance(prompt, style, seed,num_inference_steps,
385
  height = 512 # default height of Stable Diffusion
386
  width = 512 # default width of Stable Diffusion
387
  num_inference_steps = num_inference_steps # # Number of denoising steps
388
- guidance_scale = guidance_scale # # Scale for classifier-free guidance
389
  generator = torch.manual_seed(seed) # Seed generator to create the inital latent noise
390
  batch_size = 1
391
 
@@ -521,37 +521,30 @@ def inference(prompt, seed, style,num_inference_steps,guidance_scale,loss_functi
521
  else:
522
  return None
523
 
524
- title = "Stable Diffusion and Textual Inversion"
525
- description = "Gradio interface to apply style to Stable Diffusion outputs"
526
- examples = [["Pink Ferrari Car", 24041975,"Manga"], ["A man sipping tea wearing a spacesuit on the moon",24041975, "GTA-5"]] # Added valid styles
527
 
528
  demo = gr.Interface(inference,
529
- inputs = [gr.Textbox(label='Prompt', value='Pink Ferrari Car'), gr.Textbox(label='Seed', value=24041975),
530
  gr.Dropdown(['Dr Strange', 'GTA-5', 'Manga', 'Pokemon','Illustration','Matrix','Oil Painting'], label='Style', value='Dr Strange'),
531
  gr.Slider(
532
  minimum=5,
533
  maximum=20,
534
  value=10,
535
  step=5,
536
- label="Select Number of Steps",
537
  interactive=True,
538
  ),
539
- gr.Slider(
540
- minimum=0,
541
- maximum=10,
542
- value=8,
543
- step=8,
544
- label="Select Guidance Scale",
545
- interactive=True,
546
- ),gr.Radio(["contrast", "blue_original", "blue_modified","ymca","cmyk"], label="loss-function", info="loss-function" , value="ymca"),
547
  ],
548
  outputs = [
549
  gr.Image(label="Stable Diffusion Output"),
550
  ],
551
  title = title,
552
  description = description,
553
- # examples = examples,
554
- # cache_examples=True
555
  )
556
  demo.launch()
557
 
 
101
  height = 512 # default height of Stable Diffusion
102
  width = 512 # default width of Stable Diffusion
103
  num_inference_steps = num_inference_steps # 10 # Number of denoising steps
104
+ guidance_scale = 7.5 # Scale for classifier-free guidance
105
  generator = torch.manual_seed(seed) # Seed generator to create the inital latent noise
106
  batch_size = 1
107
 
 
376
 
377
  return loss
378
 
379
+ def generate_with_prompt_style_guidance(prompt, style, seed,num_inference_steps,loss_function):
380
 
381
  prompt = prompt + ' in style of s'
382
 
 
385
  height = 512 # default height of Stable Diffusion
386
  width = 512 # default width of Stable Diffusion
387
  num_inference_steps = num_inference_steps # # Number of denoising steps
388
+ # guidance_scale = guidance_scale # # Scale for classifier-free guidance
389
  generator = torch.manual_seed(seed) # Seed generator to create the inital latent noise
390
  batch_size = 1
391
 
 
521
  else:
522
  return None
523
 
524
+ title = "Stable Diffusion with text input"
525
+ description = "Apply various stable diffusion styles with text prompt as input"
526
+ examples = [["a hyper-realistic high definition render of bear sitting on a red rug, 4k", 24041975,"Manga"], ["A man dancing on bhutan costume",24041975, "GTA-5"]] # Added valid styles
527
 
528
  demo = gr.Interface(inference,
529
+ inputs = [gr.Textbox(label='Prompt', value='A man dancing on bhutan costume'), gr.Textbox(label='Seed', value=24041975),
530
  gr.Dropdown(['Dr Strange', 'GTA-5', 'Manga', 'Pokemon','Illustration','Matrix','Oil Painting'], label='Style', value='Dr Strange'),
531
  gr.Slider(
532
  minimum=5,
533
  maximum=20,
534
  value=10,
535
  step=5,
536
+ label="Number of Steps",
537
  interactive=True,
538
  ),
539
+ gr.Radio(["contrast", "blue_original", "blue_modified","ymca","cmyk"], label="loss-function", info="loss-function" , value="ymca"),
 
 
 
 
 
 
 
540
  ],
541
  outputs = [
542
  gr.Image(label="Stable Diffusion Output"),
543
  ],
544
  title = title,
545
  description = description,
546
+ examples = examples,
547
+ cache_examples=True
548
  )
549
  demo.launch()
550