Spaces:
Running
on
Zero
Running
on
Zero
Quality tags v1
Browse files
app.py
CHANGED
@@ -254,6 +254,16 @@ with open('characterfull.txt', 'r') as f:
|
|
254 |
def get_random_character():
|
255 |
return random.choice(characters)
|
256 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
257 |
if torch.cuda.is_available():
|
258 |
pipe = load_pipeline(MODEL)
|
259 |
logger.info("Loaded on Device!")
|
@@ -282,6 +292,9 @@ with gr.Blocks(css="style.css") as demo:
|
|
282 |
variant="primary",
|
283 |
scale=0
|
284 |
)
|
|
|
|
|
|
|
285 |
result = gr.Image(
|
286 |
label="Result",
|
287 |
show_label=False
|
@@ -293,7 +306,7 @@ with gr.Blocks(css="style.css") as demo:
|
|
293 |
placeholder="Enter a negative prompt",
|
294 |
value=""
|
295 |
)
|
296 |
-
|
297 |
label="Aspect Ratio",
|
298 |
choices=config.aspect_ratios,
|
299 |
value="1024 x 1024",
|
@@ -365,9 +378,6 @@ with gr.Blocks(css="style.css") as demo:
|
|
365 |
json_input = gr.TextArea(label="Edit/Paste JSON Parameters", placeholder="Paste or edit JSON parameters here")
|
366 |
generate_from_json = gr.Button("Generate from JSON")
|
367 |
|
368 |
-
with gr.Accordion("Randomize", open=False):
|
369 |
-
random_character_button = gr.Button("Random Character")
|
370 |
-
|
371 |
with gr.Accordion("Generation History", open=False) as history_accordion:
|
372 |
history_gallery = gr.Gallery(
|
373 |
label="History",
|
@@ -469,6 +479,12 @@ with gr.Blocks(css="style.css") as demo:
|
|
469 |
outputs=[prompt]
|
470 |
)
|
471 |
|
|
|
|
|
|
|
|
|
|
|
|
|
472 |
history_gallery.select(
|
473 |
fn=handle_image_click,
|
474 |
inputs=[],
|
|
|
254 |
def get_random_character():
|
255 |
return random.choice(characters)
|
256 |
|
257 |
+
# Function to add quality tags
|
258 |
+
def add_quality_tags(prompt, negative_prompt):
|
259 |
+
positive_tags = "score_9, score_8_up, score_7_up, score_6_up, dramatic lighting, "
|
260 |
+
negative_tags = "worst quality, low quality, text, censored, deformed, bad hand, blurry, (watermark), mutated hands, monochrome, "
|
261 |
+
|
262 |
+
updated_prompt = positive_tags + prompt
|
263 |
+
updated_negative_prompt = negative_tags + negative_prompt
|
264 |
+
|
265 |
+
return updated_prompt, updated_negative_prompt
|
266 |
+
|
267 |
if torch.cuda.is_available():
|
268 |
pipe = load_pipeline(MODEL)
|
269 |
logger.info("Loaded on Device!")
|
|
|
292 |
variant="primary",
|
293 |
scale=0
|
294 |
)
|
295 |
+
with gr.Row():
|
296 |
+
random_character_button = gr.Button("Random Character")
|
297 |
+
add_quality_tags_button = gr.Button("Add quality tags")
|
298 |
result = gr.Image(
|
299 |
label="Result",
|
300 |
show_label=False
|
|
|
306 |
placeholder="Enter a negative prompt",
|
307 |
value=""
|
308 |
)
|
309 |
+
aspect_ratio_selector = gr.Radio(
|
310 |
label="Aspect Ratio",
|
311 |
choices=config.aspect_ratios,
|
312 |
value="1024 x 1024",
|
|
|
378 |
json_input = gr.TextArea(label="Edit/Paste JSON Parameters", placeholder="Paste or edit JSON parameters here")
|
379 |
generate_from_json = gr.Button("Generate from JSON")
|
380 |
|
|
|
|
|
|
|
381 |
with gr.Accordion("Generation History", open=False) as history_accordion:
|
382 |
history_gallery = gr.Gallery(
|
383 |
label="History",
|
|
|
479 |
outputs=[prompt]
|
480 |
)
|
481 |
|
482 |
+
add_quality_tags_button.click(
|
483 |
+
fn=add_quality_tags,
|
484 |
+
inputs=[prompt, negative_prompt],
|
485 |
+
outputs=[prompt, negative_prompt]
|
486 |
+
)
|
487 |
+
|
488 |
history_gallery.select(
|
489 |
fn=handle_image_click,
|
490 |
inputs=[],
|