Update README.md
Browse files
README.md
CHANGED
@@ -1,227 +1,76 @@
|
|
1 |
---
|
2 |
-
|
3 |
-
|
4 |
-
|
|
|
|
|
5 |
---
|
6 |
|
7 |
-
# Model Card
|
|
|
8 |
|
9 |
-
This
|
|
|
10 |
|
11 |
-
|
12 |
|
13 |
-
## Model Details
|
14 |
|
15 |
-
###
|
16 |
-
|
17 |
-
<!-- Provide a longer summary of what this model is. -->
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
- **Developed by:** [More Information Needed]
|
22 |
-
- **Shared by [optional]:** [More Information Needed]
|
23 |
-
- **Model type:** [More Information Needed]
|
24 |
-
- **Language(s) (NLP):** [More Information Needed]
|
25 |
-
- **License:** [More Information Needed]
|
26 |
-
- **Finetuned from model [optional]:** [More Information Needed]
|
27 |
-
|
28 |
-
### Model Sources [optional]
|
29 |
-
|
30 |
-
<!-- Provide the basic links for the model. -->
|
31 |
-
|
32 |
-
- **Repository:** [More Information Needed]
|
33 |
-
- **Paper [optional]:** [More Information Needed]
|
34 |
-
- **Demo [optional]:** [More Information Needed]
|
35 |
-
|
36 |
-
## Use
|
37 |
-
To encode text:
|
38 |
|
39 |
```python
|
40 |
-
import torch
|
41 |
import numpy as np
|
|
|
42 |
from transformers import AutoTokenizer, CLIPTextModelWithProjection
|
43 |
|
44 |
-
search_sentence = "a woman drinking coffee looking at the sea"
|
45 |
|
46 |
-
|
|
|
|
|
47 |
tokenizer = AutoTokenizer.from_pretrained("Diangle/clip4clip-webvid")
|
48 |
|
49 |
|
50 |
inputs = tokenizer(text=search_sentence , return_tensors="pt", padding=True)
|
51 |
|
52 |
-
outputs =
|
53 |
-
|
54 |
-
|
|
|
55 |
text_embeds = outputs[1] @ text_projection
|
56 |
final_output = text_embeds[torch.arange(text_embeds.shape[0]), inputs["input_ids"].argmax(dim=-1)]
|
57 |
|
58 |
-
|
59 |
final_output = final_output / final_output.norm(dim=-1, keepdim=True)
|
60 |
final_output = final_output.cpu().detach().numpy()
|
61 |
sequence_output = final_output / np.sum(final_output**2, axis=1, keepdims=True)
|
62 |
-
print(sequence_output)
|
63 |
```
|
64 |
|
65 |
|
66 |
-
|
67 |
-
|
68 |
-
<!-- This section is for the model use without fine-tuning or plugging into a larger ecosystem/app. -->
|
69 |
-
|
70 |
-
[More Information Needed]
|
71 |
-
|
72 |
-
### Downstream Use [optional]
|
73 |
-
|
74 |
-
<!-- This section is for the model use when fine-tuned for a task, or when plugged into a larger ecosystem/app -->
|
75 |
-
|
76 |
-
[More Information Needed]
|
77 |
-
|
78 |
-
### Out-of-Scope Use
|
79 |
-
|
80 |
-
<!-- This section addresses misuse, malicious use, and uses that the model will not work well for. -->
|
81 |
-
|
82 |
-
[More Information Needed]
|
83 |
-
|
84 |
-
## Bias, Risks, and Limitations
|
85 |
-
|
86 |
-
<!-- This section is meant to convey both technical and sociotechnical limitations. -->
|
87 |
-
|
88 |
-
[More Information Needed]
|
89 |
-
|
90 |
-
### Recommendations
|
91 |
-
|
92 |
-
<!-- This section is meant to convey recommendations with respect to the bias, risk, and technical limitations. -->
|
93 |
-
|
94 |
-
Users (both direct and downstream) should be made aware of the risks, biases and limitations of the model. More information needed for further recommendations.
|
95 |
-
|
96 |
-
## How to Get Started with the Model
|
97 |
-
|
98 |
-
Use the code below to get started with the model.
|
99 |
-
|
100 |
-
[More Information Needed]
|
101 |
-
|
102 |
-
## Training Details
|
103 |
-
|
104 |
-
### Training Data
|
105 |
-
|
106 |
-
<!-- This should link to a Data Card, perhaps with a short stub of information on what the training data is all about as well as documentation related to data pre-processing or additional filtering. -->
|
107 |
-
|
108 |
-
[More Information Needed]
|
109 |
-
|
110 |
-
### Training Procedure
|
111 |
-
|
112 |
-
<!-- This relates heavily to the Technical Specifications. Content here should link to that section when it is relevant to the training procedure. -->
|
113 |
-
|
114 |
-
#### Preprocessing [optional]
|
115 |
-
|
116 |
-
[More Information Needed]
|
117 |
-
|
118 |
-
|
119 |
-
#### Training Hyperparameters
|
120 |
-
|
121 |
-
- **Training regime:** [More Information Needed] <!--fp32, fp16 mixed precision, bf16 mixed precision, bf16 non-mixed precision, fp16 non-mixed precision, fp8 mixed precision -->
|
122 |
-
|
123 |
-
#### Speeds, Sizes, Times [optional]
|
124 |
-
|
125 |
-
<!-- This section provides information about throughput, start/end time, checkpoint size if relevant, etc. -->
|
126 |
-
|
127 |
-
[More Information Needed]
|
128 |
-
|
129 |
-
## Evaluation
|
130 |
-
|
131 |
-
<!-- This section describes the evaluation protocols and provides the results. -->
|
132 |
-
|
133 |
-
### Testing Data, Factors & Metrics
|
134 |
-
|
135 |
-
#### Testing Data
|
136 |
-
|
137 |
-
<!-- This should link to a Data Card if possible. -->
|
138 |
-
|
139 |
-
[More Information Needed]
|
140 |
-
|
141 |
-
#### Factors
|
142 |
-
|
143 |
-
<!-- These are the things the evaluation is disaggregating by, e.g., subpopulations or domains. -->
|
144 |
-
|
145 |
-
[More Information Needed]
|
146 |
-
|
147 |
-
#### Metrics
|
148 |
-
|
149 |
-
<!-- These are the evaluation metrics being used, ideally with a description of why. -->
|
150 |
-
|
151 |
-
[More Information Needed]
|
152 |
-
|
153 |
-
### Results
|
154 |
-
|
155 |
-
[More Information Needed]
|
156 |
-
|
157 |
-
#### Summary
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
## Model Examination [optional]
|
162 |
-
|
163 |
-
<!-- Relevant interpretability work for the model goes here -->
|
164 |
-
|
165 |
-
[More Information Needed]
|
166 |
-
|
167 |
-
## Environmental Impact
|
168 |
-
|
169 |
-
<!-- Total emissions (in grams of CO2eq) and additional considerations, such as electricity usage, go here. Edit the suggested text below accordingly -->
|
170 |
-
|
171 |
-
Carbon emissions can be estimated using the [Machine Learning Impact calculator](https://mlco2.github.io/impact#compute) presented in [Lacoste et al. (2019)](https://arxiv.org/abs/1910.09700).
|
172 |
-
|
173 |
-
- **Hardware Type:** [More Information Needed]
|
174 |
-
- **Hours used:** [More Information Needed]
|
175 |
-
- **Cloud Provider:** [More Information Needed]
|
176 |
-
- **Compute Region:** [More Information Needed]
|
177 |
-
- **Carbon Emitted:** [More Information Needed]
|
178 |
-
|
179 |
-
## Technical Specifications [optional]
|
180 |
-
|
181 |
-
### Model Architecture and Objective
|
182 |
-
|
183 |
-
[More Information Needed]
|
184 |
-
|
185 |
-
### Compute Infrastructure
|
186 |
-
|
187 |
-
[More Information Needed]
|
188 |
-
|
189 |
-
#### Hardware
|
190 |
-
|
191 |
-
[More Information Needed]
|
192 |
-
|
193 |
-
#### Software
|
194 |
-
|
195 |
-
[More Information Needed]
|
196 |
-
|
197 |
-
## Citation [optional]
|
198 |
|
199 |
-
|
200 |
|
201 |
-
**
|
202 |
|
203 |
-
|
204 |
|
205 |
-
|
206 |
|
207 |
-
[More Information Needed]
|
208 |
|
209 |
-
## Glossary [optional]
|
210 |
|
211 |
-
|
212 |
|
213 |
-
|
214 |
|
215 |
-
|
216 |
|
217 |
-
[More Information Needed]
|
218 |
|
219 |
-
## Model Card Authors [optional]
|
220 |
|
221 |
-
|
222 |
|
223 |
-
## Model Card Contact
|
224 |
|
225 |
-
|
226 |
|
|
|
227 |
|
|
|
|
1 |
---
|
2 |
+
tags:
|
3 |
+
- vision
|
4 |
+
- clip
|
5 |
+
- clip4clip
|
6 |
+
- video
|
7 |
---
|
8 |
|
9 |
+
# Model Card
|
10 |
+
## Details
|
11 |
|
12 |
+
This model was trained via CLIP4Clip (a CLIP-based a CLIP-based video retrival method, based on this [paper](https://arxiv.org/pdf/2104.08860.pdf) and [code](https://github.com/ArrowLuo/CLIP4Clip).
|
13 |
+
This model was trained on 150k videos from the [WebVid Dataset](https://m-bain.github.io/webvid-dataset/) (a large-scale dataset of short videos with textual descriptions sourced from the web).
|
14 |
|
15 |
+
We adjucted the weights of the clip model we achieved from our training to the model implameted in [clip-vit-base-patch32](https://huggingface.co/openai/clip-vit-base-patch32) and added few changes for the last layers.
|
16 |
|
|
|
17 |
|
18 |
+
### Use with Transformers
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
19 |
|
20 |
```python
|
|
|
21 |
import numpy as np
|
22 |
+
import torch
|
23 |
from transformers import AutoTokenizer, CLIPTextModelWithProjection
|
24 |
|
|
|
25 |
|
26 |
+
search_sentence = "a basketball player performing a slam dunk"
|
27 |
+
|
28 |
+
model = CLIPTextModelWithProjection.from_pretrained("Diangle/clip4clip-webvid")
|
29 |
tokenizer = AutoTokenizer.from_pretrained("Diangle/clip4clip-webvid")
|
30 |
|
31 |
|
32 |
inputs = tokenizer(text=search_sentence , return_tensors="pt", padding=True)
|
33 |
|
34 |
+
outputs = model(input_ids=inputs["input_ids"], attention_mask=inputs["attention_mask"], return_dict=False)
|
35 |
+
|
36 |
+
# Adding special projection and changing last layers:
|
37 |
+
text_projection = model.state_dict()['text_projection.weight']
|
38 |
text_embeds = outputs[1] @ text_projection
|
39 |
final_output = text_embeds[torch.arange(text_embeds.shape[0]), inputs["input_ids"].argmax(dim=-1)]
|
40 |
|
41 |
+
# Normalizing the embeddings:
|
42 |
final_output = final_output / final_output.norm(dim=-1, keepdim=True)
|
43 |
final_output = final_output.cpu().detach().numpy()
|
44 |
sequence_output = final_output / np.sum(final_output**2, axis=1, keepdims=True)
|
45 |
+
print("sequence_output: ", sequence_output)
|
46 |
```
|
47 |
|
48 |
|
49 |
+
## Model Use
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
50 |
|
51 |
+
### Intended Use
|
52 |
|
53 |
+
This model is intended to use for video retrival, look for example **this space**.
|
54 |
|
55 |
+
### Extra Information
|
56 |
|
57 |
+
For video embedding there is an extra notebook that describes how to embedd videos.
|
58 |
|
|
|
59 |
|
|
|
60 |
|
61 |
+
## Performance and Limitations
|
62 |
|
63 |
+
### Performance
|
64 |
|
65 |
+
We have evaluated the performance
|
66 |
|
|
|
67 |
|
|
|
68 |
|
69 |
+
## Limitations
|
70 |
|
|
|
71 |
|
72 |
+
## Feedback
|
73 |
|
74 |
+
### Where to send questions or comments about the model
|
75 |
|
76 |
+
Please use [this Google Form](https://forms.gle/Uv7afRH5dvY34ZEs9)
|