Skip to content

Feat/Improve Yolo-v4 Model#149

Open
hughjazzman wants to merge 31 commits intonandium:mainfrom
hughjazzman:main
Open

Feat/Improve Yolo-v4 Model#149
hughjazzman wants to merge 31 commits intonandium:mainfrom
hughjazzman:main

Conversation

@hughjazzman
Copy link
Copy Markdown
Collaborator

Summary

The model has been improved, trained on more images, totaling 211 images. The inference code has also been refactored to improve maintainability.

Comparison

Model mAP@0.5 (155 images) mAP@0.5 (56 new images)
Old ~68% ~82%
New ~79% ~90%

Old model was trained on 155 images, new model trained on 211 images. This table shows results which uses each model's own test split for 155 images, and the new model's test split for 56 new images.

Possible Improvement

With more compute time/power, k-fold cross validation could be used to improve performance on such a tiny dataset.

Refactor

Inference classes have been created for the detection process. See base_inference.py, local_inference.py, service_inference.py. The predict_microservice has not yet been tested.

@hughjazzman hughjazzman added the enhancement New feature or request label Jul 29, 2021
@hughjazzman hughjazzman requested a review from yarkhinephyo July 29, 2021 09:09
@hughjazzman hughjazzman self-assigned this Jul 29, 2021
Comment thread lambda_backend/predict_microservice/base_inference.py Outdated
@yarkhinephyo
Copy link
Copy Markdown
Member

Also can fix the suggestions by CodeFactor check

Comment thread lambda_backend/predict_microservice/base_inference.py Outdated
Comment thread lambda_backend/predict_microservice/base_inference.py Outdated
Comment thread lambda_backend/predict_microservice/base_inference.py Outdated
layer_names = self.net.getLayerNames()
self.output_layers = [layer_names[i[0] - 1] for i in self.net.getUnconnectedOutLayers()]

def read_config(self):
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Similarly for this too. Maybe can put assert to check net.height and net.width are present in .cfg

Comment thread lambda_backend/predict_microservice/base_inference.py
Comment thread lambda_backend/predict_microservice/service_inference.py
Comment thread lambda_backend/predict_microservice/service_inference.py Outdated
Obtains predicted boxes for predict_microservice
"""

def run(self, img, width_dict):
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Validation of numpy matrix as input too

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe the input for both handler.py and local_inference.py is cv2.Mat, from cv2.imdecode and cv2.imread respectively. cv2.dnn.blobFromImage does accept a generic InputArray as image.

What should the validation here be for exactly?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

InputArray should be an interface for Mat. Since python numpy.ndarray is a binding to openCv Mat type. The validation should be numpy.ndarray. I think you can check with print(type(img))

Comment thread lambda_backend/predict_microservice/base_inference.py Outdated
Comment thread model_training/local_prediction/local_inference.py Outdated

return self.get_filtered_boxes(img, height, width)

def get_filtered_boxes(self, img, height, width):
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can add validation to check if img is of the correct data type, numpy.ndarray?

@yarkhinephyo yarkhinephyo requested a review from qwoprocks July 29, 2021 14:13
Comment thread model_training/local_prediction/local_inference.py Outdated
Comment thread model_training/local_prediction/train_test_split/test.txt Outdated
Comment thread model_training/local_prediction/README.md Outdated
Comment thread model_training/local_prediction/README.md
Comment thread lambda_backend/predict_microservice/service_inference.py Outdated
Comment thread lambda_backend/predict_microservice/base_inference.py Outdated
Comment thread model_training/local_prediction/base_inference.py Outdated
Comment thread lambda_backend/predict_microservice/base_inference.py Outdated
Comment thread model_training/local_prediction/base_inference.py Outdated
Comment thread lambda_backend/predict_microservice/base_inference.py
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants