Questaaaa commited on
Commit
93ca441
·
verified ·
1 Parent(s): f2c5148

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +3 -3
app.py CHANGED
@@ -2,13 +2,13 @@ import gradio as gr
2
  from transformers import pipeline
3
 
4
  # 选择 Hugging Face 预训练模型
5
- classifier = pipeline("image-classification", model="microsoft/beit-base-patch16-224")
6
 
7
  # 定义分类函数
8
  def classify_image(image):
9
  predictions = classifier(image)
10
- return {pred["label"]: float(pred["score"]) for pred in predictions}
11
 
12
  # 创建 Gradio 界面
13
- demo = gr.Interface(fn=classify_image, inputs="image", outputs="label", title="Image Classification Demo")
14
  demo.launch()
 
2
  from transformers import pipeline
3
 
4
  # 选择 Hugging Face 预训练模型
5
+ classifier = pipeline("feature-extraction", model="facebook/deit-base-distilled-patch16-224")
6
 
7
  # 定义分类函数
8
  def classify_image(image):
9
  predictions = classifier(image)
10
+ return {"feature_vector": predictions[0]} # 返回特征向量
11
 
12
  # 创建 Gradio 界面
13
+ demo = gr.Interface(fn=classify_image, inputs="image", outputs="text", title="Image Classification Demo")
14
  demo.launch()