File size: 484 Bytes
0e4149c
 
 
 
93ca441
0e4149c
 
 
 
93ca441
0e4149c
 
93ca441
0e4149c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
import gradio as gr
from transformers import pipeline

# 选择 Hugging Face 预训练模型
classifier = pipeline("feature-extraction", model="facebook/deit-base-distilled-patch16-224")

# 定义分类函数
def classify_image(image):
    predictions = classifier(image)
    return {"feature_vector": predictions[0]}  # 返回特征向量

# 创建 Gradio 界面
demo = gr.Interface(fn=classify_image, inputs="image", outputs="text", title="Image Classification Demo")
demo.launch()