The following shows the folder structure of the repository for this project:
.
├── Cars.ipynb # Artefact #1: Jupyter notebook for model training and evaluation (actual was done using .py files)
├── confusion_matrix.ipynb
├── requirements.txt
├── README.MD
├── data
│ ├── annotations
│ └── car_ims # This data folder has been removed to save space
├── docker
│ ├── docker-compose.yml
│ └── inference.Dockerfile # Artefact #3: Dockerfile to containerize API
├── runs # location of tensorboard run files
├── models # location of .pth files
└── src
├── api
│ └── fastapi # Artefact #2: Source code file(s) for API
├── config
│ ├── config.yml # Artefact #2: Config file
│ └── load_config.py # Artefact #2: .py to load config
├── dataset.py # Artefact #2: .py to initialize custom dataset
├── model.py # Artefact #2: .py to initialize model
└── train.py
Application has been containerized using docker compose for ease of deployment.
-
To run the fastapi server, please use the command:
docker compose -f docker/docker-compose.yml up -d
-
Once running you can go to the UI using your local browser at
http://localhost:4000/docs
-
To stop the fastAPI server, please use the command:
docker compose -f docker/docker-compose.yml down
-
To remove existing docker images
docker image rm fastapi-server-cars:0.1.0
- Images are not flipped and in the correct orientation
- Bounding boxes provided are all correct with no errors
- As the bounding box data allowed for a closer crop of the target image
- Created a toggle to allow for training of images either cropped to bounding box or not
- Generally found that cropping the image did not improve the inference
- Config file provided to allow for customization of the training.
- Batch size selected to be maximum that could be fit into vram memory.
- No hyperparameter tuning was used.
The model selected was a standard resnet. Several different versions were tested either with 50 or 101 layers
Considerations for model selection
-
Able to be retrained within timeline (<1 day) with fairly accurate results
- Already pretrained on imagenet
- Performs well across various machine learning classification tasks
-
Reasonable model architecture
- Model comes with different depth and weights
- Generally found that the larger model (ResNet101) was able to deliver better accuracy given same parameters
- Model has reasonable depth and size to be able to get baseline classification
- Model makes use of skip connections to allow gradients to flow directly accross network
During the training and validation phases the model training loss, validation loss and validation accuracy were logged using tensorboard.
These outputs were logged using tensorboard. Tensorboard can be run through:
tensorboard --logdir=runs --port 6006
Once running the port can be accessed at localhost:6006
.
To analyze the output on the test set, a Confusion Matrix was also generated: