Update app.py
Browse files
app.py
CHANGED
@@ -146,18 +146,19 @@ def upscale_image(
|
|
146 |
if os.path.exists(temp_input_path):
|
147 |
os.remove(temp_input_path)
|
148 |
|
149 |
-
# Gradio ์ธํฐํ์ด์ค ์์ฑ
|
150 |
def create_interface():
|
151 |
-
with gr.Blocks(title="Clarity Upscaler
|
152 |
-
gr.Markdown("# Clarity Upscaler - ์ด๋ฏธ์ง ํ์ง ๊ฐ์ ๋๊ตฌ")
|
153 |
-
gr.Markdown("Replicate์ Clarity Upscaler ๋ชจ๋ธ์ ์ฌ์ฉํ์ฌ ์ด๋ฏธ์ง์ ํ์ง์ ๊ฐ์ ํฉ๋๋ค.")
|
154 |
-
|
155 |
with gr.Row():
|
156 |
with gr.Column():
|
|
|
|
|
|
|
|
|
|
|
157 |
input_image = gr.Image(label="์๋ณธ ์ด๋ฏธ์ง", type="pil")
|
158 |
-
|
159 |
with gr.Accordion("๊ณ ๊ธ ์ค์ ", open=False):
|
160 |
-
scale_factor = gr.Slider(
|
161 |
output_format = gr.Radio(["jpg", "png"], value="jpg", label="์ถ๋ ฅ ํ์")
|
162 |
sd_model = gr.Dropdown(
|
163 |
choices=[
|
@@ -169,53 +170,61 @@ def create_interface():
|
|
169 |
value="juggernaut_reborn.safetensors [338b85bc4f]",
|
170 |
label="SD ๋ชจ๋ธ"
|
171 |
)
|
172 |
-
resemblance = gr.Slider(
|
173 |
-
creativity
|
174 |
-
dynamic
|
175 |
-
sharpen
|
176 |
-
seed
|
177 |
-
|
178 |
-
submit_btn = gr.Button("ํ์ง ๊ฐ์ ์์", variant="primary")
|
179 |
|
|
|
|
|
180 |
with gr.Column():
|
181 |
output_image = gr.Image(label="๊ฐ์ ๋ ์ด๋ฏธ์ง")
|
182 |
-
|
183 |
-
|
184 |
-
|
185 |
-
|
186 |
-
def process_image(image, scale_factor, output_format, sd_model, resemblance, creativity, dynamic, sharpen, seed):
|
187 |
-
if image is None:
|
188 |
-
return None
|
189 |
-
|
190 |
-
try:
|
191 |
-
result = upscale_image(
|
192 |
-
image=image,
|
193 |
-
scale_factor=scale_factor,
|
194 |
-
output_format=output_format,
|
195 |
-
sd_model=sd_model,
|
196 |
-
resemblance=resemblance,
|
197 |
-
creativity=creativity,
|
198 |
-
dynamic=dynamic,
|
199 |
-
sharpen=sharpen,
|
200 |
-
seed=int(seed)
|
201 |
)
|
202 |
-
|
203 |
-
|
204 |
-
|
|
|
|
|
|
|
|
|
|
|
205 |
return None
|
206 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
207 |
submit_btn.click(
|
208 |
-
process_image,
|
209 |
inputs=[
|
210 |
-
input_image, scale_factor, output_format, sd_model,
|
211 |
resemblance, creativity, dynamic, sharpen, seed
|
212 |
],
|
213 |
outputs=[output_image]
|
214 |
)
|
215 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
216 |
return demo
|
217 |
|
218 |
-
# ๋ฉ์ธ ์คํ
|
219 |
if __name__ == "__main__":
|
220 |
demo = create_interface()
|
221 |
demo.launch(share=True)
|
|
|
146 |
if os.path.exists(temp_input_path):
|
147 |
os.remove(temp_input_path)
|
148 |
|
|
|
149 |
def create_interface():
|
150 |
+
with gr.Blocks(title="Clarity Upscaler") as demo:
|
|
|
|
|
|
|
151 |
with gr.Row():
|
152 |
with gr.Column():
|
153 |
+
password_input = gr.Textbox(
|
154 |
+
label="๋น๋ฐ๋ฒํธ",
|
155 |
+
type="password",
|
156 |
+
placeholder="๋น๋ฐ๋ฒํธ๋ฅผ ์
๋ ฅํ์ธ์"
|
157 |
+
)
|
158 |
input_image = gr.Image(label="์๋ณธ ์ด๋ฏธ์ง", type="pil")
|
159 |
+
|
160 |
with gr.Accordion("๊ณ ๊ธ ์ค์ ", open=False):
|
161 |
+
scale_factor = gr.Slider(1, 4, value=2, step=0.5, label="ํ๋ ๋น์จ")
|
162 |
output_format = gr.Radio(["jpg", "png"], value="jpg", label="์ถ๋ ฅ ํ์")
|
163 |
sd_model = gr.Dropdown(
|
164 |
choices=[
|
|
|
170 |
value="juggernaut_reborn.safetensors [338b85bc4f]",
|
171 |
label="SD ๋ชจ๋ธ"
|
172 |
)
|
173 |
+
resemblance = gr.Slider(0.0, 1.0, value=0.6, step=0.05, label="์๋ณธ ์ ์ฌ๋")
|
174 |
+
creativity = gr.Slider(0.0, 1.0, value=0.35, step=0.05, label="์ฐฝ์์ฑ")
|
175 |
+
dynamic = gr.Slider(1, 10, value=6, step=1, label="๋ค์ด๋๋ฏน ์๊ณ๊ฐ")
|
176 |
+
sharpen = gr.Slider(0, 2, value=0, step=0.1, label="์ ๋ช
๋")
|
177 |
+
seed = gr.Number(value=1337, label="์๋", precision=0)
|
|
|
|
|
178 |
|
179 |
+
submit_btn = gr.Button("์คํ", variant="primary")
|
180 |
+
|
181 |
with gr.Column():
|
182 |
output_image = gr.Image(label="๊ฐ์ ๋ ์ด๋ฏธ์ง")
|
183 |
+
download_btn = gr.DownloadButton(
|
184 |
+
label="๋ค์ด๋ก๋",
|
185 |
+
file_name="upscaled.jpg",
|
186 |
+
mime="image/jpeg"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
187 |
)
|
188 |
+
|
189 |
+
def process_image(
|
190 |
+
password, image, scale_factor, output_format, sd_model,
|
191 |
+
resemblance, creativity, dynamic, sharpen, seed
|
192 |
+
):
|
193 |
+
if password != "1089":
|
194 |
+
raise ValueError("์๋ชป๋ ๋น๋ฐ๋ฒํธ์
๋๋ค.")
|
195 |
+
if image is None:
|
196 |
return None
|
197 |
+
|
198 |
+
return upscale_image(
|
199 |
+
image=image,
|
200 |
+
scale_factor=scale_factor,
|
201 |
+
output_format=output_format,
|
202 |
+
sd_model=sd_model,
|
203 |
+
resemblance=resemblance,
|
204 |
+
creativity=creativity,
|
205 |
+
dynamic=dynamic,
|
206 |
+
sharpen=sharpen,
|
207 |
+
seed=int(seed)
|
208 |
+
)
|
209 |
+
|
210 |
+
# 1) ์คํ ๋ฒํผ โ output_image
|
211 |
submit_btn.click(
|
212 |
+
fn=process_image,
|
213 |
inputs=[
|
214 |
+
password_input, input_image, scale_factor, output_format, sd_model,
|
215 |
resemblance, creativity, dynamic, sharpen, seed
|
216 |
],
|
217 |
outputs=[output_image]
|
218 |
)
|
219 |
+
# 2) ๋ค์ด๋ก๋ ๋ฒํผ โ output_image ๊ทธ๋๋ก ๋ฐ์์ ํ์ผ๋ก ์ ๊ณต
|
220 |
+
download_btn.click(
|
221 |
+
fn=lambda img: img,
|
222 |
+
inputs=[output_image],
|
223 |
+
outputs=[download_btn]
|
224 |
+
)
|
225 |
+
|
226 |
return demo
|
227 |
|
|
|
228 |
if __name__ == "__main__":
|
229 |
demo = create_interface()
|
230 |
demo.launch(share=True)
|