Spaces:
Running
on
Zero
Running
on
Zero
fix
Browse files
app.py
CHANGED
@@ -17,15 +17,16 @@ load_wd14_tagger_model()
|
|
17 |
def process_image(input_image, mode, weight1, weight2):
|
18 |
# 画像処理ロジック
|
19 |
sotai_image, sketch_image = process_image_as_base64(input_image, mode, weight1, weight2)
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
|
|
25 |
|
26 |
# Gradio インターフェースの定義
|
27 |
iface = gr.Interface(
|
28 |
-
fn=
|
29 |
inputs=[
|
30 |
gr.Image(type="pil", label="Input Image"),
|
31 |
gr.Radio(["original", "refine"], label="Mode", value="original"),
|
@@ -41,7 +42,7 @@ iface = gr.Interface(
|
|
41 |
)
|
42 |
|
43 |
# APIとして公開
|
44 |
-
app = gr.mount_gradio_app(app, iface, path="/")
|
45 |
|
46 |
# Hugging Face Spacesでデプロイする場合
|
47 |
iface.queue().launch()
|
|
|
17 |
def process_image(input_image, mode, weight1, weight2):
|
18 |
# 画像処理ロジック
|
19 |
sotai_image, sketch_image = process_image_as_base64(input_image, mode, weight1, weight2)
|
20 |
+
|
21 |
+
# Base64文字列をPIL Imageに変換
|
22 |
+
sotai_pil = Image.open(io.BytesIO(base64.b64decode(sotai_image)))
|
23 |
+
sketch_pil = Image.open(io.BytesIO(base64.b64decode(sketch_image)))
|
24 |
+
|
25 |
+
return sotai_pil, sketch_pil
|
26 |
|
27 |
# Gradio インターフェースの定義
|
28 |
iface = gr.Interface(
|
29 |
+
fn=process_image,
|
30 |
inputs=[
|
31 |
gr.Image(type="pil", label="Input Image"),
|
32 |
gr.Radio(["original", "refine"], label="Mode", value="original"),
|
|
|
42 |
)
|
43 |
|
44 |
# APIとして公開
|
45 |
+
app = gr.mount_gradio_app(app, iface, path="/predict")
|
46 |
|
47 |
# Hugging Face Spacesでデプロイする場合
|
48 |
iface.queue().launch()
|