Nikeytas commited on
Commit
0c67a17
·
verified ·
1 Parent(s): 8af250c

Update model card with comprehensive documentation

Browse files
Files changed (1) hide show
  1. README.md +293 -185
README.md CHANGED
@@ -1,199 +1,307 @@
1
  ---
2
- library_name: transformers
3
- tags: []
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
4
  ---
5
 
6
- # Model Card for Model ID
7
 
8
- <!-- Provide a quick summary of what the model is/does. -->
9
 
 
 
 
 
 
10
 
 
11
 
12
- ## Model Details
 
 
13
 
14
- ### Model Description
15
 
16
- <!-- Provide a longer summary of what this model is. -->
17
 
18
- This is the model card of a 🤗 transformers model that has been pushed on the Hub. This model card has been automatically generated.
19
 
20
- - **Developed by:** [More Information Needed]
21
- - **Funded by [optional]:** [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
- ## Uses
37
-
38
- <!-- Address questions around how the model is intended to be used, including the foreseeable users of the model and those affected by the model. -->
39
-
40
- ### Direct Use
41
-
42
- <!-- This section is for the model use without fine-tuning or plugging into a larger ecosystem/app. -->
43
-
44
- [More Information Needed]
45
-
46
- ### Downstream Use [optional]
47
-
48
- <!-- This section is for the model use when fine-tuned for a task, or when plugged into a larger ecosystem/app -->
49
-
50
- [More Information Needed]
51
-
52
- ### Out-of-Scope Use
53
-
54
- <!-- This section addresses misuse, malicious use, and uses that the model will not work well for. -->
55
-
56
- [More Information Needed]
57
-
58
- ## Bias, Risks, and Limitations
59
-
60
- <!-- This section is meant to convey both technical and sociotechnical limitations. -->
61
-
62
- [More Information Needed]
63
-
64
- ### Recommendations
65
-
66
- <!-- This section is meant to convey recommendations with respect to the bias, risk, and technical limitations. -->
67
-
68
- Users (both direct and downstream) should be made aware of the risks, biases and limitations of the model. More information needed for further recommendations.
69
-
70
- ## How to Get Started with the Model
71
-
72
- Use the code below to get started with the model.
73
-
74
- [More Information Needed]
75
-
76
- ## Training Details
77
-
78
- ### Training Data
79
-
80
- <!-- This should link to a Dataset 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. -->
81
-
82
- [More Information Needed]
83
-
84
- ### Training Procedure
85
-
86
- <!-- This relates heavily to the Technical Specifications. Content here should link to that section when it is relevant to the training procedure. -->
87
-
88
- #### Preprocessing [optional]
89
-
90
- [More Information Needed]
91
-
92
-
93
- #### Training Hyperparameters
94
-
95
- - **Training regime:** [More Information Needed] <!--fp32, fp16 mixed precision, bf16 mixed precision, bf16 non-mixed precision, fp16 non-mixed precision, fp8 mixed precision -->
96
-
97
- #### Speeds, Sizes, Times [optional]
98
-
99
- <!-- This section provides information about throughput, start/end time, checkpoint size if relevant, etc. -->
100
-
101
- [More Information Needed]
102
-
103
- ## Evaluation
104
-
105
- <!-- This section describes the evaluation protocols and provides the results. -->
106
-
107
- ### Testing Data, Factors & Metrics
108
-
109
- #### Testing Data
110
-
111
- <!-- This should link to a Dataset Card if possible. -->
112
-
113
- [More Information Needed]
114
-
115
- #### Factors
116
-
117
- <!-- These are the things the evaluation is disaggregating by, e.g., subpopulations or domains. -->
118
-
119
- [More Information Needed]
120
-
121
- #### Metrics
122
-
123
- <!-- These are the evaluation metrics being used, ideally with a description of why. -->
124
-
125
- [More Information Needed]
126
-
127
- ### Results
128
-
129
- [More Information Needed]
130
-
131
- #### Summary
132
-
133
-
134
-
135
- ## Model Examination [optional]
136
-
137
- <!-- Relevant interpretability work for the model goes here -->
138
-
139
- [More Information Needed]
140
-
141
- ## Environmental Impact
142
-
143
- <!-- Total emissions (in grams of CO2eq) and additional considerations, such as electricity usage, go here. Edit the suggested text below accordingly -->
144
-
145
- 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).
146
-
147
- - **Hardware Type:** [More Information Needed]
148
- - **Hours used:** [More Information Needed]
149
- - **Cloud Provider:** [More Information Needed]
150
- - **Compute Region:** [More Information Needed]
151
- - **Carbon Emitted:** [More Information Needed]
152
-
153
- ## Technical Specifications [optional]
154
-
155
- ### Model Architecture and Objective
156
-
157
- [More Information Needed]
158
-
159
- ### Compute Infrastructure
160
-
161
- [More Information Needed]
162
-
163
- #### Hardware
164
-
165
- [More Information Needed]
166
-
167
- #### Software
168
-
169
- [More Information Needed]
170
-
171
- ## Citation [optional]
172
-
173
- <!-- If there is a paper or blog post introducing the model, the APA and Bibtex information for that should go in this section. -->
174
-
175
- **BibTeX:**
176
-
177
- [More Information Needed]
178
-
179
- **APA:**
180
-
181
- [More Information Needed]
182
-
183
- ## Glossary [optional]
184
-
185
- <!-- If relevant, include terms and calculations in this section that can help readers understand the model or model card. -->
186
-
187
- [More Information Needed]
188
-
189
- ## More Information [optional]
190
-
191
- [More Information Needed]
192
-
193
- ## Model Card Authors [optional]
194
-
195
- [More Information Needed]
196
-
197
- ## Model Card Contact
198
 
199
- [More Information Needed]
 
 
 
1
  ---
2
+ license: mit
3
+ base_model: MCG-NJU/videomae-base
4
+ tags:
5
+ - video-classification
6
+ - crime-detection
7
+ - violence-detection
8
+ - videomae
9
+ - computer-vision
10
+ - security
11
+ - surveillance
12
+ - generated_from_trainer
13
+ language:
14
+ - en
15
+ datasets:
16
+ - jinmang2/ucf_crime
17
+ metrics:
18
+ - accuracy
19
+ - precision
20
+ - recall
21
+ - f1
22
+ pipeline_tag: video-classification
23
+ model-index:
24
+ - name: test-upload-model
25
+ results:
26
+ - task:
27
+ name: Violence Detection
28
+ type: video-classification
29
+ dataset:
30
+ name: UCF Crime Dataset (Subset)
31
+ type: jinmang2/ucf_crime
32
+ args: violence_detection
33
+ metrics:
34
+ - name: Accuracy
35
+ type: accuracy
36
+ value: 0.5000
37
+ - name: Precision
38
+ type: precision
39
+ value: 0.2500
40
+ - name: Recall
41
+ type: recall
42
+ value: 0.5000
43
+ - name: F1
44
+ type: f1
45
+ value: 0.3333
46
  ---
47
 
48
+ # Nikeytas/Test Upload Model
49
 
50
+ This model is a fine-tuned version of [MCG-NJU/videomae-base](https://huggingface.co/MCG-NJU/videomae-base) on the UCF Crime dataset with **event-based binary classification**. It achieves the following results on the evaluation set:
51
 
52
+ - **Loss**: 0.5847
53
+ - **Accuracy**: 0.5000
54
+ - **Precision**: 0.2500
55
+ - **Recall**: 0.5000
56
+ - **F1 Score**: 0.3333
57
 
58
+ ## 🎯 Model Overview
59
 
60
+ This VideoMAE model has been fine-tuned for **binary violence detection** in video content. The model classifies videos into two categories:
61
+ - **Violent Crime** (1): Videos containing violent criminal activities
62
+ - **Non-Violent Incident** (0): Videos with non-violent or normal activities
63
 
64
+ The model is based on the **VideoMAE architecture** and has been specifically trained on a curated subset of the UCF Crime dataset with event-based categorization for realistic crime detection scenarios.
65
 
66
+ ## 📊 Dataset & Training
67
 
68
+ ### Dataset Composition
69
 
70
+ **Total Videos**: 20
71
+ - **Violent Crime Videos**: 10
72
+ - **Non-Violent Incident Videos**: 10
 
 
 
 
73
 
74
+ **Class Balance**: 50.0% violent crimes
75
+
76
+ **Event Distribution**:
77
+ - **Arrest**: 20 videos
78
+ - **Arson**: 20 videos
79
+
80
+ **Data Splits**:
81
+ - **Training**: 12 videos
82
+ - **Validation**: 4 videos
83
+ - **Test**: 4 videos
84
+
85
+ ## 🎯 Performance
86
+
87
+ ### Performance Metrics
88
+
89
+ **Validation Performance**:
90
+ - **eval_loss**: 0.5847
91
+ - **eval_accuracy**: 0.5000
92
+ - **eval_precision**: 0.2500
93
+ - **eval_recall**: 0.5000
94
+ - **eval_f1**: 0.3333
95
+ - **eval_runtime**: 0.6636
96
+ - **eval_samples_per_second**: 6.0270
97
+ - **eval_steps_per_second**: 3.0140
98
+ - **epoch**: 1.0000
99
+
100
+ **Test Performance**:
101
+ - **eval_loss**: 0.6700
102
+ - **eval_accuracy**: 0.5000
103
+ - **eval_precision**: 0.2500
104
+ - **eval_recall**: 0.5000
105
+ - **eval_f1**: 0.3333
106
+ - **eval_runtime**: 0.4271
107
+ - **eval_samples_per_second**: 9.3660
108
+ - **eval_steps_per_second**: 4.6830
109
+ - **epoch**: 1.0000
110
+
111
+ **Training Information**:
112
+ - **Training Time**: 0.1 minutes
113
+ - **Best Accuracy Achieved**: 0.5000
114
+ - **Model Architecture**: VideoMAE Base (fine-tuned)
115
+ - **Fine-tuning Approach**: Event-based binary classification
116
+
117
+ ## 🚀 Training Procedure
118
+
119
+ ### Training Hyperparameters
120
+
121
+ The following hyperparameters were used during training:
122
+ - **Learning Rate**: 5e-05
123
+ - **Train Batch Size**: 2
124
+ - **Eval Batch Size**: 2
125
+ - **Optimizer**: AdamW with betas=(0.9,0.999) and epsilon=1e-08
126
+ - **LR Scheduler Type**: Linear
127
+ - **Training Epochs**: 1
128
+ - **Weight Decay**: 0.01
129
+
130
+ ### Training Results
131
+
132
+ | Training Loss | Epoch | Step | Validation Loss | Accuracy |
133
+ |---------------|-------|------|-----------------|----------|
134
+ | 0.5 | 1.00 | N/A | 0.5847 | 0.5000 |
135
+
136
+ ### Framework Versions
137
+
138
+ - **Transformers**: 4.30.2+
139
+ - **PyTorch**: 2.0.1+
140
+ - **Datasets**: Latest
141
+ - **Device**: Apple Silicon MPS / CUDA / CPU (Auto-detected)
142
+
143
+ ## 🚀 Quick Start
144
+
145
+ ### Installation
146
+
147
+ ```bash
148
+ pip install transformers torch torchvision opencv-python pillow
149
+ ```
150
+
151
+ ### Basic Usage
152
+
153
+ ```python
154
+ import torch
155
+ from transformers import AutoModelForVideoClassification, AutoProcessor
156
+ import cv2
157
+ import numpy as np
158
+
159
+ # Load model and processor
160
+ model = AutoModelForVideoClassification.from_pretrained("Nikeytas/test-upload-model")
161
+ processor = AutoProcessor.from_pretrained("Nikeytas/test-upload-model")
162
+
163
+ # Process video
164
+ def classify_video(video_path, num_frames=16):
165
+ # Extract frames
166
+ cap = cv2.VideoCapture(video_path)
167
+ frames = []
168
+
169
+ total_frames = int(cap.get(cv2.CAP_PROP_FRAME_COUNT))
170
+ indices = np.linspace(0, total_frames - 1, num_frames, dtype=int)
171
+
172
+ for idx in indices:
173
+ cap.set(cv2.CAP_PROP_POS_FRAMES, idx)
174
+ ret, frame = cap.read()
175
+ if ret:
176
+ frame_rgb = cv2.cvtColor(frame, cv2.COLOR_BGR2RGB)
177
+ frames.append(frame_rgb)
178
+
179
+ cap.release()
180
+
181
+ # Process with model
182
+ inputs = processor(frames, return_tensors="pt")
183
+
184
+ with torch.no_grad():
185
+ outputs = model(**inputs)
186
+ predictions = torch.nn.functional.softmax(outputs.logits, dim=-1)
187
+ predicted_class = torch.argmax(predictions, dim=-1).item()
188
+ confidence = predictions[0][predicted_class].item()
189
+
190
+ label = "Violent Crime" if predicted_class == 1 else "Non-Violent"
191
+ return label, confidence
192
+
193
+ # Example usage
194
+ video_path = "path/to/your/video.mp4"
195
+ prediction, confidence = classify_video(video_path)
196
+ print(f"Prediction: {prediction} (Confidence: {confidence:.3f})")
197
+ ```
198
+
199
+ ### Batch Processing
200
+
201
+ ```python
202
+ import os
203
+ from pathlib import Path
204
+
205
+ def process_video_directory(video_dir, output_file="results.txt"):
206
+ results = []
207
+
208
+ for video_file in Path(video_dir).glob("*.mp4"):
209
+ try:
210
+ prediction, confidence = classify_video(str(video_file))
211
+ results.append({
212
+ "file": video_file.name,
213
+ "prediction": prediction,
214
+ "confidence": confidence
215
+ })
216
+ print(f"✅ {video_file.name}: {prediction} ({confidence:.3f})")
217
+ except Exception as e:
218
+ print(f"❌ Error processing {video_file.name}: {e}")
219
+
220
+ # Save results
221
+ with open(output_file, "w") as f:
222
+ for result in results:
223
+ f.write(f"{result['file']}: {result['prediction']} ({result['confidence']:.3f})\n")
224
+
225
+ return results
226
+
227
+ # Process all videos in a directory
228
+ results = process_video_directory("./videos/")
229
+ ```
230
+
231
+ ## 📈 Technical Specifications
232
+
233
+ - **Base Model**: MCG-NJU/videomae-base
234
+ - **Architecture**: Vision Transformer (ViT) adapted for video
235
+ - **Input Resolution**: 224x224 pixels per frame
236
+ - **Temporal Resolution**: 16 frames per video clip
237
+ - **Output Classes**: 2 (Binary classification)
238
+ - **Training Framework**: HuggingFace Transformers
239
+ - **Optimization**: AdamW optimizer with learning rate 5e-5
240
+
241
+ ## ⚠️ Limitations
242
+
243
+ 1. **Dataset Scope**: Trained on a subset of UCF Crime dataset - may not generalize to all types of violence
244
+ 2. **Temporal Context**: Uses 16-frame clips which may miss context in longer sequences
245
+ 3. **Environmental Bias**: Performance may vary with different lighting, camera angles, and video quality
246
+ 4. **False Positives**: May misclassify intense but non-violent activities (sports, action movies)
247
+ 5. **Real-time Performance**: Processing time depends on hardware capabilities
248
+
249
+ ## 🔒 Ethical Considerations
250
+
251
+ ### Intended Use
252
+ - **Primary**: Research and development in video analysis
253
+ - **Secondary**: Security system enhancement with human oversight
254
+ - **Educational**: Computer vision and AI safety research
255
+
256
+ ### Prohibited Uses
257
+ - **Surveillance without consent**: Do not use for unauthorized monitoring
258
+ - **Discriminatory profiling**: Avoid bias against specific groups or communities
259
+ - **Automated punishment**: Never use for automated legal or disciplinary actions
260
+ - **Privacy violation**: Respect privacy laws and individual rights
261
+
262
+ ### Bias and Fairness
263
+ - Model trained on specific dataset that may not represent all populations
264
+ - Regular evaluation needed for bias detection and mitigation
265
+ - Human oversight required for critical applications
266
+ - Consider demographic representation in deployment scenarios
267
+
268
+ ## 📝 Model Card Information
269
+
270
+ - **Developed by**: Research Team
271
+ - **Model Type**: Video Classification (Binary)
272
+ - **Training Data**: UCF Crime Dataset (Subset)
273
+ - **Training Date**: 2025-06-08 15:19:08 UTC
274
+ - **Evaluation Metrics**: Accuracy, Precision, Recall, F1-Score
275
+ - **Intended Users**: Researchers, Security Professionals, Developers
276
+
277
+ ## 📚 Citation
278
+
279
+ If you use this model in your research, please cite:
280
+
281
+ ```bibtex
282
+ @misc{Nikeytas_test_upload_model,
283
+ title={VideoMAE Fine-tuned for Crime Detection},
284
+ author={Research Team},
285
+ year={2024},
286
+ publisher={Hugging Face},
287
+ url={https://huggingface.co/Nikeytas/test-upload-model}
288
+ }
289
+ ```
290
+
291
+ ## 🤝 Contributing
292
+
293
+ We welcome contributions to improve the model! Please:
294
+ 1. Report issues with specific examples
295
+ 2. Suggest improvements for bias reduction
296
+ 3. Share evaluation results on new datasets
297
+ 4. Contribute to documentation and examples
298
+
299
+ ## 📞 Contact
300
+
301
+ For questions, issues, or collaboration opportunities, please open an issue in the model repository or contact the development team.
302
 
303
+ ---
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
304
 
305
+ *Last updated: 2025-06-08 15:19:08 UTC*
306
+ *Model version: 1.0*
307
+ *Framework: HuggingFace Transformers*