Upload 2 files
Browse files- app.py +2 -2
- image_feature.py +6 -5
app.py
CHANGED
@@ -3,8 +3,8 @@ import image_feature as func
|
|
3 |
|
4 |
|
5 |
def work11(image1, image2):
|
6 |
-
return func.infer1(image1, image2)
|
7 |
-
|
8 |
|
9 |
|
10 |
# with gr.Blocks() as demo:
|
|
|
3 |
|
4 |
|
5 |
def work11(image1, image2):
|
6 |
+
# return func.infer1(image1, image2)
|
7 |
+
return func.infer3(image1, image2)
|
8 |
|
9 |
|
10 |
# with gr.Blocks() as demo:
|
image_feature.py
CHANGED
@@ -49,16 +49,17 @@ DEVICE = torch.device('cpu')
|
|
49 |
|
50 |
|
51 |
# 第二种方式推理图片相似度
|
52 |
-
|
53 |
-
|
54 |
-
processor = AutoImageProcessor.from_pretrained("chanhua/autotrain-izefx-v3qh0")
|
55 |
-
model = AutoModel.from_pretrained("chanhua/autotrain-izefx-v3qh0").to(DEVICE)
|
56 |
|
57 |
|
58 |
# tensor([0.6061], device='cuda:0', grad_fn=<SumBackward1>)
|
59 |
|
60 |
# pipe = pipeline(task="image-feature-extraction", model_name="google/vit-base-patch16-384", device=DEVICE, pool=True)
|
61 |
-
pipe = pipeline(task="image-feature-extraction", model_name="chanhua/autotrain-izefx-v3qh0", device=DEVICE, pool=True)
|
|
|
62 |
|
63 |
|
64 |
# 推理
|
|
|
49 |
|
50 |
|
51 |
# 第二种方式推理图片相似度
|
52 |
+
processor = AutoImageProcessor.from_pretrained("google/vit-base-patch16-224")
|
53 |
+
model = AutoModel.from_pretrained("google/vit-base-patch16-224").to(DEVICE)
|
54 |
+
# processor = AutoImageProcessor.from_pretrained("chanhua/autotrain-izefx-v3qh0")
|
55 |
+
# model = AutoModel.from_pretrained("chanhua/autotrain-izefx-v3qh0").to(DEVICE)
|
56 |
|
57 |
|
58 |
# tensor([0.6061], device='cuda:0', grad_fn=<SumBackward1>)
|
59 |
|
60 |
# pipe = pipeline(task="image-feature-extraction", model_name="google/vit-base-patch16-384", device=DEVICE, pool=True)
|
61 |
+
# pipe = pipeline(task="image-feature-extraction", model_name="chanhua/autotrain-izefx-v3qh0", device=DEVICE, pool=True)
|
62 |
+
pipe = pipeline(task="image-feature-extraction", model_name="google/vit-base-patch16-224", device=DEVICE, pool=True, revision="29e7a1e183")
|
63 |
|
64 |
|
65 |
# 推理
|