-
Notifications
You must be signed in to change notification settings - Fork 0
/
detr.html
267 lines (249 loc) · 12.5 KB
/
detr.html
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
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Compress and Train DETR Model</title>
<link rel="stylesheet" href="styles.css">
<style>
/* Ensure the nav images are properly sized */
nav img {
height: 40px; /* Adjust the height as needed */
margin-right: 20px;
max-width: 100px; /* Prevents the image from being too wide */
}
nav {
display: flex;
align-items: center;
padding: 10px 20px;
background-color: #ffffff;
border-bottom: 2px solid #ddd;
box-shadow: 0 4px 2px -2px gray;
}
nav a {
margin: 0 20px;
text-decoration: none;
color: #333;
font-weight: bold;
transition: color 0.3s;
position: relative;
}
nav a:hover {
color: #007bff;
}
.content {
margin: 20px;
}
.project-info {
margin-top: 20px;
padding: 20px;
background-color: #ffffff;
border: 1px solid #ddd;
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
}
.project-info h2 {
margin-top: 0;
color: #333;
}
.project-info .names {
display: flex;
justify-content: space-around;
flex-wrap: wrap;
}
.names div {
margin: 10px;
text-align: center;
background-color: #f4f4f9;
padding: 10px;
border-radius: 8px;
box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}
.names div p {
margin: 5px 0;
}
.links a {
display: inline-block;
margin-right: 20px;
text-decoration: none;
color: #1a237e;
font-weight: bold;
background-color: #e8eaf6;
padding: 10px 20px;
border-radius: 8px;
transition: background-color 0.3s;
}
.links a:hover {
background-color: #c5cae9;
}
</style>
</head>
<body>
<nav>
<img src="images/IISC_logo.jpeg" alt="IISC Logo">
<img src="images/Shell_logo.png" alt="Shell Logo">
<a href="index.html">Home</a>
<a href="detr.html">DETR</a>
<a href="vgg.html">VGG</a>
<a href="resnet.html">ResNet</a>
<a href="unet.html">UNet</a>
</nav>
<div class="content">
<h1>Compress and Train DETR Model</h1>
<div style="display: flex; justify-content: space-between;">
<form method="post" action="/detr/stream_output" id="training-form" style="width: 25%;">
<label for="model">Model:</label>
<select id="model" name="model" required>
<option value="detr">DETR</option>
</select><br>
<label for="algorithm">Algorithm:</label>
<select id="algorithm" name="algorithm" required>
<option value="">Select Algorithm</option>
<option value="FPGM">FPGM</option>
<option value="L1">L1</option>
<option value="L2">L2</option>
<option value="SNIP">SNIP</option>
<option value="Synflow">Synflow</option>
<option value="our_algo">our_algo</option>
</select><br>
<div id="main-params" style="display: none;">
<label for="coco_path">Data Path (COCO format):</label>
<input type="text" id="coco_path" name="coco_path" value="../Data/open-images-bus-trucks/"><br>
<label for="epochs">Epochs:</label>
<input type="number" id="epochs" name="epochs" value="10"><br>
<label for="output_dir">Output Directory:</label>
<input type="text" id="output_dir" name="output_dir" value="DETR_output"><br>
<label for="resume">Pretrained Path:</label>
<input type="text" id="resume" name="resume" value="../Data/detr-r50_no-class-head.pth"><br>
<div id="compression-rate-field" style="display: none;">
<label for="compression">Compression:</label>
<input type="text" id="compression" name="compression" value="0.5"><br>
</div>
<div id="rate_dist_field" style="display: none;">
<label for="rate_dist">Rate Dist:</label>
<input type="text" id="rate_dist" name="rate_dist" value="0.3"><br>
</div>
<div id="rate_norm_field" style="display: none;">
<label for="rate_norm">Remaining Parameters after Compression:</label>
<input type="text" id="rate_norm" name="rate_norm" value="0.3"><br>
</div>
<div id="apply-pruning-field" style="display: none;">
<input type="checkbox" id="prune" name="prune">
<label for="prune">Apply Pruning</label><br>
</div>
<button type="button" id="toggle-settings">Show/Hide Advanced Settings</button>
<div id="advanced-settings" style="display: none;">
<div id="main-params-fpgm-l1-l2" style="display: none;">
<label for="nproc_per_node">Number of GPUs:</label>
<input type="number" id="nproc_per_node" name="nproc_per_node" value="3"><br>
<label for="lr">Learning Rate:</label>
<input type="text" id="lr" name="lr" value="1e-4"><br>
<label for="batch_size">Batch Size:</label>
<input type="number" id="batch_size" name="batch_size" value="2"><br>
<label for="num_workers">Number of Workers:</label>
<input type="number" id="num_workers" name="num_workers" value="4"><br>
<label for="layer_begin">Layer Begin:</label>
<input type="number" id="layer_begin" name="layer_begin" value="5"><br>
<label for="layer_end">Layer End:</label>
<input type="number" id="layer_end" name="layer_end" value="140"><br>
</div>
<div id="main-params-snip-synflow-our_algo" style="display: none;">
<label for="nproc_per_node">Number of GPUs:</label>
<input type="number" id="nproc_per_node" name="nproc_per_node" value="3"><br>
<label for="lr">Learning Rate:</label>
<input type="text" id="lr" name="lr" value="1e-4"><br>
<label for="batch_size">Batch Size:</label>
<input type="number" id="batch_size" name="batch_size" value="2"><br>
<label for="num_workers">Number of Workers:</label>
<input type="number" id="num_workers" name="num_workers" value="4"><br>
<label for="pruner">Pruner:</label>
<input type="text" id="pruner" name="pruner" value=""><br>
</div>
</div>
</div>
<button type="submit">Run Command</button>
</form>
<div style="width: 70%;">
<h2>Training Curves</h2>
<img id="training-image" src="" alt="Training Accuracy Image" style="max-width: 100%; margin-bottom: 20px;">
<h2>Model Metrics</h2>
<img id="metrics-image" src="" alt="Model Metrics Image" style="max-width: 100%;">
<div id="output" style="white-space: pre-wrap; max-height: 300px; overflow-y: scroll; border: 1px solid #ccc; padding: 10px; background-color: #f9f9f9; margin-top: 20px;"></div>
</div>
</div>
</div>
<script>
document.getElementById('algorithm').addEventListener('change', function() {
var mainParams = document.getElementById('main-params');
var algorithm = this.value;
document.getElementById('compression-rate-field').style.display = 'none';
document.getElementById('rate_dist_field').style.display = 'none';
document.getElementById('rate_norm_field').style.display = 'none';
document.getElementById('apply-pruning-field').style.display = 'none';
document.getElementById('main-params-fpgm-l1-l2').style.display = 'none';
document.getElementById('main-params-snip-synflow-our_algo').style.display = 'none';
if (algorithm) {
mainParams.style.display = 'block';
} else {
mainParams.style.display = 'none';
}
if (algorithm === 'FPGM') {
document.getElementById('rate_dist_field').style.display = 'block';
document.getElementById('main-params-fpgm-l1-l2').style.display = 'block';
} else if (algorithm === 'L1' || algorithm === 'L2') {
document.getElementById('rate_norm_field').style.display = 'block';
document.getElementById('main-params-fpgm-l1-l2').style.display = 'block';
} else if (algorithm === 'SNIP' || algorithm === 'Synflow' || algorithm === 'our_algo') {
document.getElementById('compression-rate-field').style.display = 'block';
document.getElementById('main-params-snip-synflow-our_algo').style.display = 'block';
document.getElementById('pruner').value = algorithm.toLowerCase();
document.getElementById('apply-pruning-field').style.display = 'block';
}
});
document.getElementById('toggle-settings').addEventListener('click', function() {
var advancedSettings = document.getElementById('advanced-settings');
if (advancedSettings.style.display === 'none') {
advancedSettings.style.display = 'block';
} else {
advancedSettings.style.display = 'none';
}
});
const form = document.getElementById('training-form');
form.addEventListener('submit', function(event) {
event.preventDefault();
const formData = new FormData(form);
const params = new URLSearchParams(formData).toString();
const outputDir = formData.get('output_dir');
const eventSource = new EventSource(`/detr/stream_output?${params}`);
const outputDiv = document.getElementById('output');
const trainingImage = document.getElementById('training-image');
const metricsImage = document.getElementById('metrics-image');
const trainingImageUrl = `/detr/images/${outputDir}/training_plots.png`;
const metricsImageUrl = `/detr/images/${outputDir}/model_metrics.png`;
console.log("Training Image URL: ", trainingImageUrl);
console.log("Metrics Image URL: ", metricsImageUrl);
trainingImage.src = trainingImageUrl;
metricsImage.src = metricsImageUrl;
outputDiv.innerHTML = '';
eventSource.onmessage = function(event) {
if (event.data.includes('Process completed')) {
eventSource.close();
}
const lines = outputDiv.innerHTML.split('<br>');
if (lines.length > 100) {
lines.splice(0, lines.length - 100); // Keep only the last 100 lines
}
outputDiv.innerHTML = lines.join('<br>') + '<br>' + event.data;
outputDiv.scrollTop = outputDiv.scrollHeight; // Auto-scroll to the bottom
};
function refreshImages() {
const timestamp = new Date().getTime();
const trainingUrl = trainingImage.src.split('?')[0];
const metricsUrl = metricsImage.src.split('?')[0];
trainingImage.src = `${trainingUrl}?timestamp=${timestamp}`;
metricsImage.src = `${metricsUrl}?timestamp=${timestamp}`;
}
setInterval(refreshImages, 5000); // Refresh images every 5 seconds
});
</script>
</body>
</html>