Skip to content

Commit

Permalink
trying my_ssd_mobnet_640
Browse files Browse the repository at this point in the history
  • Loading branch information
VinceJnz committed Feb 8, 2023
1 parent 30daf91 commit 13c7baf
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 25 deletions.
32 changes: 31 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,34 @@ This fork has the following changes

## label studio

http://localhost:8080/projects/6/data/local-storage/6/9ee06b40-Day_1_Images_Flight_1_DSC09209_geotag_1.JPG
http://localhost:8080/projects/6/data/local-storage/6/9ee06b40-Day_1_Images_Flight_1_DSC09209_geotag_1.JPG


## Model training

### Training details

<https://www.tensorflow.org/guide/distributed_training>
<https://www.tensorflow.org/guide/checkpoint>


### Execution flow for training
[model_main.py]
main
[model_lib_v2.py]
train_loop
[inputs.py]
train_input
[image_resizer_builder.py]
build

?????????
train_step_fn()
eager_train_step
_compute_losses_and_predictions_dicts(...) #model prediction is done here


??????????



42 changes: 18 additions & 24 deletions Training_Customised_Image_Detection_Model-ML4DR_v1.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,10 @@
"SEED = 123\n",
"random.seed(SEED)\n",
"np.random.seed(SEED)\n",
"tf.random.set_seed(SEED)"
"tf.random.set_seed(SEED)\n",
"\n",
"import os\n",
"print(f\"Current OS: {os.name}\") "
]
},
{
Expand All @@ -57,22 +60,6 @@
"Including paths and training hyper-parameters"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/"
},
"id": "vCm7RtDn0za5",
"outputId": "9a10857b-fff7-4cfd-c568-318c1658d087"
},
"outputs": [],
"source": [
"import os\n",
"print(f\"Current OS: {os.name}\") "
]
},
{
"cell_type": "markdown",
"metadata": {},
Expand Down Expand Up @@ -541,7 +528,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"### Create TF Record from COCO files"
"### Prep COCO file data"
]
},
{
Expand Down Expand Up @@ -626,20 +613,27 @@
"create_label_map(labels, files['LABELMAP'])"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Create TF Record from COCO files"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"#This is used when creating the TF Record files\n",
"# in the TF Record file\n",
"# Store each image with its annotations\n",
"#This is used when creating and reading the TF Record files\n",
"\n",
"from object_detection.utils import dataset_util #, label_map_util\n",
"import io\n",
"from PIL import Image\n",
"\n",
"#This is used write the TF Records\n",
"#Store images with its associated annotations in a TF Record file\n",
"def create_tf_example(imageInfo, image_path):\n",
" with tf.io.gfile.GFile(os.path.join(image_path, '{}'.format(imageInfo['file_name'])), 'rb') as fid:\n",
" encoded_jpg = fid.read()\n",
Expand Down Expand Up @@ -903,13 +897,13 @@
"pipeline_config.model.ssd.num_classes = len(labels)\n",
"#pipeline_config.train_config.batch_size = 4\n",
"#pipeline_config.train_config.batch_size = 3\n",
"#pipeline_config.train_config.batch_size = 2\n",
"pipeline_config.train_config.batch_size = 2\n",
"#pipeline_config.train_config.batch_size = 1\n",
"\n",
"#if the batch size is small the learning rate needs to be reduced for the model to converge\n",
"#https://github.com/tensorflow/models/issues/9151\n",
"#https://medium.com/mini-distill/effect-of-batch-size-on-training-dynamics-21c14f7a716e\n",
"#pipeline_config.train_config.optimizer.momentium_optimizer.learning_rate.cosine_decay_learning_rate.learning_rate_base = 0.05 #0.08\n",
"pipeline_config.train_config.optimizer.momentum_optimizer.learning_rate.cosine_decay_learning_rate.learning_rate_base = 0.03 #0.08\n",
"pipeline_config.train_config.fine_tune_checkpoint = os.path.join(paths['PRETRAINED_MODEL_PATH'], PRETRAINED_MODEL_NAME, 'checkpoint', 'ckpt-0')\n",
"pipeline_config.train_config.fine_tune_checkpoint_type = \"detection\"\n",
"pipeline_config.train_input_reader.label_map_path= files['LABELMAP']\n",
Expand Down Expand Up @@ -1119,7 +1113,7 @@
" category_index,\n",
" use_normalized_coordinates=True,\n",
" max_boxes_to_draw=5,\n",
" min_score_thresh=.05, #(0.5)\n",
" min_score_thresh=.5, #(0.5)\n",
" agnostic_mode=False)\n",
"\n",
"plt.imshow(cv2.cvtColor(image_np_with_detections, cv2.COLOR_BGR2RGB))\n",
Expand Down

0 comments on commit 13c7baf

Please sign in to comment.