Skip to content

Commit 49c4edb

Browse files
committed
change to fp16
1 parent 19789f4 commit 49c4edb

8 files changed

+3336
-2645
lines changed

Diff for: README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ Now training models.. Plz wait.
2020
|*backbone* |*resolution*|*VOCmAP* |*COCOmAP*|*Inference[ms]*|*model*|
2121
|:------: |:------------:|:----------:|:-------:|:-------------:|:-----:|
2222
|EfficientnetB0(wo/BiFPN)|512 |77.0 |TBD | | |
23-
|EfficientnetB0(w/BiFPN) |512 |79.0 |TBD | | |
23+
|EfficientnetB0(w/BiFPN) |512 |77.2 |TBD | | |
2424
|EfficientnetB2(wo/BiFPN)|768 |TBD |TBD | | |
2525
|EfficientnetB2(w/BiFPN) |768 |TBD |TBD | | |
2626
|EfficientnetB4(wo/BiFPN)|1024 |TBD |TBD | | |

Diff for: eval.ipynb

+207-31
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,8 @@
4949
"train_img_list, train_anno_list, val_img_list, val_anno_list = make_datapath_list(vocpath)\n",
5050
"\n",
5151
"model=\"efficientdet\"\n",
52-
"backbone = \"efficientnet-b2\"\n",
53-
"scale = 2"
52+
"backbone = \"efficientnet-b0\"\n",
53+
"scale = 1"
5454
]
5555
},
5656
{
@@ -148,18 +148,18 @@
148148
},
149149
{
150150
"cell_type": "code",
151-
"execution_count": 1,
151+
"execution_count": 11,
152152
"metadata": {},
153153
"outputs": [
154154
{
155-
"ename": "NameError",
156-
"evalue": "name 'DATASET' is not defined",
157-
"output_type": "error",
158-
"traceback": [
159-
"\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
160-
"\u001b[0;31mNameError\u001b[0m Traceback (most recent call last)",
161-
"\u001b[0;32m<ipython-input-1-edf285b2353f>\u001b[0m in \u001b[0;36m<module>\u001b[0;34m()\u001b[0m\n\u001b[0;32m----> 1\u001b[0;31m \u001b[0;32mif\u001b[0m \u001b[0;32mnot\u001b[0m \u001b[0mDATASET\u001b[0m \u001b[0;34m==\u001b[0m \u001b[0;34m\"COCO\"\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 2\u001b[0m \u001b[0mnum_class\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0;36m21\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 3\u001b[0m \u001b[0;32melse\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 4\u001b[0m \u001b[0mnum_class\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0;36m81\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 5\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n",
162-
"\u001b[0;31mNameError\u001b[0m: name 'DATASET' is not defined"
155+
"name": "stdout",
156+
"output_type": "stream",
157+
"text": [
158+
"Loaded pretrained weights for efficientnet-b0\n",
159+
"320\n",
160+
"use BiFPN\n",
161+
"loaded the trained weights\n",
162+
"using: cuda:0\n"
163163
]
164164
}
165165
],
@@ -212,7 +212,7 @@
212212
" map_location={'cuda:0': 'cpu'})\n",
213213
"else:\n",
214214
" net = EfficientDet(phase=\"inference\", cfg=ssd_cfg, verbose=False, backbone=backbone, useBiFPN=True)\n",
215-
" net_weights = torch.load('./weights/VOC_efficientnet-b2_600_BiFPN_100.pth',\n",
215+
" net_weights = torch.load('./weights/VOC_efficientnet-b0_300_BiFPN_200.pth',\n",
216216
" map_location={'cuda:0': 'cpu'})\n",
217217
"\n",
218218
"net.load_state_dict(net_weights)\n",
@@ -227,7 +227,7 @@
227227
},
228228
{
229229
"cell_type": "code",
230-
"execution_count": null,
230+
"execution_count": 12,
231231
"metadata": {},
232232
"outputs": [],
233233
"source": [
@@ -243,9 +243,17 @@
243243
},
244244
{
245245
"cell_type": "code",
246-
"execution_count": null,
246+
"execution_count": 13,
247247
"metadata": {},
248-
"outputs": [],
248+
"outputs": [
249+
{
250+
"name": "stdout",
251+
"output_type": "stream",
252+
"text": [
253+
"cuda:0\n"
254+
]
255+
}
256+
],
249257
"source": [
250258
"from utils.ssd_predict_show import SSDPredictShow\n",
251259
"ssd = SSDPredictShow(eval_categories=voc_classes, net=net, device=device, image_size=input_size)"
@@ -260,7 +268,7 @@
260268
},
261269
{
262270
"cell_type": "code",
263-
"execution_count": null,
271+
"execution_count": 14,
264272
"metadata": {
265273
"scrolled": true
266274
},
@@ -271,18 +279,65 @@
271279
},
272280
{
273281
"cell_type": "code",
274-
"execution_count": null,
282+
"execution_count": 15,
275283
"metadata": {},
276-
"outputs": [],
284+
"outputs": [
285+
{
286+
"data": {
287+
"text/plain": [
288+
"['../VOCdevkit/VOC2007/JPEGImages/000001.jpg',\n",
289+
" '../VOCdevkit/VOC2007/JPEGImages/000002.jpg',\n",
290+
" '../VOCdevkit/VOC2007/JPEGImages/000003.jpg',\n",
291+
" '../VOCdevkit/VOC2007/JPEGImages/000004.jpg',\n",
292+
" '../VOCdevkit/VOC2007/JPEGImages/000006.jpg',\n",
293+
" '../VOCdevkit/VOC2007/JPEGImages/000008.jpg',\n",
294+
" '../VOCdevkit/VOC2007/JPEGImages/000010.jpg',\n",
295+
" '../VOCdevkit/VOC2007/JPEGImages/000011.jpg',\n",
296+
" '../VOCdevkit/VOC2007/JPEGImages/000013.jpg',\n",
297+
" '../VOCdevkit/VOC2007/JPEGImages/000014.jpg']"
298+
]
299+
},
300+
"execution_count": 15,
301+
"metadata": {},
302+
"output_type": "execute_result"
303+
}
304+
],
277305
"source": [
278306
"val_img_list[0:10]"
279307
]
280308
},
281309
{
282310
"cell_type": "code",
283-
"execution_count": null,
311+
"execution_count": 16,
284312
"metadata": {},
285-
"outputs": [],
313+
"outputs": [
314+
{
315+
"name": "stdout",
316+
"output_type": "stream",
317+
"text": [
318+
"iter: 0\n"
319+
]
320+
},
321+
{
322+
"name": "stderr",
323+
"output_type": "stream",
324+
"text": [
325+
"/home/ubuntu/anaconda3/envs/pytorch_p36/lib/python3.6/site-packages/torch/nn/functional.py:2457: UserWarning: nn.functional.upsample is deprecated. Use nn.functional.interpolate instead.\n",
326+
" warnings.warn(\"nn.functional.upsample is deprecated. Use nn.functional.interpolate instead.\")\n",
327+
"/home/ubuntu/anaconda3/envs/pytorch_p36/lib/python3.6/site-packages/torch/nn/functional.py:2539: UserWarning: Default upsampling behavior when mode=bilinear is changed to align_corners=False since 0.4.0. Please specify align_corners=True if the old behavior is desired. See the documentation of nn.Upsample for details.\n",
328+
" \"See the documentation of nn.Upsample for details.\".format(mode))\n"
329+
]
330+
},
331+
{
332+
"name": "stdout",
333+
"output_type": "stream",
334+
"text": [
335+
"iter: 1000\n",
336+
"iter: 3000\n",
337+
"iter: 4000\n"
338+
]
339+
}
340+
],
286341
"source": [
287342
"for i, imp in enumerate(val_img_list):\n",
288343
" detections, pre_dict_label_index = ssd.ssd_predict2(imp, data_confidence_level=0.05)\n",
@@ -302,9 +357,30 @@
302357
},
303358
{
304359
"cell_type": "code",
305-
"execution_count": null,
360+
"execution_count": 17,
306361
"metadata": {},
307-
"outputs": [],
362+
"outputs": [
363+
{
364+
"data": {
365+
"text/plain": [
366+
"[array([], shape=(0, 5), dtype=float64),\n",
367+
" array([], shape=(0, 5), dtype=float64),\n",
368+
" array([], shape=(0, 5), dtype=float64),\n",
369+
" array([], shape=(0, 5), dtype=float64),\n",
370+
" array([], shape=(0, 5), dtype=float64),\n",
371+
" array([], shape=(0, 5), dtype=float64),\n",
372+
" array([], shape=(0, 5), dtype=float64),\n",
373+
" [array([ 0.7535214, 137.66829 , 84.52406 , 326.27124 , 302.4893 ],\n",
374+
" dtype=float32)],\n",
375+
" array([], shape=(0, 5), dtype=float64),\n",
376+
" array([], shape=(0, 5), dtype=float64)]"
377+
]
378+
},
379+
"execution_count": 17,
380+
"metadata": {},
381+
"output_type": "execute_result"
382+
}
383+
],
308384
"source": [
309385
"all_boxes[7][0:10]"
310386
]
@@ -318,7 +394,7 @@
318394
},
319395
{
320396
"cell_type": "code",
321-
"execution_count": null,
397+
"execution_count": 18,
322398
"metadata": {},
323399
"outputs": [],
324400
"source": [
@@ -476,7 +552,7 @@
476552
},
477553
{
478554
"cell_type": "code",
479-
"execution_count": null,
555+
"execution_count": 19,
480556
"metadata": {},
481557
"outputs": [],
482558
"source": [
@@ -497,7 +573,7 @@
497573
},
498574
{
499575
"cell_type": "code",
500-
"execution_count": null,
576+
"execution_count": 20,
501577
"metadata": {},
502578
"outputs": [],
503579
"source": [
@@ -585,7 +661,7 @@
585661
},
586662
{
587663
"cell_type": "code",
588-
"execution_count": null,
664+
"execution_count": 21,
589665
"metadata": {},
590666
"outputs": [],
591667
"source": [
@@ -594,9 +670,49 @@
594670
},
595671
{
596672
"cell_type": "code",
597-
"execution_count": null,
673+
"execution_count": 22,
598674
"metadata": {},
599-
"outputs": [],
675+
"outputs": [
676+
{
677+
"name": "stdout",
678+
"output_type": "stream",
679+
"text": [
680+
"Writing aeroplane VOC results file\n",
681+
"Writing bicycle VOC results file\n",
682+
"Writing bird VOC results file\n",
683+
"Writing boat VOC results file\n"
684+
]
685+
},
686+
{
687+
"name": "stderr",
688+
"output_type": "stream",
689+
"text": [
690+
"/home/ubuntu/anaconda3/envs/pytorch_p36/lib/python3.6/site-packages/ipykernel_launcher.py:21: DeprecationWarning: elementwise == comparison failed; this will raise an error in the future.\n"
691+
]
692+
},
693+
{
694+
"name": "stdout",
695+
"output_type": "stream",
696+
"text": [
697+
"Writing bottle VOC results file\n",
698+
"Writing bus VOC results file\n",
699+
"Writing car VOC results file\n",
700+
"Writing cat VOC results file\n",
701+
"Writing chair VOC results file\n",
702+
"Writing cow VOC results file\n",
703+
"Writing diningtable VOC results file\n",
704+
"Writing dog VOC results file\n",
705+
"Writing horse VOC results file\n",
706+
"Writing motorbike VOC results file\n",
707+
"Writing person VOC results file\n",
708+
"Writing pottedplant VOC results file\n",
709+
"Writing sheep VOC results file\n",
710+
"Writing sofa VOC results file\n",
711+
"Writing train VOC results file\n",
712+
"Writing tvmonitor VOC results file\n"
713+
]
714+
}
715+
],
600716
"source": [
601717
"write_voc_results_file(pascal_classes, all_boxes, val_img_list)"
602718
]
@@ -610,7 +726,7 @@
610726
},
611727
{
612728
"cell_type": "code",
613-
"execution_count": null,
729+
"execution_count": 23,
614730
"metadata": {},
615731
"outputs": [],
616732
"source": [
@@ -663,9 +779,69 @@
663779
},
664780
{
665781
"cell_type": "code",
666-
"execution_count": null,
782+
"execution_count": 24,
667783
"metadata": {},
668-
"outputs": [],
784+
"outputs": [
785+
{
786+
"name": "stdout",
787+
"output_type": "stream",
788+
"text": [
789+
"VOC07 metric? No\n",
790+
"AP for aeroplane = 0.8093\n",
791+
"AP for bicycle = 0.8631\n",
792+
"AP for bird = 0.7861\n",
793+
"AP for boat = 0.7077\n",
794+
"AP for bottle = 0.4031\n",
795+
"AP for bus = 0.8470\n",
796+
"AP for car = 0.8519\n",
797+
"AP for cat = 0.9062\n",
798+
"AP for chair = 0.5554\n",
799+
"AP for cow = 0.8457\n",
800+
"AP for diningtable = 0.7194\n",
801+
"AP for dog = 0.9009\n",
802+
"AP for horse = 0.8980\n",
803+
"AP for motorbike = 0.8618\n",
804+
"AP for person = 0.7593\n",
805+
"AP for pottedplant = 0.4591\n",
806+
"AP for sheep = 0.8089\n",
807+
"AP for sofa = 0.8020\n",
808+
"AP for train = 0.8793\n",
809+
"AP for tvmonitor = 0.7795\n",
810+
"Mean AP = 0.7722\n",
811+
"~~~~~~~~\n",
812+
"Results:\n",
813+
"0.809\n",
814+
"0.863\n",
815+
"0.786\n",
816+
"0.708\n",
817+
"0.403\n",
818+
"0.847\n",
819+
"0.852\n",
820+
"0.906\n",
821+
"0.555\n",
822+
"0.846\n",
823+
"0.719\n",
824+
"0.901\n",
825+
"0.898\n",
826+
"0.862\n",
827+
"0.759\n",
828+
"0.459\n",
829+
"0.809\n",
830+
"0.802\n",
831+
"0.879\n",
832+
"0.779\n",
833+
"0.772\n",
834+
"~~~~~~~~\n",
835+
"\n",
836+
"--------------------------------------------------------------\n",
837+
"Results computed with the **unofficial** Python eval code.\n",
838+
"Results should be very close to the official MATLAB eval code.\n",
839+
"Recompute with `./tools/reval.py --matlab ...` for your paper.\n",
840+
"-- Thanks, The Management\n",
841+
"--------------------------------------------------------------\n"
842+
]
843+
}
844+
],
669845
"source": [
670846
"# evaluate detections\n",
671847
"python_eval()"

0 commit comments

Comments
 (0)