Update app.py
Browse files
app.py
CHANGED
|
@@ -148,7 +148,8 @@ def upscale_image(
|
|
| 148 |
|
| 149 |
# Gradio ์ธํฐํ์ด์ค ์์ฑ
|
| 150 |
def create_interface():
|
| 151 |
-
with gr.Blocks(title="Test") as demo:
|
|
|
|
| 152 |
with gr.Row():
|
| 153 |
with gr.Column():
|
| 154 |
input_image = gr.Image(label="์๋ณธ ์ด๋ฏธ์ง", type="pil")
|
|
@@ -172,44 +173,17 @@ def create_interface():
|
|
| 172 |
sharpen = gr.Slider(minimum=0, maximum=2, value=0, step=0.1, label="์ ๋ช
๋")
|
| 173 |
seed = gr.Number(value=1337, label="์๋", precision=0)
|
| 174 |
|
| 175 |
-
submit_btn = gr.Button("์คํ
|
| 176 |
|
| 177 |
with gr.Column():
|
| 178 |
output_image = gr.Image(label="๊ฐ์ ๋ ์ด๋ฏธ์ง")
|
| 179 |
-
log_output = gr.Textbox(label="๋ก๊ทธ", lines=10)
|
| 180 |
-
|
| 181 |
-
# ๋ก๊ทธ ์บก์ฒ ํจ์
|
| 182 |
-
class LogCapture:
|
| 183 |
-
def __init__(self):
|
| 184 |
-
self.logs = []
|
| 185 |
-
self.handler = self.create_handler()
|
| 186 |
-
|
| 187 |
-
def create_handler(self):
|
| 188 |
-
handler = logging.StreamHandler(stream=self)
|
| 189 |
-
handler.setFormatter(logging.Formatter('%(asctime)s - %(levelname)s - %(message)s'))
|
| 190 |
-
return handler
|
| 191 |
-
|
| 192 |
-
def write(self, message):
|
| 193 |
-
self.logs.append(message)
|
| 194 |
-
|
| 195 |
-
def flush(self):
|
| 196 |
-
pass
|
| 197 |
-
|
| 198 |
-
def get_logs(self):
|
| 199 |
-
return "".join(self.logs)
|
| 200 |
-
|
| 201 |
-
def clear(self):
|
| 202 |
-
self.logs.clear()
|
| 203 |
|
| 204 |
-
|
| 205 |
-
logger.addHandler(log_capture.handler)
|
| 206 |
|
| 207 |
# ์ ์ถ ๋ฒํผ ํด๋ฆญ ์ ๋์
|
| 208 |
def process_image(image, scale_factor, output_format, sd_model, resemblance, creativity, dynamic, sharpen, seed):
|
| 209 |
if image is None:
|
| 210 |
-
return None
|
| 211 |
-
|
| 212 |
-
log_capture.clear()
|
| 213 |
|
| 214 |
try:
|
| 215 |
result = upscale_image(
|
|
@@ -223,10 +197,10 @@ def create_interface():
|
|
| 223 |
sharpen=sharpen,
|
| 224 |
seed=int(seed)
|
| 225 |
)
|
| 226 |
-
return result
|
| 227 |
except Exception as e:
|
| 228 |
logger.error(f"์ด๋ฏธ์ง ์ฒ๋ฆฌ ์ค ์ค๋ฅ ๋ฐ์: {str(e)}")
|
| 229 |
-
return None
|
| 230 |
|
| 231 |
submit_btn.click(
|
| 232 |
process_image,
|
|
@@ -234,7 +208,7 @@ def create_interface():
|
|
| 234 |
input_image, scale_factor, output_format, sd_model,
|
| 235 |
resemblance, creativity, dynamic, sharpen, seed
|
| 236 |
],
|
| 237 |
-
outputs=[output_image
|
| 238 |
)
|
| 239 |
|
| 240 |
return demo
|
|
|
|
| 148 |
|
| 149 |
# Gradio ์ธํฐํ์ด์ค ์์ฑ
|
| 150 |
def create_interface():
|
| 151 |
+
with gr.Blocks(title="Test") as demo:
|
| 152 |
+
|
| 153 |
with gr.Row():
|
| 154 |
with gr.Column():
|
| 155 |
input_image = gr.Image(label="์๋ณธ ์ด๋ฏธ์ง", type="pil")
|
|
|
|
| 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 |
+
# ๋ก๊ทธ ์บก์ฒ ๊ธฐ๋ฅ ์ ๊ฑฐ (UI์์ ๋ก๊ทธ ํ์ํ์ง ์์)
|
|
|
|
| 182 |
|
| 183 |
# ์ ์ถ ๋ฒํผ ํด๋ฆญ ์ ๋์
|
| 184 |
def process_image(image, scale_factor, output_format, sd_model, resemblance, creativity, dynamic, sharpen, seed):
|
| 185 |
if image is None:
|
| 186 |
+
return None
|
|
|
|
|
|
|
| 187 |
|
| 188 |
try:
|
| 189 |
result = upscale_image(
|
|
|
|
| 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,
|
|
|
|
| 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
|