benjamin-paine commited on
Commit
fecc0e6
·
verified ·
1 Parent(s): 1fb83ef

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +39 -1
app.py CHANGED
@@ -63,6 +63,9 @@ def infer(
63
  system_prompt=default_system_prompt,
64
  cfg_normalization=True,
65
  cfg_trunc_ratio=1.0,
 
 
 
66
  progress=gr.Progress(track_tqdm=True),
67
  ):
68
  if randomize_seed:
@@ -70,6 +73,11 @@ def infer(
70
 
71
  generator = torch.Generator().manual_seed(seed)
72
 
 
 
 
 
 
73
  image = pipe(
74
  prompt=prompt,
75
  negative_prompt=negative_prompt,
@@ -79,8 +87,9 @@ def infer(
79
  height=height,
80
  generator=generator,
81
  system_prompt=system_prompt,
 
82
  cfg_normalization=cfg_normalization,
83
- cfg_trunc_ratio=cfg_trunc_ratio
84
  ).images[0]
85
 
86
  return image, seed
@@ -104,6 +113,7 @@ with gr.Blocks(css=css) as demo:
104
  prompt = gr.Text(
105
  label="Prompt",
106
  show_label=False,
 
107
  max_lines=4,
108
  placeholder="Enter your prompt",
109
  container=False,
@@ -117,12 +127,14 @@ with gr.Blocks(css=css) as demo:
117
  with gr.Row():
118
  system_prompt = gr.Text(
119
  label="System Prompt",
 
120
  max_lines=4,
121
  value=default_system_prompt
122
  )
123
 
124
  negative_prompt = gr.Text(
125
  label="Negative prompt",
 
126
  max_lines=4,
127
  placeholder="Enter a negative prompt",
128
  )
@@ -172,6 +184,14 @@ with gr.Blocks(css=css) as demo:
172
  value=30,
173
  )
174
 
 
 
 
 
 
 
 
 
175
  with gr.Row():
176
  cfg_normalization = gr.Checkbox(
177
  label="CFG Normalization",
@@ -185,6 +205,21 @@ with gr.Blocks(css=css) as demo:
185
  value=1.0
186
  )
187
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
188
  gr.Examples(examples=examples, inputs=[prompt], outputs=[result, seed], fn=infer, cache_examples=True, cache_mode="lazy")
189
 
190
  gr.on(
@@ -202,6 +237,9 @@ with gr.Blocks(css=css) as demo:
202
  system_prompt,
203
  cfg_normalization,
204
  cfg_trunc_ratio,
 
 
 
205
  ],
206
  outputs=[result, seed],
207
  )
 
63
  system_prompt=default_system_prompt,
64
  cfg_normalization=True,
65
  cfg_trunc_ratio=1.0,
66
+ max_sequence_length=256,
67
+ dynamic_shifting=True,
68
+ sigmas="Default",
69
  progress=gr.Progress(track_tqdm=True),
70
  ):
71
  if randomize_seed:
 
73
 
74
  generator = torch.Generator().manual_seed(seed)
75
 
76
+ pipe.scheduler.config.use_dynamic_shifting = dynamic_shifting
77
+ pipe.scheduler.config.use_karras_sigmas = sigmas == "Karras"
78
+ pipe.scheduler.config.use_exponential_sigmas = sigmas == "Exponential"
79
+ pipe.scheduler.config.use_beta_sigmas = sigmas == "Beta"
80
+
81
  image = pipe(
82
  prompt=prompt,
83
  negative_prompt=negative_prompt,
 
87
  height=height,
88
  generator=generator,
89
  system_prompt=system_prompt,
90
+ max_sequence_length=max_sequence_length,
91
  cfg_normalization=cfg_normalization,
92
+ cfg_trunc_ratio=cfg_trunc_ratio,
93
  ).images[0]
94
 
95
  return image, seed
 
113
  prompt = gr.Text(
114
  label="Prompt",
115
  show_label=False,
116
+ lines=2,
117
  max_lines=4,
118
  placeholder="Enter your prompt",
119
  container=False,
 
127
  with gr.Row():
128
  system_prompt = gr.Text(
129
  label="System Prompt",
130
+ lines=2,
131
  max_lines=4,
132
  value=default_system_prompt
133
  )
134
 
135
  negative_prompt = gr.Text(
136
  label="Negative prompt",
137
+ lines=2,
138
  max_lines=4,
139
  placeholder="Enter a negative prompt",
140
  )
 
184
  value=30,
185
  )
186
 
187
+ max_sequence_length = gr.Slider(
188
+ label="Max Sequence Length",
189
+ minimum=16,
190
+ maximum=512,
191
+ value=256,
192
+ step=8
193
+ )
194
+
195
  with gr.Row():
196
  cfg_normalization = gr.Checkbox(
197
  label="CFG Normalization",
 
205
  value=1.0
206
  )
207
 
208
+ with gr.Row():
209
+ dynamic_shifting = gr.Checkbox(
210
+ label="Use Dynamic Shifting",
211
+ value=True
212
+ )
213
+ sigmas = gr.Dropdown(
214
+ choices=[
215
+ "Default",
216
+ "Karras",
217
+ "Exponential",
218
+ "Beta"
219
+ ],
220
+ value="Default"
221
+ )
222
+
223
  gr.Examples(examples=examples, inputs=[prompt], outputs=[result, seed], fn=infer, cache_examples=True, cache_mode="lazy")
224
 
225
  gr.on(
 
237
  system_prompt,
238
  cfg_normalization,
239
  cfg_trunc_ratio,
240
+ max_sequence_length,
241
+ dynamic_shifting,
242
+ sigmas
243
  ],
244
  outputs=[result, seed],
245
  )