Update app.py
Browse files
app.py
CHANGED
@@ -511,37 +511,7 @@ pipe = StableDiffusionXLPipeline.from_pretrained(
|
|
511 |
variant="fp16"
|
512 |
).to(device)
|
513 |
|
514 |
-
|
515 |
-
# ํ๊ธ ์
๋ ฅ ๊ฐ์ง ๋ฐ ๋ฒ์ญ
|
516 |
-
if any('\uac00' <= char <= '\ud7a3' for char in prompt):
|
517 |
-
translated = translator(prompt, max_length=512)
|
518 |
-
prompt = translated[0]['translation_text']
|
519 |
-
|
520 |
-
# Hi-res์ 3840x2160 ์คํ์ผ ์ ์ฉ
|
521 |
-
prompt = f"hyper-realistic 8K image of {prompt}. ultra-detailed, lifelike, high-resolution, sharp, vibrant colors, photorealistic"
|
522 |
-
|
523 |
-
# ๊ณ ์ ๋ ์ค์ ๊ฐ
|
524 |
-
negative_prompt = "cartoonish, low resolution, blurry, simplistic, abstract, deformed, ugly, (deformed, distorted, disfigured:1.3), poorly drawn, bad anatomy, wrong anatomy, extra limb, missing limb, floating limbs, (mutated hands and fingers:1.4), disconnected limbs, mutation, mutated, disgusting, amputation"
|
525 |
-
width = 1024
|
526 |
-
height = 1024
|
527 |
-
guidance_scale = 6
|
528 |
-
num_inference_steps = 100
|
529 |
-
seed = random.randint(0, 2**32 - 1)
|
530 |
-
generator = torch.Generator().manual_seed(seed)
|
531 |
-
|
532 |
-
image = pipe(
|
533 |
-
prompt=prompt,
|
534 |
-
negative_prompt=negative_prompt,
|
535 |
-
width=width,
|
536 |
-
height=height,
|
537 |
-
guidance_scale=guidance_scale,
|
538 |
-
num_inference_steps=num_inference_steps,
|
539 |
-
generator=generator,
|
540 |
-
).images[0]
|
541 |
-
|
542 |
-
unique_name = str(uuid.uuid4()) + ".png"
|
543 |
-
image.save(unique_name)
|
544 |
-
return unique_name
|
545 |
|
546 |
def generate_images(blog_post):
|
547 |
images = []
|
@@ -580,6 +550,10 @@ def generate_images(blog_post):
|
|
580 |
value_summary = f"Image symbolizing the value and benefit for readers: {conclusion_text[:100]}..."
|
581 |
images.append(generate_image(value_summary))
|
582 |
|
|
|
|
|
|
|
|
|
583 |
return images
|
584 |
|
585 |
|
@@ -635,15 +609,14 @@ with gr.Blocks() as demo:
|
|
635 |
outputs=[references1, references2, references3, outline_result, outline_token_output, output, token_output]
|
636 |
)
|
637 |
|
638 |
-
# ์ด๋ฏธ์ง ์์ฑ ๋ฒํผ ๋ฐ ์ถ๋ ฅ ์ถ๊ฐ
|
639 |
-
generate_images_btn = gr.Button("์ด๋ฏธ์ง ์์ฑํ๊ธฐ")
|
640 |
image_outputs = [gr.Image(label=f"์์ฑ๋ ์ด๋ฏธ์ง {i+1}") for i in range(5)]
|
641 |
-
|
642 |
generate_images_btn.click(
|
643 |
fn=generate_images,
|
644 |
inputs=[output],
|
645 |
outputs=image_outputs
|
646 |
)
|
|
|
|
|
647 |
|
648 |
save_pdf_btn = gr.Button("PDF๋ก ์ ์ฅํ๊ธฐ")
|
649 |
pdf_output = gr.File(label="์์ฑ๋ PDF ํ์ผ")
|
|
|
511 |
variant="fp16"
|
512 |
).to(device)
|
513 |
|
514 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
515 |
|
516 |
def generate_images(blog_post):
|
517 |
images = []
|
|
|
550 |
value_summary = f"Image symbolizing the value and benefit for readers: {conclusion_text[:100]}..."
|
551 |
images.append(generate_image(value_summary))
|
552 |
|
553 |
+
# ๋ง์ฝ ์์ฑ๋ ์ด๋ฏธ์ง๊ฐ 5๊ฐ ๋ฏธ๋ง์ด๋ผ๋ฉด, ๋ถ์กฑํ ๋งํผ ๋ง์ง๋ง ์ด๋ฏธ์ง๋ฅผ ๋ณต์
|
554 |
+
while len(images) < 5:
|
555 |
+
images.append(images[-1] if images else "")
|
556 |
+
|
557 |
return images
|
558 |
|
559 |
|
|
|
609 |
outputs=[references1, references2, references3, outline_result, outline_token_output, output, token_output]
|
610 |
)
|
611 |
|
|
|
|
|
612 |
image_outputs = [gr.Image(label=f"์์ฑ๋ ์ด๋ฏธ์ง {i+1}") for i in range(5)]
|
|
|
613 |
generate_images_btn.click(
|
614 |
fn=generate_images,
|
615 |
inputs=[output],
|
616 |
outputs=image_outputs
|
617 |
)
|
618 |
+
|
619 |
+
|
620 |
|
621 |
save_pdf_btn = gr.Button("PDF๋ก ์ ์ฅํ๊ธฐ")
|
622 |
pdf_output = gr.File(label="์์ฑ๋ PDF ํ์ผ")
|