Object_Detection: NanoDet (GSOC)
Updated files for object detection using YOLOX, files uploaded for review:
- Model files (.onnx format FP16)
- Model: Nanodet-plus-m-1.5x-416
- README
- LICENSE (Apache 2.0)
- demo.py (with image and webcam inference options)
- NanoDet.py (class NanoDet)
- examples (test_data: test images, results: inferred results)
- COCO class names (coco.names)
COMPLETED:
- [x] Model upload
- [x] demo file
- [x] NanoDet file
- [x] Example inference (image and webcam)
TO DO:
- [x] Model quantization
This PR is for NanoDet, so please remove the object_detection_yolox directory.
removed yolox directory
Yes, resolving the changes
On Sun, Sep 4, 2022 at 7:38 AM Yuantao Feng @.***> wrote:
@.**** commented on this pull request.
In models/object_detection_nanodet/NanodetPlus.py https://github.com/opencv/opencv_zoo/pull/87#discussion_r962228626:
with open('coco.names', 'rt') as f:
self.classes = f.read().rstrip('\n').split('\n')Lets keep all classes here in this file like this https://github.com/open-mmlab/mmdetection/blob/df28da98926bc410e16bed1e9fc7d425d9a89495/mmdet/datasets/coco.py#L25-L38
In models/object_detection_nanodet/NanodetPlus.py https://github.com/opencv/opencv_zoo/pull/87#discussion_r962228759:
top, left, newh, neww = 0, 0, self.image_shape[0], self.image_shape[1]
if keep_ratio and srcimg.shape[0] != srcimg.shape[1]:hw_scale = srcimg.shape[0] / srcimg.shape[1]if hw_scale > 1:newh, neww = self.image_shape[0], int(self.image_shape[1] / hw_scale)img = cv2.resize(srcimg, (neww, newh), interpolation=cv2.INTER_AREA)left = int((self.image_shape[1] - neww) * 0.5)img = cv2.copyMakeBorder(img, 0, 0, left, self.image_shape[1] - neww - left, cv2.BORDER_CONSTANT,value=0) # add borderelse:newh, neww = int(self.image_shape[0] * hw_scale), self.image_shape[1]img = cv2.resize(srcimg, (neww, newh), interpolation=cv2.INTER_AREA)top = int((self.image_shape[0] - newh) * 0.5)img = cv2.copyMakeBorder(img, top, self.image_shape[0] - newh - top, 0, 0, cv2.BORDER_CONSTANT, value=0)else:img = cv2.resize(srcimg, self.image_shape, interpolation=cv2.INTER_AREA)blob = self.pre_process(img)Can we reuse the code from yolox for letterbox preprocessing?
In models/object_detection_nanodet/NanodetPlus.py https://github.com/opencv/opencv_zoo/pull/87#discussion_r962228839:
value=0) # add border
else:newh, neww = int(self.image_shape[0] * hw_scale), self.image_shape[1]img = cv2.resize(srcimg, (neww, newh), interpolation=cv2.INTER_AREA)top = int((self.image_shape[0] - newh) * 0.5)img = cv2.copyMakeBorder(img, top, self.image_shape[0] - newh - top, 0, 0, cv2.BORDER_CONSTANT, value=0)else:img = cv2.resize(srcimg, self.image_shape, interpolation=cv2.INTER_AREA)blob = self.pre_process(img)self.net.setInput(blob)outs = self.net.forward(self.net.getUnconnectedOutLayersNames())det_bboxes, det_conf, det_classid = self.post_process(outs)ratioh,ratiow = srcimg.shape[0]/newh,srcimg.shape[1]/newwreturn left, top, ratioh, ratiow, det_bboxes, det_conf, det_classidI propose to have the same formatting of results of yolox.
In models/object_detection_nanodet/coco.names https://github.com/opencv/opencv_zoo/pull/87#discussion_r962228905:
@@ -0,0 +1,80 @@ +person
This file is not needed if we keep these classes in the wrapper class.
In models/object_detection_nanodet/demo.py https://github.com/opencv/opencv_zoo/pull/87#discussion_r962228939:
if(Video_save):
clip = moviepy.video.io.ImageSequenceClip.ImageSequenceClip(frame_list, fps=fps)clip.write_videofile('Webcam_result.mp4')Use VideoWriter instead.
— Reply to this email directly, view it on GitHub https://github.com/opencv/opencv_zoo/pull/87#pullrequestreview-1095584259, or unsubscribe https://github.com/notifications/unsubscribe-auth/ALTC7V6AFWSL5FZ72IKDEKDV4QAANANCNFSM57AGTIAA . You are receiving this because you authored the thread.Message ID: @.***>
@Sidd1609 could you squash commits into one? I am going to work on this pr and merge it.
Changes have been made for nanodet And yolox commits have been updated in separate branch
On Fri, Oct 21, 2022 at 12:37 PM Yuantao Feng @.***> wrote:
@Sidd1609 https://github.com/Sidd1609 could you squash commits into one? I am going to work on this pr and merge it.
— Reply to this email directly, view it on GitHub https://github.com/opencv/opencv_zoo/pull/87#issuecomment-1286548654, or unsubscribe https://github.com/notifications/unsubscribe-auth/ALTC7V3SWF7K6DDP2F5W6OTWEI6MHANCNFSM57AGTIAA . You are receiving this because you were mentioned.Message ID: @.***>
close in favor of https://github.com/opencv/opencv_zoo/pull/103