Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -1,19 +1,27 @@
|
|
1 |
import gradio as gr
|
2 |
from transformers import pipeline
|
|
|
|
|
3 |
|
4 |
-
# ์ด๋ฏธ์ง ์ธ์ ํ์ดํ๋ผ์ธ
|
5 |
model = pipeline("image-classification", model="google/vit-base-patch16-224")
|
6 |
|
7 |
-
def classify_image(
|
8 |
-
|
|
|
|
|
|
|
|
|
9 |
return {prediction['label']: prediction['score'] for prediction in predictions}
|
10 |
|
11 |
-
# Gradio ์ธํฐํ์ด์ค ์์ฑ
|
12 |
iface = gr.Interface(fn=classify_image,
|
13 |
inputs=gr.Image(),
|
14 |
outputs=gr.Label(num_top_classes=3),
|
15 |
title="์ด๋ฏธ์ง ๋ถ๋ฅ๊ธฐ",
|
16 |
-
description="์ด๋ฏธ์ง๋ฅผ ์
๋ก๋ํ๋ฉด, ์ฌ๋ฌผ์ ์ธ์ํ๊ณ ์ต์์ 3๊ฐ์ ๋ถ๋ฅ ๊ฒฐ๊ณผ๋ฅผ ์ถ๋ ฅํฉ๋๋ค."
|
|
|
17 |
|
18 |
# ์ธํฐํ์ด์ค ์คํ
|
19 |
iface.launch()
|
|
|
|
1 |
import gradio as gr
|
2 |
from transformers import pipeline
|
3 |
+
from PIL import Image
|
4 |
+
import io
|
5 |
|
6 |
+
# ์ด๋ฏธ์ง ์ธ์ ํ์ดํ๋ผ์ธ ๋ก๋
|
7 |
model = pipeline("image-classification", model="google/vit-base-patch16-224")
|
8 |
|
9 |
+
def classify_image(uploaded_image):
|
10 |
+
# ์
๋ก๋๋ ์ด๋ฏธ์ง๊ฐ PIL ์ด๋ฏธ์ง ๊ฐ์ฒด์ธ์ง ํ์ธ (Gradio๋ ์๋์ผ๋ก PIL ์ด๋ฏธ์ง ๊ฐ์ฒด๋ก ๋ณํ)
|
11 |
+
if not isinstance(uploaded_image, Image.Image):
|
12 |
+
raise ValueError("Uploaded image is not in the correct format.")
|
13 |
+
|
14 |
+
predictions = model(uploaded_image)
|
15 |
return {prediction['label']: prediction['score'] for prediction in predictions}
|
16 |
|
17 |
+
# Gradio ์ธํฐํ์ด์ค ์์ฑ
|
18 |
iface = gr.Interface(fn=classify_image,
|
19 |
inputs=gr.Image(),
|
20 |
outputs=gr.Label(num_top_classes=3),
|
21 |
title="์ด๋ฏธ์ง ๋ถ๋ฅ๊ธฐ",
|
22 |
+
description="์ด๋ฏธ์ง๋ฅผ ์
๋ก๋ํ๋ฉด, ์ฌ๋ฌผ์ ์ธ์ํ๊ณ ์ต์์ 3๊ฐ์ ๋ถ๋ฅ ๊ฒฐ๊ณผ๋ฅผ ์ถ๋ ฅํฉ๋๋ค.",
|
23 |
+
share=True) # Public link ์์ฑ
|
24 |
|
25 |
# ์ธํฐํ์ด์ค ์คํ
|
26 |
iface.launch()
|
27 |
+
|