import gradio as gr from transformers import pipeline # 이미지 인식 파이프라인 로드, 모델을 명시적으로 지정 model = pipeline("image-classification", model="google/vit-base-patch16-224") def classify_image(image): predictions = model(image) return {prediction['label']: prediction['score'] for prediction in predictions} # Gradio 인터페이스 생성 (shape 인자 없이) iface = gr.Interface(fn=classify_image, inputs=gr.Image(), outputs=gr.Label(num_top_classes=3), title="이미지 분류기", description="이미지를 업로드하면, 사물을 인식하고 최상위 3개의 분류 결과를 출력합니다.") # 인터페이스 실행 iface.launch()