p1atdev commited on
Commit
9ae73d2
Β·
1 Parent(s): c490b57

chore: update ui

Browse files
Files changed (1) hide show
  1. app.py +29 -14
app.py CHANGED
@@ -40,6 +40,7 @@ def infer(
40
  guidance_scale: float,
41
  num_inference_steps: int,
42
  tkg_channels: list[int] = [0, 1, 1, 0],
 
43
  progress=gr.Progress(track_tqdm=True),
44
  ):
45
  if randomize_seed:
@@ -60,7 +61,7 @@ def infer(
60
  )
61
  tkg_latents = apply_tkg_noise(
62
  latents,
63
- shift=0.11,
64
  delta_shift=0.1,
65
  std_dev=0.5,
66
  factor=8,
@@ -69,8 +70,8 @@ def infer(
69
 
70
  latents = torch.cat(
71
  [
72
- latents,
73
  tkg_latents,
 
74
  ],
75
  dim=0,
76
  )
@@ -107,6 +108,7 @@ def on_generate(
107
  guidance_scale: float,
108
  num_inference_steps: int,
109
  color_name: str,
 
110
  *args,
111
  **kwargs
112
  ):
@@ -123,6 +125,7 @@ def on_generate(
123
  guidance_scale,
124
  num_inference_steps,
125
  tkg_channels=tkg_channels,
 
126
  *args,
127
  **kwargs,
128
  )
@@ -131,7 +134,7 @@ def on_generate(
131
 
132
  examples = [
133
  # "1girl, arima kana, oshi no ko, hoshimachi suisei, hoshimachi suisei \(1st costume\), cosplay, looking at viewer, smile, outdoors, night, v, masterpiece, high score, great score, absurdres",
134
- "1girl, solo, upper body, looking at viewer, straight-on, masterpiece, best quality",
135
  ]
136
 
137
 
@@ -149,26 +152,36 @@ TKG-DMπŸ₯šπŸš: Training-free Chroma Key Content Generation Diffusion Model
149
 
150
  with gr.Row():
151
  with gr.Column():
152
- prompt = gr.Text(
153
  label="Prompt",
154
  max_lines=4,
155
  placeholder="Enter your prompt",
156
  )
157
- negative_prompt = gr.Textbox(
158
- label="Negative prompt",
159
- max_lines=4,
160
- placeholder="Enter a negative prompt",
161
- value="lowres, bad anatomy, bad hands, text, error, missing finger, extra digits, fewer digits, cropped, worst quality, low quality, low score, bad score, average score, signature, watermark, username, blurry",
162
- )
163
-
164
  color_set = gr.Dropdown(
165
- label="Chroma key color",
166
  choices=list(COLOR_SET_MAP.keys()),
167
  value="green",
168
  )
169
 
 
 
 
 
 
 
 
 
 
170
 
171
  with gr.Accordion("Advanced Settings", open=False):
 
 
 
 
 
 
 
172
  seed = gr.Slider(
173
  label="Seed",
174
  minimum=0,
@@ -215,8 +228,9 @@ TKG-DMπŸ₯šπŸš: Training-free Chroma Key Content Generation Diffusion Model
215
 
216
  with gr.Column():
217
  run_button = gr.Button("Generate", variant="primary")
218
- result_w_tkg = gr.Image(label="with TKG")
219
- result_wo_tkg = gr.Image(label="without TKG")
 
220
 
221
 
222
 
@@ -235,6 +249,7 @@ TKG-DMπŸ₯šπŸš: Training-free Chroma Key Content Generation Diffusion Model
235
  guidance_scale,
236
  num_inference_steps,
237
  color_set,
 
238
  ],
239
  outputs=[result_w_tkg, result_wo_tkg, seed],
240
  )
 
40
  guidance_scale: float,
41
  num_inference_steps: int,
42
  tkg_channels: list[int] = [0, 1, 1, 0],
43
+ chroma_key_shift: float = 0.11,
44
  progress=gr.Progress(track_tqdm=True),
45
  ):
46
  if randomize_seed:
 
61
  )
62
  tkg_latents = apply_tkg_noise(
63
  latents,
64
+ shift=chroma_key_shift,
65
  delta_shift=0.1,
66
  std_dev=0.5,
67
  factor=8,
 
70
 
71
  latents = torch.cat(
72
  [
 
73
  tkg_latents,
74
+ latents,
75
  ],
76
  dim=0,
77
  )
 
108
  guidance_scale: float,
109
  num_inference_steps: int,
110
  color_name: str,
111
+ chroma_key_shift: float,
112
  *args,
113
  **kwargs
114
  ):
 
125
  guidance_scale,
126
  num_inference_steps,
127
  tkg_channels=tkg_channels,
128
+ chroma_key_shift=chroma_key_shift,
129
  *args,
130
  **kwargs,
131
  )
 
134
 
135
  examples = [
136
  # "1girl, arima kana, oshi no ko, hoshimachi suisei, hoshimachi suisei \(1st costume\), cosplay, looking at viewer, smile, outdoors, night, v, masterpiece, high score, great score, absurdres",
137
+ "1girl, solo, school uniform, cat ears, full body, looking at viewer, straight-on, chibi, masterpiece, best quality",
138
  ]
139
 
140
 
 
152
 
153
  with gr.Row():
154
  with gr.Column():
155
+ prompt = gr.Textbox(
156
  label="Prompt",
157
  max_lines=4,
158
  placeholder="Enter your prompt",
159
  )
160
+
 
 
 
 
 
 
161
  color_set = gr.Dropdown(
162
+ label="Background color",
163
  choices=list(COLOR_SET_MAP.keys()),
164
  value="green",
165
  )
166
 
167
+ with gr.Accordion("TKG Settings", open=False):
168
+ chroma_key_shift = gr.Slider(
169
+ label="Latent mean shift for chroma key",
170
+ minimum=0.0,
171
+ maximum=1.0,
172
+ step=0.05,
173
+ value=0.11,
174
+ )
175
+
176
 
177
  with gr.Accordion("Advanced Settings", open=False):
178
+ negative_prompt = gr.Textbox(
179
+ label="Negative prompt",
180
+ max_lines=4,
181
+ placeholder="Enter a negative prompt",
182
+ value="lowres, bad anatomy, bad hands, text, error, missing finger, extra digits, fewer digits, cropped, worst quality, low quality, low score, bad score, average score, signature, watermark, username, blurry",
183
+ )
184
+
185
  seed = gr.Slider(
186
  label="Seed",
187
  minimum=0,
 
228
 
229
  with gr.Column():
230
  run_button = gr.Button("Generate", variant="primary")
231
+ with gr.Row():
232
+ result_w_tkg = gr.Image(label="with TKG")
233
+ result_wo_tkg = gr.Image(label="without TKG")
234
 
235
 
236
 
 
249
  guidance_scale,
250
  num_inference_steps,
251
  color_set,
252
+ chroma_key_shift,
253
  ],
254
  outputs=[result_w_tkg, result_wo_tkg, seed],
255
  )