foreversheikh commited on
Commit
5c19b3a
·
verified ·
1 Parent(s): 1d058b9

Upload 17 files

Browse files
.gitattributes CHANGED
@@ -33,3 +33,17 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
33
  *.zip filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
33
  *.zip filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
36
+ static/videos/Abuse.mp4 filter=lfs diff=lfs merge=lfs -text
37
+ static/videos/Arrest.mp4 filter=lfs diff=lfs merge=lfs -text
38
+ static/videos/Arson.mp4 filter=lfs diff=lfs merge=lfs -text
39
+ static/videos/Assault.mp4 filter=lfs diff=lfs merge=lfs -text
40
+ static/videos/Burglary.mp4 filter=lfs diff=lfs merge=lfs -text
41
+ static/videos/Explosion.mp4 filter=lfs diff=lfs merge=lfs -text
42
+ static/videos/Fighting.mp4 filter=lfs diff=lfs merge=lfs -text
43
+ static/videos/Normal.mp4 filter=lfs diff=lfs merge=lfs -text
44
+ static/videos/RoadAccidents.mp4 filter=lfs diff=lfs merge=lfs -text
45
+ static/videos/Robbery.mp4 filter=lfs diff=lfs merge=lfs -text
46
+ static/videos/Shooting.mp4 filter=lfs diff=lfs merge=lfs -text
47
+ static/videos/Shoplifting.mp4 filter=lfs diff=lfs merge=lfs -text
48
+ static/videos/Stealing.mp4 filter=lfs diff=lfs merge=lfs -text
49
+ static/videos/Vandalism.mp4 filter=lfs diff=lfs merge=lfs -text
static/css/style.css ADDED
@@ -0,0 +1,112 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ body {
2
+ font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
3
+ background-color: #121212;
4
+ color: #e0e0e0;
5
+ margin: 0;
6
+ padding: 20px;
7
+ display: flex;
8
+ justify-content: center;
9
+ }
10
+
11
+ .container {
12
+ display: flex;
13
+ width: 100%;
14
+ max-width: 1600px;
15
+ gap: 20px;
16
+ }
17
+
18
+ /* CHANGED: Main content takes more space, sidebar takes less */
19
+ .main-content {
20
+ flex: 4; /* Increased from 3 */
21
+ display: flex;
22
+ flex-direction: column;
23
+ }
24
+
25
+ .sidebar {
26
+ flex: 1; /* Stays at 1, making it proportionally smaller */
27
+ background-color: #1e1e1e;
28
+ padding: 20px;
29
+ border-radius: 8px;
30
+ height: fit-content;
31
+ }
32
+
33
+ .header {
34
+ display: flex;
35
+ justify-content: space-between;
36
+ align-items: center;
37
+ margin-bottom: 10px;
38
+ }
39
+
40
+ h1 { border-bottom: none; padding-bottom: 0; }
41
+ h2, h3 { color: #ffffff; border-bottom: 2px solid #333; padding-bottom: 10px; }
42
+
43
+ /* CHANGED: Grid ratio adjusted to make the graph wider */
44
+ .dashboard-grid {
45
+ display: grid;
46
+ grid-template-columns: 1.8fr 1.5fr; /* Video area vs Graph area */
47
+ gap: 20px;
48
+ align-items: flex-start;
49
+ }
50
+
51
+ .video-area {
52
+ display: flex;
53
+ flex-direction: column;
54
+ }
55
+
56
+ .video-wrapper {
57
+ width: 100%;
58
+ margin-bottom: 10px; /* Space between video and status label */
59
+ }
60
+
61
+ #videoPlayer {
62
+ background-color: #000;
63
+ border-radius: 8px;
64
+ }
65
+
66
+ /* CHANGED: Status label is now positioned under the video */
67
+ #statusLabel {
68
+ margin-top: 0; /* Resets previous margin */
69
+ font-style: italic;
70
+ color: #f44336;
71
+ text-align: center; /* Center the text under the video */
72
+ min-height: 24px; /* Prevents layout shifts */
73
+ }
74
+
75
+ /* The chart and yolo containers are now styled independently */
76
+ .chart-container {
77
+ background-color: #1e1e1e;
78
+ padding: 20px;
79
+ border-radius: 8px;
80
+ }
81
+
82
+ .yolo-container {
83
+ background-color: #1e1e1e;
84
+ padding: 20px;
85
+ border-radius: 8px;
86
+ }
87
+
88
+ #yoloTextLabel { font-size: 1.2em; font-weight: bold; color: #4CAF50; min-height: 25px; }
89
+ #yoloImageFrame { width: 100%; height: auto; border-radius: 4px; background-color: #333; min-height: 150px; margin-top: 10px; }
90
+
91
+ /* Styles for controls in the sidebar */
92
+ .custom-select {
93
+ width: 100%;
94
+ padding: 12px 15px;
95
+ background-color: #3a3a3a;
96
+ color: #e0e0e0;
97
+ border: 1px solid #bb86fc;
98
+ border-radius: 4px;
99
+ font-size: 1em;
100
+ cursor: pointer;
101
+ }
102
+ .custom-select:hover { background-color: #4a4a4a; }
103
+
104
+ .separator { border: none; border-top: 1px solid #333; margin: 20px 0; }
105
+ .upload-section { display: flex; flex-direction: column; gap: 10px; }
106
+ #videoUpload { color: #e0e0e0; }
107
+ #videoUpload::file-selector-button { font-weight: bold; color: #bb86fc; background-color: #3a3a3a; padding: 8px 12px; border: 1px solid #bb86fc; border-radius: 4px; cursor: pointer; transition: background-color 0.2s; }
108
+ #videoUpload::file-selector-button:hover { background-color: #4a4a4a; }
109
+ #uploadButton { padding: 10px 20px; font-size: 16px; font-weight: bold; color: white; background-color: #03dac6; border: none; border-radius: 5px; cursor: pointer; transition: background-color 0.2s; }
110
+ #uploadButton:hover { background-color: #018786; }
111
+ #resetButton { padding: 10px 20px; font-size: 16px; font-weight: bold; color: white; background-color: #f44336; border: none; border-radius: 5px; cursor: pointer; transition: background-color 0.2s; }
112
+ #resetButton:hover { background-color: #d32f2f; }
static/js/main.js ADDED
@@ -0,0 +1,108 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ document.addEventListener('DOMContentLoaded', () => {
2
+ const socket = io();
3
+
4
+ const videoPlayer = document.getElementById('videoPlayer');
5
+ const yoloTextLabel = document.getElementById('yoloTextLabel');
6
+ const yoloImageFrame = document.getElementById('yoloImageFrame');
7
+ const statusLabel = document.getElementById('statusLabel');
8
+ const resetButton = document.getElementById('resetButton');
9
+ const videoUploadInput = document.getElementById('videoUpload');
10
+ const uploadButton = document.getElementById('uploadButton');
11
+
12
+ // CHANGED: Get the new dropdown selector
13
+ const anomalySelector = document.getElementById('anomalySelector');
14
+
15
+ let chart;
16
+
17
+ function initializeChart() {
18
+ const ctx = document.getElementById('anomalyChart').getContext('2d');
19
+ if (chart) { chart.destroy(); }
20
+ chart = new Chart(ctx, {
21
+ type: 'line', data: { labels: [], datasets: [{ label: 'Anomaly Score', data: [], borderColor: 'rgba(255, 99, 132, 1)', backgroundColor: 'rgba(255, 99, 132, 0.2)', borderWidth: 2, tension: 0.4, pointRadius: 0 }] }, options: { scales: { y: { beginAtZero: true, max: 1.0, ticks: { color: '#e0e0e0' }}, x: { ticks: { color: '#e0e0e0' }}}, plugins: { legend: { labels: { color: '#e0e0e0' }}}}
22
+ });
23
+ }
24
+
25
+ function resetUI() {
26
+ videoPlayer.pause();
27
+ videoPlayer.removeAttribute('src');
28
+ videoPlayer.load();
29
+ initializeChart();
30
+ yoloTextLabel.textContent = 'Waiting for anomaly...';
31
+ yoloImageFrame.src = '';
32
+ statusLabel.textContent = 'System reset. Select a video to begin.';
33
+ videoUploadInput.value = '';
34
+ anomalySelector.selectedIndex = 0; // Reset dropdown to the default option
35
+ }
36
+
37
+ // --- WebSocket Event Listeners (unchanged) ---
38
+ socket.on('connect', () => { statusLabel.textContent = 'Connected. Please select a video to start processing.'; });
39
+ socket.on('update_graph', (data) => {
40
+ const { score } = data;
41
+ if (!chart) return;
42
+ const newLabel = chart.data.labels.length + 1;
43
+ chart.data.labels.push(newLabel);
44
+ chart.data.datasets[0].data.push(score);
45
+ if (chart.data.labels.length > 100) { chart.data.labels.shift(); chart.data.datasets[0].data.shift(); }
46
+ chart.update();
47
+ });
48
+ socket.on('update_yolo_text', (data) => { yoloTextLabel.textContent = data.text; });
49
+ socket.on('update_yolo_image', (data) => { yoloImageFrame.src = `data:image/jpeg;base64,${data.image_data}`; });
50
+ socket.on('update_status', (data) => { statusLabel.textContent = data.status; });
51
+ socket.on('processing_error', (data) => { statusLabel.textContent = `Error: ${data.error}`; });
52
+ socket.on('processing_finished', (data) => { statusLabel.textContent = data.message; });
53
+ socket.on('system_reset_confirm', () => { resetUI(); });
54
+
55
+ // --- User Interaction ---
56
+
57
+ // CHANGED: Replaced the old event listener for links with one for the dropdown
58
+ anomalySelector.addEventListener('change', (event) => {
59
+ const anomalyName = event.target.value;
60
+ if (!anomalyName) return; // Do nothing if the default option is selected
61
+
62
+ resetUI();
63
+ statusLabel.textContent = `Requesting to process ${anomalyName}...`;
64
+
65
+ videoPlayer.src = `/video_stream/demo/${anomalyName}`;
66
+ videoPlayer.play();
67
+
68
+ socket.emit('start_processing', { 'source': 'demo', 'filename': anomalyName });
69
+ });
70
+
71
+ resetButton.addEventListener('click', () => { socket.emit('reset_system'); });
72
+
73
+ // Upload button logic (unchanged)
74
+ uploadButton.addEventListener('click', () => {
75
+ const file = videoUploadInput.files[0];
76
+ if (!file) {
77
+ alert('Please select a video file first!');
78
+ return;
79
+ }
80
+
81
+ resetUI();
82
+ statusLabel.textContent = 'Uploading video...';
83
+
84
+ const formData = new FormData();
85
+ formData.append('video', file);
86
+
87
+ fetch('/upload', { method: 'POST', body: formData })
88
+ .then(response => response.json())
89
+ .then(data => {
90
+ if (data.success) {
91
+ const uploadedFilename = data.filename;
92
+ statusLabel.textContent = `Upload successful. Starting analysis...`;
93
+ videoPlayer.src = `/video_stream/upload/${uploadedFilename}`;
94
+ videoPlayer.play();
95
+ socket.emit('start_processing', { 'source': 'upload', 'filename': uploadedFilename });
96
+ } else {
97
+ statusLabel.textContent = `Error: ${data.error}`;
98
+ alert(`Upload failed: ${data.error}`);
99
+ }
100
+ })
101
+ .catch(error => {
102
+ statusLabel.textContent = 'An error occurred during upload.';
103
+ console.error('Upload error:', error);
104
+ });
105
+ });
106
+
107
+ initializeChart();
108
+ });
static/script.js ADDED
@@ -0,0 +1,41 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ const videoPlayer = document.getElementById("videoPlayer");
2
+ const yoloResult = document.getElementById("yoloResult");
3
+
4
+ // Dummy chart for anomaly graph
5
+ const ctx = document.getElementById("anomalyGraph").getContext("2d");
6
+ const graph = new Chart(ctx, {
7
+ type: "line",
8
+ data: {
9
+ labels: [],
10
+ datasets: [{
11
+ label: "Anomaly Score",
12
+ data: [],
13
+ borderColor: "red",
14
+ borderWidth: 2
15
+ }]
16
+ },
17
+ options: {
18
+ responsive: true,
19
+ scales: {
20
+ y: { min: 0, max: 1 }
21
+ }
22
+ }
23
+ });
24
+
25
+ async function playDemo(name) {
26
+ const response = await fetch("/get_video", {
27
+ method: "POST",
28
+ headers: {"Content-Type": "application/json"},
29
+ body: JSON.stringify({ name })
30
+ });
31
+
32
+ const data = await response.json();
33
+ if (data.error) {
34
+ alert(data.error);
35
+ return;
36
+ }
37
+
38
+ // Load video
39
+ videoPlayer.src = "file:///" + data.path;
40
+ yoloResult.innerText = `Playing demo: ${name}`;
41
+ }
static/videos/Abuse.mp4 ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:425744aa3472e424d52d7ce97bf6d0bdd445ad62ad1be110095d2027a31550cc
3
+ size 6250495
static/videos/Arrest.mp4 ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:faf0f08b1ee989545ad1de2edecdb56a24e65914194b8083f47d10481926c0e1
3
+ size 11929804
static/videos/Arson.mp4 ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:902f3138fa8b839abd08bcd3e434e84756742fdf0c60bcc0769cd7106b1ac3a2
3
+ size 12694369
static/videos/Assault.mp4 ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:3b83cf948fef884ede2b86a2d3fe68de779b9c81301a5c653fbb329bfc243274
3
+ size 21066405
static/videos/Burglary.mp4 ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:cd17094bfd2e5b73bcce767c434f14b715744eb3338fb80f1a213c1a337ce65d
3
+ size 9857751
static/videos/Explosion.mp4 ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:b462f9241ab7521e98071b18e8956c5a921336140b4da68ddbf56a5684e87fb6
3
+ size 5162883
static/videos/Fighting.mp4 ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:a135cc99b9b7d1f314375cc5e29b6a38aa1131544bf0d9ca133a95644668abf6
3
+ size 5519077
static/videos/Normal.mp4 ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:e7a4881043c8e9deefe11c65ed8663a281c8366a5baa91f091d67b98eb638018
3
+ size 7205089
static/videos/RoadAccidents.mp4 ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:0e6ccd7bac80120cfeac9a5ef3e726da29864fb8cfd218ea0ed42d696ce553ab
3
+ size 14490312
static/videos/Robbery.mp4 ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:ce7983bbb834708b8316c72cb916b9cab0105e2f283c7f8e636d38b36ddd6b48
3
+ size 26631485
static/videos/Shooting.mp4 ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:b125ed267b82f514820cc568c7c820a0f04cd531500bd242003c8efd2f9bdcdf
3
+ size 2198741
static/videos/Shoplifting.mp4 ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:717d68d3671d3f7638f80cc7db2e682599fceee21f15385431c569a1480d42ab
3
+ size 22406639
static/videos/Stealing.mp4 ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:97ebf655ad4192fdfef01ec91c435f85d6e773257fe72a1458eacf5abdd2e04b
3
+ size 27565440
static/videos/Vandalism.mp4 ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:407508a2a3587caac3b3e4b165983f494692301e400ed4c4bbed504c47ba9e56
3
+ size 2851411