Skip to content

Commit

Permalink
Created using Colaboratory
Browse files Browse the repository at this point in the history
  • Loading branch information
AIWintermuteAI committed Dec 14, 2021
1 parent 53954c8 commit 8753ebb
Showing 1 changed file with 45 additions and 39 deletions.
84 changes: 45 additions & 39 deletions resources/aXeleRate_pascal20_detector.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"provenance": [],
"collapsed_sections": [],
"mount_file_id": "1_yhmzOZKns_-h0GwyPu9YAT3K0WQ1PG8",
"authorship_tag": "ABX9TyNngjnxUG9lnl+vJGB5gnHo",
"authorship_tag": "ABX9TyPUzrsszS4m23mnB7AcN0I9",
"include_colab_link": true
},
"kernelspec": {
Expand All @@ -25,7 +25,7 @@
"colab_type": "text"
},
"source": [
"<a href=\"https://colab.research.google.com/github/AIWintermuteAI/aXeleRate/blob/dev/resources/aXeleRate_pascal20_detector.ipynb\" target=\"_parent\"><img src=\"https://colab.research.google.com/assets/colab-badge.svg\" alt=\"Open In Colab\"/></a>"
"<a href=\"https://colab.research.google.com/github/AIWintermuteAI/aXeleRate/blob/master/resources/aXeleRate_pascal20_detector.ipynb\" target=\"_parent\"><img src=\"https://colab.research.google.com/assets/colab-badge.svg\" alt=\"Open In Colab\"/></a>"
]
},
{
Expand Down Expand Up @@ -60,7 +60,7 @@
"!git clone https://github.com/AIWintermuteAI/aXeleRate.git\n",
"import sys\n",
"sys.path.append('/content/aXeleRate')\n",
"from axelerate import setup_training, setup_inference"
"from axelerate import setup_training, setup_inference, setup_evaluation"
],
"execution_count": null,
"outputs": []
Expand Down Expand Up @@ -93,12 +93,12 @@
"source": [
"%matplotlib inline\n",
"!gdown https://drive.google.com/uc?id=1xgk7svdjBiEyzyUVoZrCz4PP6dSjVL8S #pascal-voc dataset\n",
"!gdown https://drive.google.com/uc?id=1-ccBXBEUhyzG2_jopf6d13hTH9X7qpNl #pre-trained model\n",
"!gdown https://drive.google.com/uc?id=1-2jYfTRPX4kSUTL5SUQVxwHKjBclrBTA #pre-trained model\n",
"!unzip --qq pascal_20_detection.zip\n",
"\n",
"from axelerate.networks.common_utils.augment import visualize_detection_dataset\n",
"\n",
"visualize_detection_dataset(img_folder='pascal_20_detection/imgs_validation', ann_folder='pascal_20_detection/anns_validation', num_imgs=10, img_size=224, augment=True)"
"visualize_detection_dataset(img_folder='pascal_20_detection/imgs_validation', ann_folder='pascal_20_detection/anns_validation', num_imgs=10, img_size=320, augment=True)\n"
],
"execution_count": null,
"outputs": []
Expand Down Expand Up @@ -126,6 +126,8 @@
"- DenseNet121\n",
"- ResNet50\n",
"\n",
"Currently only MobileNet backends available for YOLOv3 detector. I'm working on backend (feature exctractor) overhaul.\n",
"\n",
"For more information on anchors, please read here\n",
"https://github.com/pjreddie/darknet/issues/568\n",
"\n",
Expand All @@ -138,13 +140,13 @@
"\n",
"coord_scale determines how much to penalize wrong position and size predictions (x, y, w, h)\n",
"\n",
"class_scale determines how much to penalize wrong class prediction\n",
"obj_thresh, nms_threshold set detection confidence threshold and nms thresholds to be used when calcualting precision/recall\n",
"\n",
"For converter type you can choose the following:\n",
"\n",
"'k210', 'tflite_fullint', 'tflite_dynamic', 'edgetpu', 'openvino', 'onnx'\n",
"\n",
"**Since it is an example notebook, we will use pretrained weights and set all layers of the model to be \"frozen\"(non-trainable).** "
"**Since it is an example notebook, we will use pretrained weights and set learning rate to 0.0** "
]
},
{
Expand All @@ -157,16 +159,18 @@
" \"model\":{\n",
" \"type\": \"Detector\",\n",
" \"architecture\": \"MobileNet1_0\",\n",
" \"input_size\": 224,\n",
" \"anchors\": [0.57273, 0.677385, 1.87446, 2.06253, 3.33843, 5.47434, 7.88282, 3.52778, 9.77052, 9.16828],\n",
" \"input_size\": [224, 320],\n",
" \"anchors\": [[[0.76120044, 0.57155991], [0.6923348, 0.88535553], [0.47163042, 0.34163313]],\n",
" [[0.33340788, 0.70065861], [0.18124964, 0.38986752], [0.08497349, 0.1527057 ]]],\n",
" \"labels\": [\"person\", \"bird\", \"cat\", \"cow\", \"dog\", \"horse\", \"sheep\", \"aeroplane\", \"bicycle\", \"boat\", \"bus\", \"car\", \"motorbike\", \"train\",\"bottle\", \"chair\", \"diningtable\", \"pottedplant\", \"sofa\", \"tvmonitor\"],\n",
" \"coord_scale\" : \t\t1.0,\n",
" \"class_scale\" : \t\t1.0,\n",
" \"object_scale\" : \t\t5.0,\n",
" \"obj_thresh\" : \t\t 0.7,\n",
" \"iou_thresh\" : \t\t 0.5,\n",
" \"coord_scale\" : \t\t 1.0,\n",
" \"object_scale\" : \t\t 3.0, \n",
" \"no_object_scale\" : \t1.0\n",
" },\n",
" \"weights\" : {\n",
" \"full\": \t\t\t\t\"/content/2020-04-12_17-09-43.h5\",\n",
" \"full\": \t\t\t\t \"/content/yolo_best_recall.h5\",\n",
" \"backend\": \t\t \"imagenet\"\n",
" },\n",
" \"train\" : {\n",
Expand All @@ -177,18 +181,18 @@
" \"valid_image_folder\": \"pascal_20_detection/imgs_validation\",\n",
" \"valid_annot_folder\": \"pascal_20_detection/anns_validation\",\n",
" \"valid_times\": 1,\n",
" \"valid_metric\": \"mAP\",\n",
" \"valid_metric\": \"recall\",\n",
" \"batch_size\": 32,\n",
" \"learning_rate\": 0.0,\n",
" \"saved_folder\": \t\tF\"/content/drive/MyDrive/pascal20_detection\",\n",
" \"first_trainable_layer\": \"reshape\",\n",
" \"augumentation\":\t\t\t\tFalse,\n",
" \"is_only_detect\" : \t\tFalse\n",
" \"saved_folder\": \t\tF\"/content/drive/MyDrive/projects/pascal20_yolov3\",\n",
" \"first_trainable_layer\": \"\",\n",
" \"augmentation\":\t\t\t\t True,\n",
" \"is_only_detect\" : \t\t False\n",
" },\n",
" \"converter\" : {\n",
" \"type\": \t\t\t\t[\"k210\"]\n",
" \"type\": \t\t\t\t[]\n",
" }\n",
" }"
"}"
],
"execution_count": null,
"outputs": []
Expand Down Expand Up @@ -220,7 +224,7 @@
"id": "i0Fc61WrTxh1"
},
"source": [
"Also, let's open Tensorboard, where we will be able to watch model training progress in real time. Training and validation logs also will be saved in project folder.\r\n",
"Also, let's open Tensorboard, where we will be able to watch model training progress in real time. Training and validation logs also will be saved in project folder.\n",
"Since there are no logs before we start the training, tensorboard will be empty. Refresh it after first epoch."
]
},
Expand All @@ -230,9 +234,9 @@
"id": "jsGp9JvjTzzp"
},
"source": [
"%load_ext tensorboard\r\n",
"%tensorboard --logdir logs\r\n",
"!sleep 10"
"%load_ext tensorboard\n",
"%tensorboard --logdir logs\n",
"!sleep 5"
],
"execution_count": null,
"outputs": []
Expand Down Expand Up @@ -300,7 +304,7 @@
},
"source": [
"from axelerate.networks.common_utils.convert import Converter\n",
"converter = Converter('openvino', 'MobileNet1_0', 'pascal_20_detection/imgs_validation')\n",
"converter = Converter('tflite_dynamic', 'MobileNet1_0', 'pascal_20_detection/imgs_validation')\n",
"converter.convert_model(model_path)"
],
"execution_count": null,
Expand All @@ -325,38 +329,40 @@
" \"model\":{\n",
" \"type\": \"Detector\",\n",
" \"architecture\": \"MobileNet1_0\",\n",
" \"input_size\": 224,\n",
" \"anchors\": [0.57273, 0.677385, 1.87446, 2.06253, 3.33843, 5.47434, 7.88282, 3.52778, 9.77052, 9.16828],\n",
" \"input_size\": [224, 320],\n",
" \"anchors\": [[[0.76120044, 0.57155991], [0.6923348, 0.88535553], [0.47163042, 0.34163313]],\n",
" [[0.33340788, 0.70065861], [0.18124964, 0.38986752], [0.08497349, 0.1527057 ]]],\n",
" \"labels\": [\"person\", \"bird\", \"cat\", \"cow\", \"dog\", \"horse\", \"sheep\", \"aeroplane\", \"bicycle\", \"boat\", \"bus\", \"car\", \"motorbike\", \"train\",\"bottle\", \"chair\", \"diningtable\", \"pottedplant\", \"sofa\", \"tvmonitor\"],\n",
" \"coord_scale\" : \t\t1.0,\n",
" \"class_scale\" : \t\t1.0,\n",
" \"object_scale\" : \t\t5.0,\n",
" \"obj_thresh\" : \t\t 0.7,\n",
" \"iou_thresh\" : \t\t 0.5,\n",
" \"coord_scale\" : \t\t 1.0,\n",
" \"object_scale\" : \t\t 3.0, \n",
" \"no_object_scale\" : \t1.0\n",
" },\n",
" \"weights\" : {\n",
" \"full\": \t\t\t\t\"\",\n",
" \"full\": \t\t\t\t \"\",\n",
" \"backend\": \t\t \"imagenet\"\n",
" },\n",
" \"train\" : {\n",
" \"actual_epoch\": 100,\n",
" \"actual_epoch\": 50,\n",
" \"train_image_folder\": \"pascal_20_detection/imgs\",\n",
" \"train_annot_folder\": \"pascal_20_detection/anns\",\n",
" \"train_times\": 1,\n",
" \"valid_image_folder\": \"pascal_20_detection/imgs_validation\",\n",
" \"valid_annot_folder\": \"pascal_20_detection/anns_validation\",\n",
" \"valid_times\": 1,\n",
" \"valid_metric\": \"mAP\",\n",
" \"valid_metric\": \"recall\",\n",
" \"batch_size\": 32,\n",
" \"learning_rate\": 1e-4,\n",
" \"saved_folder\": \t\tF\"/content/drive/MyDrive/pascal20_detection\",\n",
" \"learning_rate\": 1e-3,\n",
" \"saved_folder\": \t\tF\"/content/drive/MyDrive/projects/pascal20_yolov3\",\n",
" \"first_trainable_layer\": \"\",\n",
" \"augumentation\":\t\t\t\tFalse,\n",
" \"is_only_detect\" : \t\tFalse\n",
" \"augmentation\":\t\t\t\t True,\n",
" \"is_only_detect\" : \t\t False\n",
" },\n",
" \"converter\" : {\n",
" \"type\": \t\t\t\t[\"k210\",\"tflite\"]\n",
" \"type\": \t\t\t\t[]\n",
" }\n",
" }"
"}"
],
"execution_count": null,
"outputs": []
Expand Down

0 comments on commit 8753ebb

Please sign in to comment.