ssboost commited on
Commit
8361071
ยท
verified ยท
1 Parent(s): ff5efd2

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +41 -64
app.py CHANGED
@@ -146,28 +146,19 @@ def upscale_image(
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
- # 1) ๋น„๋ฐ€๋ฒˆํ˜ธ ์ž…๋ ฅ
154
- password_input = gr.Textbox(
155
- label="๋น„๋ฐ€๋ฒˆํ˜ธ",
156
- type="password",
157
- placeholder="๋น„๋ฐ€๋ฒˆํ˜ธ๋ฅผ ์ž…๋ ฅํ•˜์„ธ์š”"
158
- )
159
-
160
- # 2) ์—…์Šค์ผ€์ผํ•  ์ด๋ฏธ์ง€ ์ž…๋ ฅ
161
  input_image = gr.Image(label="์›๋ณธ ์ด๋ฏธ์ง€", type="pil")
162
-
163
- # 3) ๊ณ ๊ธ‰ ์„ค์ • ์•„์ฝ”๋””์–ธ ์•ˆ์— ํŒŒ๋ผ๋ฏธํ„ฐ๋“ค ์ •์˜
164
  with gr.Accordion("๊ณ ๊ธ‰ ์„ค์ •", open=False):
165
- scale_factor = gr.Slider(
166
- minimum=1, maximum=4, value=2, step=0.5, label="ํ™•๋Œ€ ๋น„์œจ"
167
- )
168
- output_format = gr.Radio(
169
- choices=["jpg", "png"], value="jpg", label="์ถœ๋ ฅ ํ˜•์‹"
170
- )
171
  sd_model = gr.Dropdown(
172
  choices=[
173
  "juggernaut_reborn.safetensors [338b85bc4f]",
@@ -178,66 +169,52 @@ def create_interface():
178
  value="juggernaut_reborn.safetensors [338b85bc4f]",
179
  label="SD ๋ชจ๋ธ"
180
  )
181
- resemblance = gr.Slider(
182
- minimum=0.0, maximum=1.0, value=0.6, step=0.05, label="์›๋ณธ ์œ ์‚ฌ๋„"
183
- )
184
- creativity = gr.Slider(
185
- minimum=0.0, maximum=1.0, value=0.35, step=0.05, label="์ฐฝ์˜์„ฑ"
186
- )
187
- dynamic = gr.Slider(
188
- minimum=1, maximum=10, value=6, step=1, label="๋‹ค์ด๋‚˜๋ฏน ์ž„๊ณ„๊ฐ’"
189
- )
190
- sharpen = gr.Slider(
191
- minimum=0, maximum=2, value=0, step=0.1, label="์„ ๋ช…๋„"
192
- )
193
- seed = gr.Number(
194
- value=1337, label="์‹œ๋“œ", precision=0
195
- )
196
-
197
- # 4) ์‹คํ–‰ ๋ฒ„ํŠผ
198
- submit_btn = gr.Button("์‹คํ–‰", variant="primary")
199
-
200
  with gr.Column():
201
- # 5) ๊ฒฐ๊ณผ ์ด๋ฏธ์ง€ ํ‘œ์‹œ
202
  output_image = gr.Image(label="๊ฐœ์„ ๋œ ์ด๋ฏธ์ง€")
203
-
204
- # 6) ๋ฒ„ํŠผ ํด๋ฆญ ์‹œ ํ˜ธ์ถœํ•  ํ•จ์ˆ˜
205
- def process_image(
206
- password, image, scale_factor, output_format, sd_model,
207
- resemblance, creativity, dynamic, sharpen, seed
208
- ):
209
- # ๋น„๋ฐ€๋ฒˆํ˜ธ ๊ฒ€์ฆ
210
- if password != "1089":
211
- raise ValueError("์ž˜๋ชป๋œ ๋น„๋ฐ€๋ฒˆํ˜ธ์ž…๋‹ˆ๋‹ค.")
212
  if image is None:
213
  return None
214
-
215
- return upscale_image(
216
- image=image,
217
- scale_factor=scale_factor,
218
- output_format=output_format,
219
- sd_model=sd_model,
220
- resemblance=resemblance,
221
- creativity=creativity,
222
- dynamic=dynamic,
223
- sharpen=sharpen,
224
- seed=int(seed)
225
- )
226
-
227
- # 7) click ์ด๋ฒคํŠธ์— ๋ชจ๋“  ์ž…๋ ฅ ์œ„์ ฏ์„ ์ˆœ์„œ๋Œ€๋กœ ์ „๋‹ฌ
 
 
 
 
228
  submit_btn.click(
229
  process_image,
230
  inputs=[
231
- password_input,
232
- input_image, scale_factor, output_format, sd_model,
233
  resemblance, creativity, dynamic, sharpen, seed
234
  ],
235
  outputs=[output_image]
236
  )
237
-
238
  return demo
239
 
240
-
241
  # ๋ฉ”์ธ ์‹คํ–‰
242
  if __name__ == "__main__":
243
  demo = create_interface()
 
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 - ์ด๋ฏธ์ง€ ํ™”์งˆ ๊ฐœ์„ ") as demo:
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(minimum=1, maximum=4, value=2, step=0.5, label="ํ™•๋Œ€ ๋น„์œจ")
161
+ output_format = gr.Radio(["jpg", "png"], value="jpg", label="์ถœ๋ ฅ ํ˜•์‹")
 
 
 
 
162
  sd_model = gr.Dropdown(
163
  choices=[
164
  "juggernaut_reborn.safetensors [338b85bc4f]",
 
169
  value="juggernaut_reborn.safetensors [338b85bc4f]",
170
  label="SD ๋ชจ๋ธ"
171
  )
172
+ resemblance = gr.Slider(minimum=0.0, maximum=1.0, value=0.6, step=0.05, label="์›๋ณธ ์œ ์‚ฌ๋„")
173
+ creativity = gr.Slider(minimum=0.0, maximum=1.0, value=0.35, step=0.05, label="์ฐฝ์˜์„ฑ")
174
+ dynamic = gr.Slider(minimum=1, maximum=10, value=6, step=1, label="๋‹ค์ด๋‚˜๋ฏน ์ž„๊ณ„๊ฐ’")
175
+ sharpen = gr.Slider(minimum=0, maximum=2, value=0, step=0.1, label="์„ ๋ช…๋„")
176
+ seed = gr.Number(value=1337, label="์‹œ๋“œ", precision=0)
177
+
178
+ submit_btn = gr.Button("ํ™”์งˆ ๊ฐœ์„  ์‹œ์ž‘", variant="primary")
179
+
 
 
 
 
 
 
 
 
 
 
 
180
  with gr.Column():
 
181
  output_image = gr.Image(label="๊ฐœ์„ ๋œ ์ด๋ฏธ์ง€")
182
+
183
+ # ๋กœ๊ทธ ์บก์ฒ˜ ๊ธฐ๋Šฅ ์ œ๊ฑฐ (UI์—์„œ ๋กœ๊ทธ ํ‘œ์‹œํ•˜์ง€ ์•Š์Œ)
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
+ return result
203
+ except Exception as e:
204
+ logger.error(f"์ด๋ฏธ์ง€ ์ฒ˜๋ฆฌ ์ค‘ ์˜ค๋ฅ˜ ๋ฐœ์ƒ: {str(e)}")
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()