blockenters commited on
Commit
cfd2263
·
1 Parent(s): 34f71e3
Files changed (2) hide show
  1. app.py +25 -0
  2. requirements.txt +4 -0
app.py ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ from transformers import pipeline
3
+ from PIL import Image
4
+
5
+ # 1. 사전학습된 이미지 분류 파이프라인 로드
6
+ classifier = pipeline("image-classification", model="google/vit-base-patch16-224")
7
+
8
+ # 2. Streamlit UI 구성
9
+ st.title("이미지 분류 데모")
10
+ st.write("Hugging Face의 Vision Transformer(ViT) 모델을 사용해 이미지 분류를 시도합니다.")
11
+
12
+ uploaded_file = st.file_uploader("이미지를 업로드해주세요", type=["png", "jpg", "jpeg"])
13
+
14
+ if uploaded_file is not None:
15
+ # 3. 이미지 열기
16
+ image = Image.open(uploaded_file)
17
+ st.image(image, caption="업로드한 이미지")
18
+
19
+ # 4. 분류 실행
20
+ results = classifier(image)
21
+
22
+ # 5. 결과 표시
23
+ st.write("## 예측 결과")
24
+ for result in results:
25
+ st.write(f"**{result['label']}**: {result['score']:.4f}")
requirements.txt ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
1
+ streamlit
2
+ transformers
3
+ torch
4
+ Pillow