Spaces:
Runtime error
Runtime error
seawolf2357
commited on
Commit
โข
3382a71
1
Parent(s):
3ec95cb
Update app.py
Browse files
app.py
CHANGED
@@ -6,6 +6,12 @@ from PIL import Image
|
|
6 |
model = pipeline("image-classification", model="google/vit-base-patch16-224")
|
7 |
|
8 |
def classify_image(uploaded_image):
|
|
|
|
|
|
|
|
|
|
|
|
|
9 |
predictions = model(uploaded_image)
|
10 |
return {prediction['label']: prediction['score'] for prediction in predictions}
|
11 |
|
@@ -16,6 +22,5 @@ iface = gr.Interface(fn=classify_image,
|
|
16 |
title="์ด๋ฏธ์ง ๋ถ๋ฅ๊ธฐ",
|
17 |
description="์ด๋ฏธ์ง๋ฅผ ์
๋ก๋ํ๋ฉด, ์ฌ๋ฌผ์ ์ธ์ํ๊ณ ์ต์์ 3๊ฐ์ ๋ถ๋ฅ ๊ฒฐ๊ณผ๋ฅผ ์ถ๋ ฅํฉ๋๋ค.")
|
18 |
|
19 |
-
# ์ธํฐํ์ด์ค ์คํ
|
20 |
-
iface.launch(
|
21 |
-
|
|
|
6 |
model = pipeline("image-classification", model="google/vit-base-patch16-224")
|
7 |
|
8 |
def classify_image(uploaded_image):
|
9 |
+
# ์
๋ก๋๋ ์ด๋ฏธ์ง๊ฐ PIL ์ด๋ฏธ์ง ๊ฐ์ฒด๊ฐ ์๋ ๊ฒฝ์ฐ ๋ณํ
|
10 |
+
if not isinstance(uploaded_image, Image.Image):
|
11 |
+
# ์
๋ก๋๋ ์ด๋ฏธ์ง๊ฐ PIL ์ด๋ฏธ์ง ๊ฐ์ฒด๊ฐ ์๋๋ฉด, ์ด ๋ถ๋ถ์ ์ฒ๋ฆฌํ๋ ๋ก์ง ์ถ๊ฐ
|
12 |
+
# ์: uploaded_image = Image.open(io.BytesIO(uploaded_image))
|
13 |
+
raise ValueError("Uploaded image is not a PIL Image object.")
|
14 |
+
|
15 |
predictions = model(uploaded_image)
|
16 |
return {prediction['label']: prediction['score'] for prediction in predictions}
|
17 |
|
|
|
22 |
title="์ด๋ฏธ์ง ๋ถ๋ฅ๊ธฐ",
|
23 |
description="์ด๋ฏธ์ง๋ฅผ ์
๋ก๋ํ๋ฉด, ์ฌ๋ฌผ์ ์ธ์ํ๊ณ ์ต์์ 3๊ฐ์ ๋ถ๋ฅ ๊ฒฐ๊ณผ๋ฅผ ์ถ๋ ฅํฉ๋๋ค.")
|
24 |
|
25 |
+
# ์ธํฐํ์ด์ค ์คํ
|
26 |
+
iface.launch()
|
|