mustafa2ak commited on
Commit
c72d64a
·
verified ·
1 Parent(s): 959d8e5

Delete debug_analyzer.py

Browse files
Files changed (1) hide show
  1. debug_analyzer.py +0 -135
debug_analyzer.py DELETED
@@ -1,135 +0,0 @@
1
- """
2
- Standalone script to analyze debug output and diagnose issues
3
- """
4
- import json
5
- import numpy as np
6
- import matplotlib.pyplot as plt
7
- from collections import defaultdict
8
- from pathlib import Path
9
-
10
- def analyze_reid_debug(debug_file='reid_debug.json'):
11
- """Analyze the debug output file and provide insights"""
12
-
13
- if not Path(debug_file).exists():
14
- print(f"Debug file {debug_file} not found")
15
- return
16
-
17
- with open(debug_file, 'r') as f:
18
- data = json.load(f)
19
-
20
- print("="*80)
21
- print("REID DEBUG ANALYSIS")
22
- print("="*80)
23
-
24
- summary = data.get('summary', {})
25
- log = data.get('log', [])
26
-
27
- # Overall stats
28
- print("\n📊 OVERALL STATISTICS:")
29
- print(f" Total frames: {summary.get('total_frames', 0)}")
30
- print(f" Temp IDs created: {summary.get('temp_ids_created', 0)}")
31
- print(f" Active dogs: {summary.get('active_dogs', 0)}")
32
- print(f" Sleeping tracks: {summary.get('sleeping_tracks', 0)}")
33
-
34
- # Quality analysis
35
- quality_stats = summary.get('quality_stats', {})
36
- if quality_stats:
37
- print("\n🎯 FEATURE QUALITY:")
38
- print(f" Average: {quality_stats.get('avg', 0):.3f}")
39
- print(f" Range: [{quality_stats.get('min', 0):.3f} - {quality_stats.get('max', 0):.3f}]")
40
-
41
- if quality_stats.get('avg', 0) < 0.5:
42
- print(" ⚠️ LOW AVERAGE QUALITY - Consider:")
43
- print(" • Better lighting")
44
- print(" • Higher resolution")
45
- print(" • Less motion blur")
46
-
47
- # Storage stats
48
- storage_stats = summary.get('storage_stats', {})
49
- if storage_stats:
50
- print("\n💾 STORAGE EFFICIENCY:")
51
- total_stored = sum(v for k, v in storage_stats.items() if 'stored' in k)
52
- total_rejected = sum(v for k, v in storage_stats.items() if 'rejected' in k)
53
-
54
- if total_stored + total_rejected > 0:
55
- rejection_rate = total_rejected / (total_stored + total_rejected) * 100
56
- print(f" Stored: {total_stored}")
57
- print(f" Rejected: {total_rejected}")
58
- print(f" Rejection rate: {rejection_rate:.1f}%")
59
-
60
- if rejection_rate > 50:
61
- print(" ⚠️ HIGH REJECTION RATE - Many low-quality features")
62
-
63
- # Analyze adaptive thresholds
64
- adaptive_entries = [e for e in log if e.get('operation') == 'adaptive_threshold']
65
- if adaptive_entries:
66
- print("\n🎯 ADAPTIVE THRESHOLD ANALYSIS:")
67
- adjustments = [e['details']['adjustment'] for e in adaptive_entries]
68
- confidence_levels = [e['details']['confidence_level'] for e in adaptive_entries]
69
-
70
- level_counts = defaultdict(int)
71
- for level in confidence_levels:
72
- level_counts[level] += 1
73
-
74
- print(f" Total adaptations: {len(adaptive_entries)}")
75
- for level, count in level_counts.items():
76
- pct = count / len(adaptive_entries) * 100
77
- print(f" {level}: {count} ({pct:.1f}%)")
78
-
79
- avg_adjustment = np.mean(adjustments)
80
- print(f" Average adjustment: {avg_adjustment:.3f}")
81
-
82
- # Analyze match patterns
83
- quality_entries = [e for e in log if e.get('operation') == 'quality_scoring']
84
- if quality_entries:
85
- print("\n📈 QUALITY PATTERNS:")
86
-
87
- # Extract component scores
88
- components = defaultdict(list)
89
- for entry in quality_entries:
90
- for comp, score in entry['details'].get('components', {}).items():
91
- components[comp].append(score)
92
-
93
- print(" Average component scores:")
94
- for comp, scores in components.items():
95
- print(f" {comp}: {np.mean(scores):.3f}")
96
-
97
- # Find weakest component
98
- avg_scores = {comp: np.mean(scores) for comp, scores in components.items()}
99
- weakest = min(avg_scores.items(), key=lambda x: x[1])
100
- print(f"\n ⚠️ Weakest component: {weakest[0]} ({weakest[1]:.3f})")
101
-
102
- if weakest[0] == 'sharpness':
103
- print(" → Motion blur issue, consider:")
104
- print(" • Faster shutter speed")
105
- print(" • Better camera stabilization")
106
- print(" • Higher frame rate")
107
- elif weakest[0] == 'bbox_size':
108
- print(" → Dogs too small/far, consider:")
109
- print(" • Better camera placement")
110
- print(" • Optical zoom")
111
- print(" • Multiple cameras")
112
- elif weakest[0] == 'centrality':
113
- print(" → Dogs often at frame edges, consider:")
114
- print(" • Wider field of view")
115
- print(" • Camera repositioning")
116
-
117
- # Recommendations
118
- print("\n🚀 RECOMMENDATIONS:")
119
-
120
- temp_id_ratio = summary.get('temp_ids_created', 0) / max(summary.get('total_frames', 1) / 100, 1)
121
- if temp_id_ratio > 2:
122
- print(" ❌ Too many IDs created")
123
- print(" • Increase ReID threshold")
124
- print(" • Check feature quality")
125
- elif temp_id_ratio > 1:
126
- print(" ⚠️ Moderate fragmentation")
127
- print(" • Fine-tune thresholds")
128
- print(" • Verify DeepSORT parameters")
129
- else:
130
- print(" ✅ Good ID stability")
131
-
132
- print("\n" + "="*80)
133
-
134
- if __name__ == "__main__":
135
- analyze_reid_debug()