-
Notifications
You must be signed in to change notification settings - Fork 11
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
base: main
Are you sure you want to change the base?
Conversation
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): |
There was a problem hiding this comment.
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): |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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): |
There was a problem hiding this comment.
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
?
Summary
The model has been improved, trained on more images, totaling 211 images. The inference code has also been refactored to improve maintainability.
Comparison
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. Seebase_inference.py
,local_inference.py
,service_inference.py
. The predict_microservice has not yet been tested.