Spaces:
Running
on
Zero
Running
on
Zero
Update app.py
Browse files
app.py
CHANGED
@@ -16,6 +16,15 @@ import requests
|
|
16 |
import pandas as pd
|
17 |
from transformers import pipeline
|
18 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
19 |
# 번역 모델 로드
|
20 |
translator = pipeline("translation", model="Helsinki-NLP/opus-mt-ko-en")
|
21 |
|
@@ -479,6 +488,31 @@ css = '''
|
|
479 |
#component-11{align-self: stretch;}
|
480 |
footer {visibility: hidden;}
|
481 |
'''
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
482 |
|
483 |
with gr.Blocks(theme="Nymbo/Nymbo_Theme", css=css, delete_cache=(60, 3600)) as app:
|
484 |
|
@@ -489,6 +523,7 @@ with gr.Blocks(theme="Nymbo/Nymbo_Theme", css=css, delete_cache=(60, 3600)) as a
|
|
489 |
prompt = gr.Textbox(label="Prompt", lines=1, placeholder="Type a prompt after selecting a LoRA")
|
490 |
with gr.Column(scale=1):
|
491 |
generate_button = gr.Button("Generate", variant="primary", elem_classes=["button_total"])
|
|
|
492 |
with gr.Row(elem_id="loaded_loras"):
|
493 |
with gr.Column(scale=1, min_width=25):
|
494 |
randomize_button = gr.Button("🎲", variant="secondary", scale=1, elem_id="random_btn")
|
@@ -590,6 +625,12 @@ with gr.Blocks(theme="Nymbo/Nymbo_Theme", css=css, delete_cache=(60, 3600)) as a
|
|
590 |
inputs=[result, history_gallery],
|
591 |
outputs=history_gallery,
|
592 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
593 |
|
594 |
app.queue()
|
595 |
app.launch()
|
|
|
16 |
import pandas as pd
|
17 |
from transformers import pipeline
|
18 |
|
19 |
+
import logging
|
20 |
+
import random
|
21 |
+
import warnings
|
22 |
+
import numpy as np
|
23 |
+
from diffusers import FluxControlNetModel
|
24 |
+
from diffusers.pipelines import FluxControlNetPipeline
|
25 |
+
from PIL import Image
|
26 |
+
from huggingface_hub import snapshot_download
|
27 |
+
|
28 |
# 번역 모델 로드
|
29 |
translator = pipeline("translation", model="Helsinki-NLP/opus-mt-ko-en")
|
30 |
|
|
|
488 |
#component-11{align-self: stretch;}
|
489 |
footer {visibility: hidden;}
|
490 |
'''
|
491 |
+
# 업스케일 함수 추가
|
492 |
+
@spaces.GPU
|
493 |
+
def upscale(input_image, progress=gr.Progress(track_tqdm=True)):
|
494 |
+
# 입력 이미지 처리
|
495 |
+
input_image, w_original, h_original, was_resized = process_input(input_image, 4)
|
496 |
+
|
497 |
+
# 4096x4096 크기로 조정
|
498 |
+
control_image = input_image.resize((4096, 4096))
|
499 |
+
|
500 |
+
generator = torch.Generator(device=device).manual_seed(random.randint(0, MAX_SEED))
|
501 |
+
|
502 |
+
gr.Info("Upscaling image to 4096x4096...")
|
503 |
+
image = pipe(
|
504 |
+
prompt="",
|
505 |
+
control_image=control_image,
|
506 |
+
controlnet_conditioning_scale=0.6,
|
507 |
+
num_inference_steps=28,
|
508 |
+
guidance_scale=3.5,
|
509 |
+
height=4096,
|
510 |
+
width=4096,
|
511 |
+
generator=generator,
|
512 |
+
).images[0]
|
513 |
+
|
514 |
+
return image
|
515 |
+
|
516 |
|
517 |
with gr.Blocks(theme="Nymbo/Nymbo_Theme", css=css, delete_cache=(60, 3600)) as app:
|
518 |
|
|
|
523 |
prompt = gr.Textbox(label="Prompt", lines=1, placeholder="Type a prompt after selecting a LoRA")
|
524 |
with gr.Column(scale=1):
|
525 |
generate_button = gr.Button("Generate", variant="primary", elem_classes=["button_total"])
|
526 |
+
upscale_button = gr.Button("업스케일(4096X4096픽셀)", variant="secondary")
|
527 |
with gr.Row(elem_id="loaded_loras"):
|
528 |
with gr.Column(scale=1, min_width=25):
|
529 |
randomize_button = gr.Button("🎲", variant="secondary", scale=1, elem_id="random_btn")
|
|
|
625 |
inputs=[result, history_gallery],
|
626 |
outputs=history_gallery,
|
627 |
)
|
628 |
+
|
629 |
+
upscale_button.click(
|
630 |
+
upscale,
|
631 |
+
inputs=[result],
|
632 |
+
outputs=[result]
|
633 |
+
)
|
634 |
|
635 |
app.queue()
|
636 |
app.launch()
|