Update app.py
Browse files
app.py
CHANGED
@@ -2,13 +2,13 @@ import gradio as gr
|
|
2 |
from transformers import pipeline
|
3 |
|
4 |
# 选择 Hugging Face 预训练模型
|
5 |
-
classifier = pipeline("
|
6 |
|
7 |
# 定义分类函数
|
8 |
def classify_image(image):
|
9 |
predictions = classifier(image)
|
10 |
-
return {
|
11 |
|
12 |
# 创建 Gradio 界面
|
13 |
-
demo = gr.Interface(fn=classify_image, inputs="image", outputs="
|
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()
|