seawolf2357 commited on
Commit
3ec95cb
ยท
verified ยท
1 Parent(s): 9902a40

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +3 -9
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