Browse Source

add img embedding.py

luojunhui 4 weeks ago
parent
commit
74ea9714bd
1 changed files with 7 additions and 4 deletions
  1. 7 4
      applications/clip_embedding/clip_model.py

+ 7 - 4
applications/clip_embedding/clip_model.py

@@ -22,10 +22,13 @@ try:
 except Exception:
     print("[warning] EVA-CLIP 没有预处理配置,使用默认参数构造 ImageProcessor")
     from transformers import CLIPImageProcessor
-    image_processor = CLIPImageProcessor(size={"shortest_edge": 224}, resample=3,
-                                         crop_size={"height": 224, "width": 224},
-                                         image_mean=[0.48145466, 0.4578275, 0.40821073],
-                                         image_std=[0.26862954, 0.26130258, 0.27577711])
+    image_processor = CLIPImageProcessor(
+        size={"shortest_edge": 448},  # 最短边 resize 到 448
+        resample=3,
+        crop_size={"height": 448, "width": 448},  # 中心裁剪 448×448
+        image_mean=[0.48145466, 0.4578275, 0.40821073],
+        image_std=[0.26862954, 0.26130258, 0.27577711]
+    )
 
 # 如果后续要做 text embedding,可以加 tokenizer
 tokenizer = AutoTokenizer.from_pretrained(MODEL_NAME)