PseudoTerminal X commited on
Commit
e31a916
1 Parent(s): ecbb9e3

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -8
app.py CHANGED
@@ -27,7 +27,7 @@ def extract_resolution(resolution_str):
27
 
28
  # Define the image generation function with adjustable parameters and a progress bar
29
  @spaces.GPU
30
- def generate(prompt, guidance_scale, num_inference_steps, resolution, negative_prompt):
31
  width, height = extract_resolution(resolution) or (1024, 1024)
32
  mixture_generator = torch.Generator().manual_seed(444)
33
  stage1_strength = 0.6
@@ -37,7 +37,7 @@ def generate(prompt, guidance_scale, num_inference_steps, resolution, negative_p
37
  num_inference_steps=num_inference_steps,
38
  num_images_per_prompt=1,
39
  generator=mixture_generator,
40
- guidance_scale=guidance_scale,
41
  output_type="latent",
42
  denoising_end=stage1_strength,
43
  width=width,
@@ -50,15 +50,16 @@ def generate(prompt, guidance_scale, num_inference_steps, resolution, negative_p
50
  num_inference_steps=num_inference_steps,
51
  num_images_per_prompt=1,
52
  generator=mixture_generator,
53
- guidance_scale=guidance_scale,
54
  denoising_start=stage1_strength
55
  ).images
56
 
57
  # Example prompts to demonstrate the model's capabilities
58
  example_prompts = [
59
- ["A futuristic cityscape at night under a starry sky", 7.5, 25, "blurry, overexposed"],
60
- ["A serene landscape with a flowing river and autumn trees", 8.0, 20, "crowded, noisy"],
61
- ["An abstract painting of joy and energy in bright colors", 9.0, 30, "dark, dull"]
 
62
  ]
63
 
64
  # Create a Gradio interface, 1024x1024,1152x960,896x1152
@@ -66,8 +67,9 @@ iface = gr.Interface(
66
  fn=generate,
67
  inputs=[
68
  gr.Text(label="Enter your prompt"),
69
- gr.Slider(1, 20, step=0.1, label="Guidance Scale", value=3.4),
70
- gr.Slider(1, 50, step=1, label="Number of Inference Steps", value=28),
 
71
  gr.Radio(["1024x1024", "1152x960", "896x1152"], label="Resolution", value="1152x960"),
72
  gr.Text(value="underexposed, blurry, ugly, washed-out", label="Negative Prompt")
73
  ],
 
27
 
28
  # Define the image generation function with adjustable parameters and a progress bar
29
  @spaces.GPU
30
+ def generate(prompt, stage1_guidance_scale, stage2_guidance_scale, num_inference_steps, resolution, negative_prompt):
31
  width, height = extract_resolution(resolution) or (1024, 1024)
32
  mixture_generator = torch.Generator().manual_seed(444)
33
  stage1_strength = 0.6
 
37
  num_inference_steps=num_inference_steps,
38
  num_images_per_prompt=1,
39
  generator=mixture_generator,
40
+ guidance_scale=stage1_guidance_scale,
41
  output_type="latent",
42
  denoising_end=stage1_strength,
43
  width=width,
 
50
  num_inference_steps=num_inference_steps,
51
  num_images_per_prompt=1,
52
  generator=mixture_generator,
53
+ guidance_scale=stage2_guidance_scale,
54
  denoising_start=stage1_strength
55
  ).images
56
 
57
  # Example prompts to demonstrate the model's capabilities
58
  example_prompts = [
59
+ ["A futuristic cityscape at night under a starry sky", 3.5, 4.5, 25, "blurry, overexposed"],
60
+ ["A serene landscape with a flowing river and autumn trees", 3.0, 4.0, 20, "crowded, noisy"],
61
+ ["An abstract painting of joy and energy in bright colors", 3.0, 4.5, 30, "dark, dull"],
62
+ ["a stunning portrait of a hamster with an eye patch, piloting a miniature cessna on a wooden desk in an office, depth of field, bokeh, sharp, f1.4", 3.2, 4.6, 40, "this is an ugly photograph that no one liked"]
63
  ]
64
 
65
  # Create a Gradio interface, 1024x1024,1152x960,896x1152
 
67
  fn=generate,
68
  inputs=[
69
  gr.Text(label="Enter your prompt"),
70
+ gr.Slider(1, 20, step=0.1, label="Guidance Scale (Stage I)", value=3.4),
71
+ gr.Slider(1, 20, step=0.1, label="Guidance Scale (Stage II)", value=4.2),
72
+ gr.Slider(1, 50, step=1, label="Number of Inference Steps", value=35),
73
  gr.Radio(["1024x1024", "1152x960", "896x1152"], label="Resolution", value="1152x960"),
74
  gr.Text(value="underexposed, blurry, ugly, washed-out", label="Negative Prompt")
75
  ],