Spaces:
Running
Running
seawolf2357
commited on
Update app.py
Browse files
app.py
CHANGED
@@ -1,16 +1,11 @@
|
|
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 |
|
@@ -19,9 +14,8 @@ 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 |
|
|
|
1 |
import gradio as gr
|
2 |
from transformers import pipeline
|
3 |
from PIL import Image
|
|
|
4 |
|
5 |
# ์ด๋ฏธ์ง ์ธ์ ํ์ดํ๋ผ์ธ ๋ก๋
|
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 |
|
|
|
14 |
inputs=gr.Image(),
|
15 |
outputs=gr.Label(num_top_classes=3),
|
16 |
title="์ด๋ฏธ์ง ๋ถ๋ฅ๊ธฐ",
|
17 |
+
description="์ด๋ฏธ์ง๋ฅผ ์
๋ก๋ํ๋ฉด, ์ฌ๋ฌผ์ ์ธ์ํ๊ณ ์ต์์ 3๊ฐ์ ๋ถ๋ฅ ๊ฒฐ๊ณผ๋ฅผ ์ถ๋ ฅํฉ๋๋ค.")
|
|
|
18 |
|
19 |
+
# ์ธํฐํ์ด์ค ์คํ ๋ฐ ๊ณต๊ฐ ๋งํฌ ์์ฑ
|
20 |
+
iface.launch(share=True)
|
21 |
|