Update app.py
Browse files
app.py
CHANGED
@@ -146,73 +146,65 @@ 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="
|
152 |
-
|
153 |
with gr.Row():
|
154 |
with gr.Column():
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
155 |
input_image = gr.Image(label="์๋ณธ ์ด๋ฏธ์ง", type="pil")
|
156 |
-
|
157 |
-
|
158 |
-
scale_factor = gr.Slider(minimum=1, maximum=4, value=2, step=0.5, label="ํ๋ ๋น์จ")
|
159 |
-
output_format = gr.Radio(["jpg", "png"], value="jpg", label="์ถ๋ ฅ ํ์")
|
160 |
-
sd_model = gr.Dropdown(
|
161 |
-
choices=[
|
162 |
-
"juggernaut_reborn.safetensors [338b85bc4f]",
|
163 |
-
"sd_xl_base_1.0.safetensors [39d4e625d]",
|
164 |
-
"sdxl_base_v0.9-9961.safetensors [3048045c]",
|
165 |
-
"realisticVisionV51_v51VAE.safetensors [5ecbfa0ac]",
|
166 |
-
],
|
167 |
-
value="juggernaut_reborn.safetensors [338b85bc4f]",
|
168 |
-
label="SD ๋ชจ๋ธ"
|
169 |
-
)
|
170 |
-
resemblance = gr.Slider(minimum=0.0, maximum=1.0, value=0.6, step=0.05, label="์๋ณธ ์ ์ฌ๋")
|
171 |
-
creativity = gr.Slider(minimum=0.0, maximum=1.0, value=0.35, step=0.05, label="์ฐฝ์์ฑ")
|
172 |
-
dynamic = gr.Slider(minimum=1, maximum=10, value=6, step=1, label="๋ค์ด๋๋ฏน ์๊ณ๊ฐ")
|
173 |
-
sharpen = gr.Slider(minimum=0, maximum=2, value=0, step=0.1, label="์ ๋ช
๋")
|
174 |
-
seed = gr.Number(value=1337, label="์๋", precision=0)
|
175 |
-
|
176 |
submit_btn = gr.Button("์คํ", variant="primary")
|
177 |
-
|
178 |
with gr.Column():
|
179 |
output_image = gr.Image(label="๊ฐ์ ๋ ์ด๋ฏธ์ง")
|
180 |
-
|
181 |
-
#
|
182 |
-
|
183 |
-
|
184 |
-
|
185 |
-
|
186 |
-
|
|
|
|
|
187 |
|
188 |
-
|
189 |
-
result = upscale_image(
|
190 |
-
image=image,
|
191 |
-
scale_factor=scale_factor,
|
192 |
-
output_format=output_format,
|
193 |
-
sd_model=sd_model,
|
194 |
-
resemblance=resemblance,
|
195 |
-
creativity=creativity,
|
196 |
-
dynamic=dynamic,
|
197 |
-
sharpen=sharpen,
|
198 |
-
seed=int(seed)
|
199 |
-
)
|
200 |
-
return result
|
201 |
-
except Exception as e:
|
202 |
-
logger.error(f"์ด๋ฏธ์ง ์ฒ๋ฆฌ ์ค ์ค๋ฅ ๋ฐ์: {str(e)}")
|
203 |
return None
|
204 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
205 |
submit_btn.click(
|
206 |
process_image,
|
207 |
inputs=[
|
|
|
208 |
input_image, scale_factor, output_format, sd_model,
|
209 |
resemblance, creativity, dynamic, sharpen, seed
|
210 |
],
|
211 |
outputs=[output_image]
|
212 |
)
|
213 |
-
|
214 |
return demo
|
215 |
|
|
|
216 |
# ๋ฉ์ธ ์คํ
|
217 |
if __name__ == "__main__":
|
218 |
demo = create_interface()
|
|
|
146 |
if os.path.exists(temp_input_path):
|
147 |
os.remove(temp_input_path)
|
148 |
|
149 |
+
# 1) Gradio ์ธํฐํ์ด์ค ์์ฑ๋ถ์์ ๋ณ๊ฒฝ๋ ๋ถ๋ถ๋ง ๋ฐ์ท
|
150 |
def create_interface():
|
151 |
+
with gr.Blocks(title="Clarity Upscaler") as demo:
|
|
|
152 |
with gr.Row():
|
153 |
with gr.Column():
|
154 |
+
# ๋น๋ฐ๋ฒํธ ์
๋ ฅ ํ๋ ์ถ๊ฐ
|
155 |
+
password_input = gr.Textbox(
|
156 |
+
label="๋น๋ฐ๋ฒํธ",
|
157 |
+
type="password",
|
158 |
+
placeholder="๋น๋ฐ๋ฒํธ๋ฅผ ์
๋ ฅํ์ธ์"
|
159 |
+
)
|
160 |
+
|
161 |
input_image = gr.Image(label="์๋ณธ ์ด๋ฏธ์ง", type="pil")
|
162 |
+
# โฆ (๊ธฐ์กด ๊ณ ๊ธ ์ค์ Accordion)
|
163 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
164 |
submit_btn = gr.Button("์คํ", variant="primary")
|
165 |
+
|
166 |
with gr.Column():
|
167 |
output_image = gr.Image(label="๊ฐ์ ๋ ์ด๋ฏธ์ง")
|
168 |
+
|
169 |
+
# 2) process_image ํจ์ ์๊ทธ๋์ฒ ์์
|
170 |
+
def process_image(
|
171 |
+
password, image, scale_factor, output_format, sd_model,
|
172 |
+
resemblance, creativity, dynamic, sharpen, seed
|
173 |
+
):
|
174 |
+
# ๋น๋ฐ๋ฒํธ ๊ฒ์ฆ
|
175 |
+
if password != "1089":
|
176 |
+
raise ValueError("์๋ชป๋ ๋น๋ฐ๋ฒํธ์
๋๋ค.")
|
177 |
|
178 |
+
if image is None:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
179 |
return None
|
180 |
+
|
181 |
+
# ๊ธฐ์กด ๋ก์ง ํธ์ถ
|
182 |
+
return upscale_image(
|
183 |
+
image=image,
|
184 |
+
scale_factor=scale_factor,
|
185 |
+
output_format=output_format,
|
186 |
+
sd_model=sd_model,
|
187 |
+
resemblance=resemblance,
|
188 |
+
creativity=creativity,
|
189 |
+
dynamic=dynamic,
|
190 |
+
sharpen=sharpen,
|
191 |
+
seed=int(seed)
|
192 |
+
)
|
193 |
+
|
194 |
+
# 3) ํด๋ฆญ ์ด๋ฒคํธ์ password_input ์ถ๊ฐ
|
195 |
submit_btn.click(
|
196 |
process_image,
|
197 |
inputs=[
|
198 |
+
password_input, # ๋งจ ์์ ๋น๋ฐ๋ฒํธ
|
199 |
input_image, scale_factor, output_format, sd_model,
|
200 |
resemblance, creativity, dynamic, sharpen, seed
|
201 |
],
|
202 |
outputs=[output_image]
|
203 |
)
|
204 |
+
|
205 |
return demo
|
206 |
|
207 |
+
|
208 |
# ๋ฉ์ธ ์คํ
|
209 |
if __name__ == "__main__":
|
210 |
demo = create_interface()
|