Amitz244 commited on
Commit
340b294
·
verified ·
1 Parent(s): 895c691

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +21 -6
README.md CHANGED
@@ -11,8 +11,9 @@ tags:
11
  - LaMem
12
  - THINGS
13
  ---
14
-
15
- PreceptCLIP-Memorability is a model designed to predict image memorability (the likelihood of an image to be remembered). This is the official model from the paper ["Don't Judge Before You CLIP: A Unified Approach for Perceptual Tasks"](https://arxiv.org/abs/2503.13260). We apply LoRA adaptation on the CLIP visual encoder with an additional MLP head. Our model *achieves state-of-the-art results*.
 
16
 
17
  ## Training Details
18
 
@@ -23,7 +24,9 @@ PreceptCLIP-Memorability is a model designed to predict image memorability (the
23
  - *Learning Rate*: 5e-05
24
  - *Batch Size*: 32
25
 
26
- ## Requirements
 
 
27
  - python=3.9.15
28
  - cudatoolkit=11.7
29
  - torchvision=0.14.0
@@ -39,12 +42,24 @@ from torchvision import transforms
39
  import torch
40
  from PIL import Image
41
  from huggingface_hub import hf_hub_download
 
 
42
  device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
43
 
44
- # Load model
45
- model_path = hf_hub_download(repo_id="PerceptCLIP/PerceptCLIP_Memorability", filename="perceptCLIP_Memorability.pth")
46
- model = torch.load(model_path).to(device).eval()
 
 
 
 
 
 
47
 
 
 
 
 
48
  # Load an image
49
  image = Image.open("image_path.jpg").convert("RGB")
50
 
 
11
  - LaMem
12
  - THINGS
13
  ---
14
+ **PerceptCLIP-Memorability** is a model designed to predict the **image memorability** (the likelihood of an image to be remembered). This is the official model from the paper:
15
+ 📄 **["Don't Judge Before You CLIP: A Unified Approach for Perceptual Tasks"](https://arxiv.org/abs/2503.13260)**.
16
+ We apply **LoRA adaptation** on the **CLIP visual encoder** and add an **MLP head** for emotion classification. Our model achieves **state-of-the-art results**.
17
 
18
  ## Training Details
19
 
 
24
  - *Learning Rate*: 5e-05
25
  - *Batch Size*: 32
26
 
27
+ ## Installation & Requirements
28
+
29
+ You can set up the environment using environment.yml or manually install dependencies:
30
  - python=3.9.15
31
  - cudatoolkit=11.7
32
  - torchvision=0.14.0
 
42
  import torch
43
  from PIL import Image
44
  from huggingface_hub import hf_hub_download
45
+ import importlib.util
46
+
47
  device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
48
 
49
+ # Load the model class definition dynamically
50
+ class_path = hf_hub_download(repo_id="PerceptCLIP/PerceptCLIP_Memorability", filename="modeling.py")
51
+ spec = importlib.util.spec_from_file_location("modeling", class_path)
52
+ modeling = importlib.util.module_from_spec(spec)
53
+ spec.loader.exec_module(modeling)
54
+
55
+ # initialize a model
56
+ ModelClass = modeling.clip_lora_model
57
+ model = ModelClass().to(device)
58
 
59
+ # Load pretrained model
60
+ model_path = hf_hub_download(repo_id="PerceptCLIP/PerceptCLIP_Memorability", filename="perceptCLIP_Memorability.pth")
61
+ model.load_state_dict(torch.load(model_path, map_location=device))
62
+ model.eval()
63
  # Load an image
64
  image = Image.open("image_path.jpg").convert("RGB")
65