itsluckysharma01 commited on
Commit
b0f51f8
·
1 Parent(s): 4ed7d03

Clean deployment

Browse files
Files changed (1) hide show
  1. README.md +0 -626
README.md CHANGED
@@ -9,629 +9,3 @@ short_description: AI-powered video surveillance system
9
  ---
10
 
11
  Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
12
-
13
- # 🎯 NETRA - AI Video Surveillance Web Application
14
-
15
- <div align="center">
16
-
17
- ### ⚡ **AI-Powered Video Surveillance & Real-Time Threat Detection**
18
-
19
- ![Status](https://img.shields.io/badge/Status-Active-brightgreen?style=flat-square)
20
- ![Python](https://img.shields.io/badge/Python-3.8%2B-blue?style=flat-square)
21
- ![Flask](https://img.shields.io/badge/Flask-Web-orange?style=flat-square)
22
- ![AI Models](https://img.shields.io/badge/AI%20Models-8%2F8-success?style=flat-square)
23
-
24
- </div>
25
-
26
- ---
27
-
28
- ![1779175689811](image/README/1779175689811.png)
29
-
30
- ## 🚀 Overview
31
-
32
- **NETRA** is a comprehensive web-based video surveillance system powered by advanced AI models that provides:
33
-
34
- ✅ **User Authentication** - Secure login/registration with SQLite database
35
- ✅ **Live Camera Monitoring** - Real-time video analysis with AI detection
36
- ✅ **Video Analysis** - Upload and analyze pre-recorded videos
37
- ✅ **Multi-Model Support** - 8 integrated AI models for comprehensive detection
38
- ✅ **Extensible Architecture** - Easy to add new AI models
39
- ✅ **100% Portable** - Works on any device, any path, any OS
40
-
41
- ## 📋 Key Features
42
-
43
- <table>
44
- <tr>
45
- <td width="50%">
46
-
47
- ### 🔐 **Authentication System**
48
-
49
- ```
50
- ✓ User registration & login
51
- ✓ Secure password hashing
52
- ✓ Session management
53
- ✓ SQLite database
54
- ```
55
-
56
- </td>
57
- <td width="50%">
58
-
59
- ### 🎥 **Live Camera Monitoring**
60
-
61
- ```
62
- ✓ Real-time webcam feed
63
- ✓ YOLOv8 object detection
64
- ✓ Violence recognition
65
- ✓ Instant alerts
66
- ✓ Live statistics
67
- ```
68
-
69
- </td>
70
- </tr>
71
- <tr>
72
- <td>
73
-
74
- ### 📹 **Video Analysis**
75
-
76
- ```
77
- ✓ Upload videos (500MB max)
78
- ✓ Batch frame processing
79
- ✓ Detailed reports
80
- ✓ Alert classification
81
- ```
82
-
83
- </td>
84
- <td>
85
-
86
- ### 🤖 **8 AI Models**
87
-
88
- ```
89
- ✓ Violence detection
90
- ✓ Weapon detection
91
- ✓ Pose analysis
92
- ✓ Object detection
93
- ✓ Activity recognition
94
- ```
95
-
96
- </td>
97
- </tr>
98
- </table>
99
-
100
- ## � AI Models
101
-
102
- ### Model Repository
103
-
104
- All AI models are hosted on **Hugging Face Hub** for free:
105
-
106
- 🔗 **[NETRA-Models on Hugging Face](https://huggingface.co/itsluckysharma01/NETRA-Models)**
107
-
108
- ### Models Available
109
-
110
- - 🎬 **Activity Recognition**: Violence/fight detection model (`violence_model.h5`)
111
- - 🔫 **Weapon Detection**: Detects guns, knives, and weapons (`best.pt`)
112
- - 👤 **Pose Detection**: Human body pose and movement analysis (`yolo11n-pose.pt`)
113
- - 📊 **Object Detection**: General object/person detection (`yolov8n.pt`)
114
- - 📈 **Analysis Models**: Multiple CNN models for advanced behavior analysis
115
-
116
- ### Auto-Download on Startup
117
-
118
- Models automatically download and cache locally on first run:
119
-
120
- ```bash
121
- python app.py # Models download automatically
122
- ```
123
-
124
- ### Storage Details
125
-
126
- - **Storage Location**: Hugging Face Hub (free)
127
- - **Total Size**: ~800MB
128
- - **First Run Download**: ~5-10 minutes (depending on internet speed)
129
- - **Subsequent Runs**: Instant (uses cached models)
130
- - **Local Cache**: `ai_models/` folder
131
-
132
- ## �🛠️ Installation
133
-
134
- ### Prerequisites
135
-
136
- - Python 3.8 or higher
137
- - Webcam (for live monitoring)
138
- - Windows/Linux/Mac OS
139
-
140
- ### Step 1: Clone or Navigate to Project
141
-
142
- ```bash
143
- cd f:/PROGRAMMING/MY PROJECTS/ALL_PROJECTS/Collabration_Projects/NETRA/NETRA_Project/webapp
144
- ```
145
-
146
- ### Step 2: Create Virtual Environment
147
-
148
- ```bash
149
- # Step 1: Create virtual environment
150
- python -m venv venv
151
-
152
- # Step 2: Activate it
153
- # Windows:
154
- venv\Scripts\activate
155
- # Linux/Mac:
156
- source venv/bin/activate
157
-
158
- # Step 3: Install dependencies
159
- pip install -r requirements.txt
160
-
161
- # Step 4: Verify setup
162
- python verify_setup.py
163
-
164
- # Step 5: Run application
165
- python app.py
166
- ```
167
-
168
- ```bash
169
- python -m venv venv
170
-
171
- # Windows
172
- venv\Scripts\activate
173
-
174
- # Linux/Mac
175
- source venv/bin/activate
176
- ```
177
-
178
- ### Step 3: Install Dependencies
179
-
180
- ```bash
181
- pip install -r requirements.txt
182
- ```
183
-
184
- ### Step 4: Setup Directory Structure
185
-
186
- The application expects the following structure:
187
-
188
- ```
189
- NETRA_Project/
190
- ├── webapp/
191
- │ ├── app.py
192
- │ ├── requirements.txt
193
- │ ├── static/
194
- │ │ ├── css/
195
- │ │ ├── js/
196
- │ │ └── images/
197
- │ ├── templates/
198
- │ └── uploads/
199
- ├── NETRA/
200
- │ ├── violence_detector.py
201
- │ ├── yolo_detector.py
202
- │ ├── yolov8n.pt
203
- │ └── model/
204
- └── ai_models/
205
- ├── activity_recognition/
206
- │ └── violence_model.h5
207
- └── object_detection/
208
- └── yolov8n.pt
209
- ```
210
-
211
- ## 🚀 Running the Application
212
-
213
- ### ⚡ Quick Start (3 Steps)
214
-
215
- #### Step 1️⃣ Navigate to Project
216
-
217
- ```bash
218
- cd NETRA-Project/webapp
219
- ```
220
-
221
- #### Step 2️⃣ Activate Virtual Environment
222
-
223
- ```bash
224
- # Windows
225
- venv\Scripts\activate
226
-
227
- # Linux/Mac
228
- source venv/bin/activate
229
- ```
230
-
231
- #### Step 3️⃣ Start the Server
232
-
233
- ```bash
234
- python app.py
235
- ```
236
-
237
- ### 🎉 Success! You'll See
238
-
239
- ```
240
- ╔═════════════���════════════════════════════════════════════════════╗
241
- ║ NETRA - AI Video Surveillance System ║
242
- ╚══════════════════════════════════════════════════════════════════╝
243
-
244
- 📊 Available Models: [violence, yolo, weapon, pose, ...]
245
-
246
- 🌐 Access Application:
247
- → http://localhost:5001
248
- → http://127.0.0.1:5001
249
-
250
- ⚙️ Configuration:
251
- → Debug Mode: ON
252
- → Port: 5001
253
- → Host: 0.0.0.0
254
-
255
- ✅ Server is RUNNING
256
- Press CTRL+C to stop
257
- ```
258
-
259
- ### 🌐 Open in Browser
260
-
261
- | Step | Action |
262
- | ---- | ------------------------------------------- |
263
- | 1️⃣ | Open **Chrome**, **Firefox**, or **Safari** |
264
- | 2️⃣ | Navigate to **http://localhost:5001** |
265
- | 3️⃣ | Click **"Sign Up"** to create account |
266
- | 4️⃣ | Enter username, email, password (6+ chars) |
267
- | 5️⃣ | Click **"Login"** with your credentials |
268
- | 6️⃣ | Access **Dashboard** and start monitoring! |
269
-
270
- ## 📖 Usage Guide - Interactive Walkthrough
271
-
272
- ### 🔐 Step 1: Registration
273
-
274
- ```
275
- Dashboard → Sign Up Tab
276
-
277
- Enter Username (any name)
278
- Enter Email (valid email)
279
- Enter Password (6+ characters)
280
-
281
- Click "Sign Up"
282
-
283
- ✅ Redirected to Login
284
- ```
285
-
286
- **Requirements:**
287
-
288
- - ✓ Username: Any name (5+ chars recommended)
289
- - ✓ Email: Valid email address
290
- - ✓ Password: Minimum 6 characters
291
-
292
- ### 🔑 Step 2: Login
293
-
294
- ```
295
- Login Page
296
-
297
- Enter Credentials
298
-
299
- Click "Login"
300
-
301
- ✅ Dashboard Loaded
302
- ```
303
-
304
- ### 📊 Step 3: Dashboard Overview
305
-
306
- After login, you'll see:
307
-
308
- | Feature | Description | Icon |
309
- | ------------------ | ------------------------------------ | ---- |
310
- | **Live Camera** | Real-time monitoring from webcam | 🎥 |
311
- | **Video Analysis** | Upload & analyze pre-recorded videos | 📹 |
312
- | **Results** | View detection results & alerts | 📊 |
313
-
314
- ### 🎥 Step 4: Live Camera Monitoring
315
-
316
- ```
317
- Dashboard
318
-
319
- Click "Start Live Monitoring"
320
-
321
- Allow Camera Permission (browser prompt)
322
-
323
- Real-Time Detection Begins
324
- ├── Object Detection (YOLOv8)
325
- ├── Violence Detection
326
- ├── Weapon Detection
327
- └── Pose Analysis
328
-
329
- View Results in Right Panel
330
- ├── Detections count
331
- ├── Alerts
332
- └── Confidence scores
333
-
334
- Click "Stop Camera" when done
335
- ```
336
-
337
- ### 📹 Step 5: Video Analysis
338
-
339
- ```
340
- Dashboard
341
-
342
- Click "Analyze Video"
343
-
344
- Upload Video File (drag & drop or click)
345
- ├── Supported formats: MP4, AVI, MOV, MKV
346
- └── Max size: 500MB
347
-
348
- Click "Analyze Video"
349
-
350
- ⏳ Processing (shows progress bar)
351
-
352
- ✅ Results Ready
353
- ├── Total Frames Processed
354
- ├── Detection by Category
355
- ├── Alerts & Severity
356
- └── Summary Statistics
357
- ```
358
-
359
- ### 📈 Step 6: Understanding Results
360
-
361
- **Detection Results Show:**
362
-
363
- - 🎯 **Objects Detected**: People, vehicles, weapons
364
- - ⚠️ **Alerts**: Unusual activities flagged
365
- - 📊 **Statistics**: Frame analysis summary
366
- - 🔔 **Severity Levels**: High, Medium, Low
367
-
368
- ## 🔧 Adding New Models
369
-
370
- The application is designed to be extensible. To add a new AI model:
371
-
372
- ### 1. Create Your Model Class
373
-
374
- ```python
375
- # my_custom_model.py
376
- class CustomDetector:
377
- def __init__(self, model_path):
378
- # Load your model
379
- pass
380
-
381
- def detect(self, frame):
382
- # Process frame and return detections
383
- pass
384
- ```
385
-
386
- ### 2. Register in ModelManager
387
-
388
- Edit `app.py` and add to the `ModelManager.load_models()` method:
389
-
390
- ```python
391
- def load_models(self):
392
- # Existing models...
393
-
394
- # Add your custom model
395
- try:
396
- from my_custom_model import CustomDetector
397
- custom_model_path = Path(__file__).parent.parent / "models" / "custom_model.h5"
398
- if custom_model_path.exists():
399
- self.models['custom'] = CustomDetector(str(custom_model_path))
400
- print("✓ Custom model loaded")
401
- except Exception as e:
402
- print(f"✗ Error loading custom model: {e}")
403
- ```
404
-
405
- ### 3. Integrate in VideoProcessor
406
-
407
- Add detection logic in `VideoProcessor.process_frame()`:
408
-
409
- ```python
410
- # Custom Model Detection
411
- if 'custom' in model_manager.models:
412
- try:
413
- custom_model = model_manager.get_model('custom')
414
- custom_results = custom_model.detect(frame)
415
- # Process results...
416
- except Exception as e:
417
- print(f"Custom detection error: {e}")
418
- ```
419
-
420
- ## 📊 Database Schema
421
-
422
- ### Users Table
423
-
424
- ```sql
425
- CREATE TABLE user (
426
- id INTEGER PRIMARY KEY,
427
- username VARCHAR(80) UNIQUE NOT NULL,
428
- email VARCHAR(120) UNIQUE NOT NULL,
429
- password_hash VARCHAR(200) NOT NULL,
430
- created_at DATETIME DEFAULT CURRENT_TIMESTAMP
431
- );
432
- ```
433
-
434
- ### Analysis History Table
435
-
436
- ```sql
437
- CREATE TABLE analysis_history (
438
- id INTEGER PRIMARY KEY,
439
- user_id INTEGER NOT NULL,
440
- analysis_type VARCHAR(50) NOT NULL,
441
- filename VARCHAR(200),
442
- detections TEXT,
443
- alert_count INTEGER DEFAULT 0,
444
- created_at DATETIME DEFAULT CURRENT_TIMESTAMP,
445
- FOREIGN KEY (user_id) REFERENCES user(id)
446
- );
447
- ```
448
-
449
- ## 🎨 Customization
450
-
451
- ### Logo
452
-
453
- Replace the logo by adding your image file:
454
-
455
- ```
456
- webapp/static/images/logo.png
457
- ```
458
-
459
- ### Colors and Styling
460
-
461
- Edit `webapp/static/css/style.css` to customize:
462
-
463
- - Primary color: `--primary-color`
464
- - Background gradients
465
- - Card styles
466
- - Animations
467
-
468
- ### Alert Thresholds
469
-
470
- Modify detection thresholds in `app.py`:
471
-
472
- ```python
473
- # Example: Adjust confidence threshold
474
- if det.confidence > 0.75: # Changed from default
475
- # Process detection
476
- ```
477
-
478
- ## 🔒 Security Notes
479
-
480
- ### Current Implementation
481
-
482
- - Password hashing using Werkzeug
483
- - Session-based authentication
484
- - CSRF protection recommended for production
485
-
486
- ### Production Recommendations
487
-
488
- 1. Change the SECRET_KEY in app.py
489
- 2. Use environment variables for sensitive data
490
- 3. Enable HTTPS
491
- 4. Add rate limiting
492
- 5. Implement CSRF tokens
493
- 6. Use stronger session management
494
-
495
- ## 🐛 Troubleshooting
496
-
497
- ### Camera Not Working
498
-
499
- - Check if camera is connected
500
- - Grant browser camera permissions
501
- - Ensure no other application is using the camera
502
- - Try restarting the application
503
-
504
- ### Models Not Loading
505
-
506
- - Verify model files exist in correct paths
507
- - Check file permissions
508
- - Review console output for error messages
509
- - Ensure all dependencies are installed
510
-
511
- ### Upload Fails
512
-
513
- - Check file size (max 500MB)
514
- - Verify file format (MP4, AVI, MOV, MKV)
515
- - Ensure `uploads/` folder exists
516
- - Check disk space
517
-
518
- ### Database Errors
519
-
520
- - Delete `netra.db` and restart to recreate
521
- - Check file permissions
522
- - Ensure SQLite is properly installed
523
-
524
- ## 📝 API Endpoints
525
-
526
- | Endpoint | Method | Description |
527
- | ----------------- | ------ | ------------------------- |
528
- | `/` | GET | Landing page |
529
- | `/register` | POST | User registration |
530
- | `/login` | POST | User login |
531
- | `/logout` | GET | User logout |
532
- | `/dashboard` | GET | Main dashboard |
533
- | `/live-camera` | GET | Live camera page |
534
- | `/video-analysis` | GET | Video analysis page |
535
- | `/camera_feed` | GET | Camera stream |
536
- | `/upload_video` | POST | Upload video for analysis |
537
- | `/api/models` | GET | List available models |
538
- | `/stop_camera` | POST | Stop camera stream |
539
-
540
- ## 🤝 Contributing
541
-
542
- To contribute to this project:
543
-
544
- 1. Fork the repository
545
- 2. Create a feature branch
546
- 3. Make your changes
547
- 4. Test thoroughly
548
- 5. Submit a pull request
549
-
550
- ## 📄 License
551
-
552
- See [LICENSE](LICENSE) file for details.
553
-
554
- ## 👥 Support & Help
555
-
556
- ### 🆘 Getting Help
557
-
558
- | Problem | Solution |
559
- | ---------------------------- | -------------------------------------------------------------------------- |
560
- | **Server won't start** | Check Python version (3.8+), virtual env activated, dependencies installed |
561
- | **Models not downloading** | Check internet connection, HuggingFace Hub access |
562
- | **Camera not working** | Grant browser camera permissions, check webcam compatibility |
563
- | **Port 5001 already in use** | Change port in app.py or close other applications |
564
-
565
- ### 🐛 Reporting Issues
566
-
567
- 1. **Check existing issues** on GitHub
568
- 2. **Provide details:**
569
- - Your OS (Windows/Linux/Mac)
570
- - Python version: `python --version`
571
- - Error message from terminal
572
- - Steps to reproduce
573
-
574
- 3. **Create issue** with clear title and description
575
-
576
- ### 📖 Documentation
577
-
578
- - 📁 [PORTABLE_SETUP.md](PORTABLE_SETUP.md) - How portability works
579
- - 🏗️ [ARCHITECTURE.md](docs/ARCHITECTURE.md) - System architecture
580
- - 🚀 [Quick Start Guide](docs/QUICK_START_BOUNDING_BOXES.md)
581
-
582
- ## 🎯 Future Enhancements
583
-
584
- **Planned Features:**
585
-
586
- | Feature | Status | Priority |
587
- | ---------------------------- | ---------- | -------- |
588
- | Multi-camera support | 🔄 Planned | High |
589
- | Cloud storage integration | 🔄 Planned | High |
590
- | Email/SMS alerts | 🔄 Planned | Medium |
591
- | Advanced analytics dashboard | 🔄 Planned | Medium |
592
- | Mobile app (iOS/Android) | 📋 Backlog | Low |
593
- | Face recognition | 📋 Backlog | Low |
594
- | License plate detection | 📋 Backlog | Low |
595
- | PDF report export | 📋 Backlog | Low |
596
- | Scheduled recording | 📋 Backlog | Low |
597
- | Motion detection zones | 📋 Backlog | Low |
598
-
599
- ---
600
-
601
- ## 🔗 Quick Links
602
-
603
- <div align="center">
604
-
605
- | 🤖 | 📚 | 💬 | 🎯 |
606
- | ----------------------------------------------------------------- | ---------------------- | ---------------------- | -------------------------------- |
607
- | [HF Models](https://huggingface.co/itsluckysharma01/NETRA-Models) | [Documentation](docs/) | [Issues](../../issues) | [Roadmap](#-future-enhancements) |
608
-
609
- </div>
610
-
611
- ---
612
-
613
- ## 📊 Project Statistics
614
-
615
- ```
616
- 📁 Files: 50+
617
- 📦 Dependencies: 15+
618
- 🤖 AI Models: 8
619
- 💾 Database: SQLite
620
- 📊 Framework: Flask
621
- 🐍 Language: Python 3.8+
622
- ```
623
-
624
- ---
625
-
626
- <div align="center">
627
-
628
- ### ⭐ If you find NETRA useful, please give it a star!
629
-
630
- **NETRA** - AI-Powered Video Surveillance System
631
- **Version:** 1.0.0
632
- **Status:** 🟢 Active & Maintained
633
- **Last Updated:** 2026
634
-
635
- Made with ❤️ for security & surveillance
636
-
637
- </div>
 
9
  ---
10
 
11
  Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference