|
49 | 49 | "train_img_list, train_anno_list, val_img_list, val_anno_list = make_datapath_list(vocpath)\n",
|
50 | 50 | "\n",
|
51 | 51 | "model=\"efficientdet\"\n",
|
52 |
| - "backbone = \"efficientnet-b2\"\n", |
53 |
| - "scale = 2" |
| 52 | + "backbone = \"efficientnet-b0\"\n", |
| 53 | + "scale = 1" |
54 | 54 | ]
|
55 | 55 | },
|
56 | 56 | {
|
|
148 | 148 | },
|
149 | 149 | {
|
150 | 150 | "cell_type": "code",
|
151 |
| - "execution_count": 1, |
| 151 | + "execution_count": 11, |
152 | 152 | "metadata": {},
|
153 | 153 | "outputs": [
|
154 | 154 | {
|
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" |
163 | 163 | ]
|
164 | 164 | }
|
165 | 165 | ],
|
|
212 | 212 | " map_location={'cuda:0': 'cpu'})\n",
|
213 | 213 | "else:\n",
|
214 | 214 | " 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", |
216 | 216 | " map_location={'cuda:0': 'cpu'})\n",
|
217 | 217 | "\n",
|
218 | 218 | "net.load_state_dict(net_weights)\n",
|
|
227 | 227 | },
|
228 | 228 | {
|
229 | 229 | "cell_type": "code",
|
230 |
| - "execution_count": null, |
| 230 | + "execution_count": 12, |
231 | 231 | "metadata": {},
|
232 | 232 | "outputs": [],
|
233 | 233 | "source": [
|
|
243 | 243 | },
|
244 | 244 | {
|
245 | 245 | "cell_type": "code",
|
246 |
| - "execution_count": null, |
| 246 | + "execution_count": 13, |
247 | 247 | "metadata": {},
|
248 |
| - "outputs": [], |
| 248 | + "outputs": [ |
| 249 | + { |
| 250 | + "name": "stdout", |
| 251 | + "output_type": "stream", |
| 252 | + "text": [ |
| 253 | + "cuda:0\n" |
| 254 | + ] |
| 255 | + } |
| 256 | + ], |
249 | 257 | "source": [
|
250 | 258 | "from utils.ssd_predict_show import SSDPredictShow\n",
|
251 | 259 | "ssd = SSDPredictShow(eval_categories=voc_classes, net=net, device=device, image_size=input_size)"
|
|
260 | 268 | },
|
261 | 269 | {
|
262 | 270 | "cell_type": "code",
|
263 |
| - "execution_count": null, |
| 271 | + "execution_count": 14, |
264 | 272 | "metadata": {
|
265 | 273 | "scrolled": true
|
266 | 274 | },
|
|
271 | 279 | },
|
272 | 280 | {
|
273 | 281 | "cell_type": "code",
|
274 |
| - "execution_count": null, |
| 282 | + "execution_count": 15, |
275 | 283 | "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 | + ], |
277 | 305 | "source": [
|
278 | 306 | "val_img_list[0:10]"
|
279 | 307 | ]
|
280 | 308 | },
|
281 | 309 | {
|
282 | 310 | "cell_type": "code",
|
283 |
| - "execution_count": null, |
| 311 | + "execution_count": 16, |
284 | 312 | "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 | + ], |
286 | 341 | "source": [
|
287 | 342 | "for i, imp in enumerate(val_img_list):\n",
|
288 | 343 | " detections, pre_dict_label_index = ssd.ssd_predict2(imp, data_confidence_level=0.05)\n",
|
|
302 | 357 | },
|
303 | 358 | {
|
304 | 359 | "cell_type": "code",
|
305 |
| - "execution_count": null, |
| 360 | + "execution_count": 17, |
306 | 361 | "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 | + ], |
308 | 384 | "source": [
|
309 | 385 | "all_boxes[7][0:10]"
|
310 | 386 | ]
|
|
318 | 394 | },
|
319 | 395 | {
|
320 | 396 | "cell_type": "code",
|
321 |
| - "execution_count": null, |
| 397 | + "execution_count": 18, |
322 | 398 | "metadata": {},
|
323 | 399 | "outputs": [],
|
324 | 400 | "source": [
|
|
476 | 552 | },
|
477 | 553 | {
|
478 | 554 | "cell_type": "code",
|
479 |
| - "execution_count": null, |
| 555 | + "execution_count": 19, |
480 | 556 | "metadata": {},
|
481 | 557 | "outputs": [],
|
482 | 558 | "source": [
|
|
497 | 573 | },
|
498 | 574 | {
|
499 | 575 | "cell_type": "code",
|
500 |
| - "execution_count": null, |
| 576 | + "execution_count": 20, |
501 | 577 | "metadata": {},
|
502 | 578 | "outputs": [],
|
503 | 579 | "source": [
|
|
585 | 661 | },
|
586 | 662 | {
|
587 | 663 | "cell_type": "code",
|
588 |
| - "execution_count": null, |
| 664 | + "execution_count": 21, |
589 | 665 | "metadata": {},
|
590 | 666 | "outputs": [],
|
591 | 667 | "source": [
|
|
594 | 670 | },
|
595 | 671 | {
|
596 | 672 | "cell_type": "code",
|
597 |
| - "execution_count": null, |
| 673 | + "execution_count": 22, |
598 | 674 | "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 | + ], |
600 | 716 | "source": [
|
601 | 717 | "write_voc_results_file(pascal_classes, all_boxes, val_img_list)"
|
602 | 718 | ]
|
|
610 | 726 | },
|
611 | 727 | {
|
612 | 728 | "cell_type": "code",
|
613 |
| - "execution_count": null, |
| 729 | + "execution_count": 23, |
614 | 730 | "metadata": {},
|
615 | 731 | "outputs": [],
|
616 | 732 | "source": [
|
|
663 | 779 | },
|
664 | 780 | {
|
665 | 781 | "cell_type": "code",
|
666 |
| - "execution_count": null, |
| 782 | + "execution_count": 24, |
667 | 783 | "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 | + ], |
669 | 845 | "source": [
|
670 | 846 | "# evaluate detections\n",
|
671 | 847 | "python_eval()"
|
|
0 commit comments