panelforge commited on
Commit
e2501d8
·
verified ·
1 Parent(s): ec1b822

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +11 -5
app.py CHANGED
@@ -21,13 +21,15 @@ MAX_SEED = np.iinfo(np.int32).max
21
  MAX_IMAGE_SIZE = 1024
22
 
23
  @spaces.GPU # [uncomment to use ZeroGPU]
24
- def infer(prompt, negative_prompt, seed, randomize_seed, width, height, guidance_scale, num_inference_steps, tag_selection_1, tag_selection_2, use_tags, progress=gr.Progress(track_tqdm=True)):
25
 
26
  # Determine final prompt
27
  if use_tags:
28
  selected_tags_1 = [tag_options_1[tag] for tag in tag_selection_1 if tag in tag_options_1]
29
  selected_tags_2 = [tag_options_2[tag] for tag in tag_selection_2 if tag in tag_options_2]
30
- tags_text = ', '.join(selected_tags_1 + selected_tags_2)
 
 
31
  final_prompt = f'score_9, score_8_up, score_7_up, source_anime, {tags_text}'
32
  else:
33
  final_prompt = f'score_9, score_8_up, score_7_up, source_anime, {prompt}'
@@ -103,6 +105,10 @@ with gr.Blocks(css=css) as demo:
103
  tag_selection_1 = gr.CheckboxGroup(choices=list(tag_options_1.keys()), label="Select Tags (Style)")
104
  with gr.Column():
105
  tag_selection_2 = gr.CheckboxGroup(choices=list(tag_options_2.keys()), label="Select Tags (Theme)")
 
 
 
 
106
  use_tags = gr.State(True)
107
 
108
  # Full-width "Run" button
@@ -165,15 +171,15 @@ with gr.Blocks(css=css) as demo:
165
  # inputs=[prompt]
166
  # )
167
 
168
- def check_tab(prompt, tag_selection_1, tag_selection_2, selected_tab):
169
  return selected_tab == "Tag Selection"
170
 
171
- tabs.change(check_tab, inputs=[prompt, tag_selection_1, tag_selection_2, tabs], outputs=use_tags)
172
 
173
  gr.on(
174
  triggers=[run_button.click, prompt.submit],
175
  fn=infer,
176
- inputs=[prompt, negative_prompt, seed, randomize_seed, width, height, guidance_scale, num_inference_steps, tag_selection_1, tag_selection_2, use_tags],
177
  outputs=[result, seed, prompt_info] # Include prompt_info in the outputs
178
  )
179
 
 
21
  MAX_IMAGE_SIZE = 1024
22
 
23
  @spaces.GPU # [uncomment to use ZeroGPU]
24
+ def infer(prompt, negative_prompt, seed, randomize_seed, width, height, guidance_scale, num_inference_steps, tag_selection_1, tag_selection_2, tag_selection_3, tag_selection_4, use_tags, progress=gr.Progress(track_tqdm=True)):
25
 
26
  # Determine final prompt
27
  if use_tags:
28
  selected_tags_1 = [tag_options_1[tag] for tag in tag_selection_1 if tag in tag_options_1]
29
  selected_tags_2 = [tag_options_2[tag] for tag in tag_selection_2 if tag in tag_options_2]
30
+ selected_tags_3 = [tag_options_3[tag] for tag in tag_selection_3 if tag in tag_options_3]
31
+ selected_tags_4 = [tag_options_4[tag] for tag in tag_selection_4 if tag in tag_options_4]
32
+ tags_text = ', '.join(selected_tags_1 + selected_tags_2 + selected_tags_3 + selected_tags_4)
33
  final_prompt = f'score_9, score_8_up, score_7_up, source_anime, {tags_text}'
34
  else:
35
  final_prompt = f'score_9, score_8_up, score_7_up, source_anime, {prompt}'
 
105
  tag_selection_1 = gr.CheckboxGroup(choices=list(tag_options_1.keys()), label="Select Tags (Style)")
106
  with gr.Column():
107
  tag_selection_2 = gr.CheckboxGroup(choices=list(tag_options_2.keys()), label="Select Tags (Theme)")
108
+ with gr.Column():
109
+ tag_selection_3 = gr.CheckboxGroup(choices=list(tag_options_3.keys()), label="Select Tags (Theme)")
110
+ with gr.Column():
111
+ tag_selection_4 = gr.CheckboxGroup(choices=list(tag_options_4.keys()), label="Select Tags (Theme)")
112
  use_tags = gr.State(True)
113
 
114
  # Full-width "Run" button
 
171
  # inputs=[prompt]
172
  # )
173
 
174
+ def check_tab(prompt, tag_selection_1, tag_selection_2, tag_selection_3, tag_selection_4, selected_tab):
175
  return selected_tab == "Tag Selection"
176
 
177
+ tabs.change(check_tab, inputs=[prompt, tag_selection_1, tag_selection_2, tag_selection_3, tag_selection_4, tabs], outputs=use_tags)
178
 
179
  gr.on(
180
  triggers=[run_button.click, prompt.submit],
181
  fn=infer,
182
+ inputs=[prompt, negative_prompt, seed, randomize_seed, width, height, guidance_scale, num_inference_steps, tag_selection_1, tag_selection_2, tag_selection_3, tag_selection_4, use_tags],
183
  outputs=[result, seed, prompt_info] # Include prompt_info in the outputs
184
  )
185