mrzjy commited on
Commit
1843a9e
1 Parent(s): ff023ee

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +6 -8
README.md CHANGED
@@ -38,7 +38,7 @@ device = torch.device("cuda:0" if torch.cuda.is_available() else "cpu")
38
 
39
  # load checkpoint from local path
40
  # model_path = "path/to/open_clip_pytorch_model.bin"
41
- # model_name = "ViT-SO400M-14-SigLIP-384"
42
  # model, preprocess = create_model_from_pretrained(model_name=model_name, pretrained=model_path, device=device)
43
  # tokenizer = get_tokenizer(model_name)
44
 
@@ -64,18 +64,16 @@ with torch.autocast(device_type=device.type):
64
  with torch.no_grad():
65
  image_features = model.encode_image(image)
66
  text_features = model.encode_text(text)
67
- image_features = F.normalize(image_features, dim=-1)
68
- image_features = F.normalize(image_features, dim=-1)
69
- text_features = F.normalize(text_features, dim=-1)
70
- text_probs = torch.sigmoid(image_features @ text_features.T * model.logit_scale.exp() + model.logit_bias)
71
- scores = [f"{s:.3f}" for i, s in enumerate(text_probs.tolist()[0])]
72
- print(scores) # [0.016, 0.000, 0.001, 0.233]
73
  ```
74
 
75
  ## Model Card
76
  ### CLIP for GenshinImpact
77
 
78
- [CLIP model](https://huggingface.co/laion/CLIP-ViT-B-16-laion2B-s34B-b88K) further fine-tuned on 17k Genshin Impact English text-image pairs at resolution 384x384.
79
 
80
  ### Training data description
81
 
 
38
 
39
  # load checkpoint from local path
40
  # model_path = "path/to/open_clip_pytorch_model.bin"
41
+ # model_name = "ViT-B-16"
42
  # model, preprocess = create_model_from_pretrained(model_name=model_name, pretrained=model_path, device=device)
43
  # tokenizer = get_tokenizer(model_name)
44
 
 
64
  with torch.no_grad():
65
  image_features = model.encode_image(image)
66
  text_features = model.encode_text(text)
67
+ image_features /= image_features.norm(dim=-1, keepdim=True)
68
+ text_features /= text_features.norm(dim=-1, keepdim=True)
69
+ text_probs = (100.0 * image_features @ text_features.T).softmax(dim=-1)
70
+ print(text_probs) # [0.0319, 0.0062, 0.0012, 0.9608]
 
 
71
  ```
72
 
73
  ## Model Card
74
  ### CLIP for GenshinImpact
75
 
76
+ [CLIP-ViT-B-16-laion2B-s34B-b88K model](https://huggingface.co/laion/CLIP-ViT-B-16-laion2B-s34B-b88K) further fine-tuned on 17k Genshin Impact English text-image pairs at resolution 384x384.
77
 
78
  ### Training data description
79