Krebzonide commited on
Commit
b47c647
·
1 Parent(s): 98b5af6

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +3 -15
app.py CHANGED
@@ -35,7 +35,7 @@ css = """
35
  }
36
  """
37
 
38
- def generate(prompt, samp_steps, batch_size, seed, height, width, progress=gr.Progress(track_tqdm=True)):
39
  prompt = prompt.lower()
40
  if nsfw_filter:
41
  if prompt[:10] == "krebzonide":
@@ -52,8 +52,6 @@ def generate(prompt, samp_steps, batch_size, seed, height, width, progress=gr.Pr
52
  num_inference_steps=samp_steps,
53
  num_images_per_prompt=batch_size,
54
  guidance_scale=0.0,
55
- height=height,
56
- width=width,
57
  generator=torch.manual_seed(seed),
58
  ).images
59
  return gr.update(value = [(img, f"Image {i+1}") for i, img in enumerate(images)], height=height+90), seed
@@ -71,9 +69,6 @@ def set_base_model(base_model_id):
71
  pipe.to("cuda")
72
  return pipe
73
 
74
- def update_pixel_ratio(num1, num2):
75
- return [round((num1-(num1%8))*num2/1048576,3), num1-(num1%8)]
76
-
77
  examples = [
78
  ['A group of 4 students from University of Wisconsin Stout sitting at a table talking, men and women, detailed faces, focused',
79
  'glitch, deformed, cross-eyed'],
@@ -98,21 +93,14 @@ with gr.Blocks(css=css) as demo:
98
  prompt = gr.Textbox(label="Prompt")
99
  submit_btn = gr.Button("Generate", elem_classes="btn-green")
100
  with gr.Row():
101
- samp_steps = gr.Slider(1, 30, value=20, step=1, label="Sampling steps")
102
  batch_size = gr.Slider(1, 6, value=1, step=1, label="Batch size", interactive=True)
103
- with gr.Row():
104
- height = gr.Slider(label="Height", value=1024, minimum=8, maximum=1536, step=8)
105
- width = gr.Slider(label="Width", value=1024, minimum=8, maximum=1024, step=8)
106
- with gr.Row():
107
- pixels = gr.Number(label="Pixel Ratio", value=1, interactive=False)
108
  seed = gr.Number(label="Seed", value=-1, minimum=-1, precision=0)
109
  gallery = gr.Gallery(show_label=False, preview=True, container=False)
110
  with gr.Row():
111
  lastSeed = gr.Number(label="Last Seed", value=-1, interactive=False)
112
  ex = gr.Examples(examples=examples, inputs=[prompt, negative_prompt])
113
  submit_btn.click(generate, [prompt, samp_steps, batch_size, seed, height, width], [gallery, lastSeed], queue=True)
114
- height.release(update_pixel_ratio, [height, width], [pixels, height], queue=False)
115
- width.release(update_pixel_ratio, [width, height], [pixels, width], queue=False)
116
-
117
  pipe = set_base_model(model_id)
118
  demo.launch(debug=True)
 
35
  }
36
  """
37
 
38
+ def generate(prompt, samp_steps, batch_size, seed, progress=gr.Progress(track_tqdm=True)):
39
  prompt = prompt.lower()
40
  if nsfw_filter:
41
  if prompt[:10] == "krebzonide":
 
52
  num_inference_steps=samp_steps,
53
  num_images_per_prompt=batch_size,
54
  guidance_scale=0.0,
 
 
55
  generator=torch.manual_seed(seed),
56
  ).images
57
  return gr.update(value = [(img, f"Image {i+1}") for i, img in enumerate(images)], height=height+90), seed
 
69
  pipe.to("cuda")
70
  return pipe
71
 
 
 
 
72
  examples = [
73
  ['A group of 4 students from University of Wisconsin Stout sitting at a table talking, men and women, detailed faces, focused',
74
  'glitch, deformed, cross-eyed'],
 
93
  prompt = gr.Textbox(label="Prompt")
94
  submit_btn = gr.Button("Generate", elem_classes="btn-green")
95
  with gr.Row():
96
+ samp_steps = gr.Slider(1, 30, value=10, step=1, label="Sampling steps")
97
  batch_size = gr.Slider(1, 6, value=1, step=1, label="Batch size", interactive=True)
 
 
 
 
 
98
  seed = gr.Number(label="Seed", value=-1, minimum=-1, precision=0)
99
  gallery = gr.Gallery(show_label=False, preview=True, container=False)
100
  with gr.Row():
101
  lastSeed = gr.Number(label="Last Seed", value=-1, interactive=False)
102
  ex = gr.Examples(examples=examples, inputs=[prompt, negative_prompt])
103
  submit_btn.click(generate, [prompt, samp_steps, batch_size, seed, height, width], [gallery, lastSeed], queue=True)
104
+
 
 
105
  pipe = set_base_model(model_id)
106
  demo.launch(debug=True)