Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat/Improve Yolo-v4 Model #149

Open
wants to merge 31 commits into
base: main
Choose a base branch
from
Open

Conversation

hughjazzman
Copy link
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 [email protected] (155 images) [email protected] (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
@yarkhinephyo
Copy link
Member

Also can fix the suggestions by CodeFactor check

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
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

Obtains predicted boxes for predict_microservice
"""

def run(self, img, width_dict):
Copy link
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
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
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))


return self.get_filtered_boxes(img, height, width)

def get_filtered_boxes(self, img, height, width):
Copy link
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
model_training/local_prediction/local_inference.py Outdated Show resolved Hide resolved
model_training/local_prediction/train_test_split/test.txt Outdated Show resolved Hide resolved
model_training/local_prediction/README.md Outdated Show resolved Hide resolved
model_training/local_prediction/README.md Show resolved Hide resolved
lambda_backend/predict_microservice/service_inference.py Outdated Show resolved Hide resolved
lambda_backend/predict_microservice/base_inference.py Outdated Show resolved Hide resolved
model_training/local_prediction/base_inference.py Outdated Show resolved Hide resolved
lambda_backend/predict_microservice/base_inference.py Outdated Show resolved Hide resolved
model_training/local_prediction/base_inference.py Outdated Show resolved Hide resolved
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