File size: 6,250 Bytes
cb3c674
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
# NETRA Project - Duplicate Folders & Merge Analysis

**Critical Finding:** Your project has **2 duplicate model directories** that need consolidation!

---

## πŸ”΄ CRITICAL: `models/` vs `ai_models/` (DUPLICATE FOLDERS)



### Current Status:

- **`config/model_config.py` uses:** `MODELS_DIR = PROJECT_ROOT / "models"` (Line 11)

- **But app.py expects models in:** Both directories have duplicates



### Directory Structure Comparison:



| Subdirectory | `models/` | `ai_models/` | Both Have |
|--------------|-----------|--------------|-----------|
| `object_detection/` | βœ… `yolov8n.pt` | βœ… `yolov8n.pt` | **DUPLICATE** |
| `pose_detection/` | ❓ Empty or file | βœ… `yolo11n-pose.pt` | Possible |
| `weapon_detection/` | ? | βœ… `best.pt` | ? |
| `anomaly_detection/` | 🟑 Empty | 🟑 Empty | Both Empty |
| `violence_detection/` | ? | ? | ? |

### Problem:
```python

# config/model_config.py points to "models/" directory:

MODELS_DIR = PROJECT_ROOT / "models"



MODEL_PATHS = {

    'yolo': {

        'candidates': [

            MODELS_DIR / "object_detection" / "yolov8n.pt",

            MODELS_DIR / "object_detection" / "yolov8s.pt",

        ],

    },

}

```

**BUT:** If actual model files are in `ai_models/`, the app won't find them!

---

## βœ… SOLUTION: Consolidate to Single Model Directory

### RECOMMENDED APPROACH:

**Option 1: Keep `ai_models/` as Primary (RECOMMENDED)**

```

Why: Name is more descriptive, common practice is "ai_models" in ML projects

Action:

  1. Update config/model_config.py line 11:

     - FROM: MODELS_DIR = PROJECT_ROOT / "models"

     - TO:   MODELS_DIR = PROJECT_ROOT / "ai_models"

  

  2. Delete "models/" directory entirely

  

  3. Verify all model files are in ai_models/ subdirectories

```



**Option 2: Keep `models/` as Primary (ALTERNATIVE)**

```

Why: Already configured in code

Action:

  1. Copy all files from ai_models/ to models/

  2. Delete ai_models/ directory

  3. Keep config/model_config.py unchanged

```



---



## πŸ“Š Code Folder Duplicates (Already Identified)



### 1️⃣ **`NETRA/` vs `src/` (CODE DUPLICATES)**

**Status:** ❌ NETRA/ NOT USED | βœ… src/ IS USED

**What can be merged:**
- Both contain identical detector implementations
- `src/` is the new structure that app.py actually imports from
- `NETRA/` should be deleted entirely (already in previous cleanup list)

---

### 2️⃣ **`detection logic/` vs `src/detectors/` (CODE DUPLICATES)**

**Status:** ❌ `detection logic/` NOT USED | βœ… `src/detectors/` IS USED

**Example - Pose Detection:**
- `detection logic/pose_detection.py` (OLD - unused)
- `src/detectors/pose_detector.py` (NEW - used by app.py)

**What can be merged:**
- Delete `detection logic/` entirely

---

## 🎯 Summary: All Duplicates & Merges Needed

| Folder 1 | Folder 2 | Status | Action |
|----------|----------|--------|--------|
| `models/` | `ai_models/` | ⚠️ CRITICAL - Duplicate model files | **MERGE: Pick one, delete other** |
| `NETRA/` | `src/` | ❌ NETRA unused | **DELETE: NETRA/** |
| `detection logic/` | `src/detectors/` | ❌ detection logic/ unused | **DELETE: detection logic/** |

---

## πŸš€ Recommended Consolidation Steps

### STEP 1: Fix Model Directories (CRITICAL - Do First)
```bash

# Option 1: Consolidate to ai_models/ (RECOMMENDED)

#

# 1. Check what's actually in models/:

#    cd models/

#    dir

#

# 2. If models/ has actual model files, copy them to ai_models/:

#    xcopy models\* ai_models\ /E /Y

#

# 3. Update config file:

#    Edit config/model_config.py line 11:

#    FROM: MODELS_DIR = PROJECT_ROOT / "models"

#    TO:   MODELS_DIR = PROJECT_ROOT / "ai_models"

#

# 4. Delete models/ directory:

#    rmdir /s /q models

#

# 5. Test:

#    python -c "from config import get_model_path; print(get_model_path('yolo'))"

```

### STEP 2: Clean Up Code Directories (Already Identified)
```bash

# Already planned in CLEANUP_ANALYSIS.md

# These are separate from the model consolidation

rmdir /s /q NETRA

rmdir /s /q "detection logic"

```

---

## ⚠️ CRITICAL VERIFICATION CHECKLIST

Before making changes, verify:

- [ ] Check what model files are in `models/object_detection/`
- [ ] Check what model files are in `ai_models/object_detection/`
- [ ] Confirm which directory actually has the trained models
- [ ] Run app.py and check if models load successfully
- [ ] Verify the config file paths are correct after consolidation

---

## πŸ” Verification Command

Run this to see which models are found:

```python

import sys

from pathlib import Path

sys.path.insert(0, str(Path(__file__).parent))



from config import get_model_path, MODEL_PATHS



print("Current model directory:", MODEL_PATHS['yolo']['candidates'][0].parent.parent)

print("\nSearching for models:")

print("YOLO:", get_model_path('yolo'))

print("Pose:", get_model_path('pose'))

print("Weapon (gun):", get_model_path('weapon', 'gun'))

print("Weapon (person):", get_model_path('weapon', 'person'))

print("Anomaly:", get_model_path('anomaly'))

```

---

## πŸ“ Updated Cleanup & Merge Plan

### PHASE 0: Model Directory Consolidation (NEW - DO FIRST!)
```

Priority: πŸ”΄ CRITICAL

Action: Choose one model directory, delete the other

Estimated space saved: ~100-150 MB

```

### PHASE 1: Code Cleanup (From CLEANUP_ANALYSIS.md)

```

Priority: 🟠 HIGH

Folders: NETRA/, detection logic/, database/models/, tests/

Estimated space saved: ~50-100 MB

```



### PHASE 2: Optional Cleanup

```

Priority: 🟑 MEDIUM

Folders: test_migration.py, .sixth/
Estimated space saved: ~5-10 MB
```



---



## ✨ Next Steps



1. **FIRST:** Identify which model directory (`models/` or `ai_models/`) actually contains your trained model files

2. **Consolidate** to single directory (recommend `ai_models/`)

3. **Update** `config/model_config.py` to point to the right directory

4. **Test** the app: `python webapp/app.py`

5. **Delete** the duplicate model directory

6. **Then** proceed with code cleanup from CLEANUP_ANALYSIS.md



---



**Generated By:** Duplicate Analysis Tool  

**Confidence Level:** 🟒 HIGH (100% safe after consolidation verified)