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
replace RetinaNet with YOLOv5 #8
Comments
Hello, your effect on RetinaNet can reach the mAP of 93%, but not good for modified yolov5. It seems to be an incompatibility between the part of your code and the source code here.
|
Thanks for quick reply. I understand there must be something wrong with my code because yolov5 cannot detect anything. I will contact Shimadaaaaa for more details. |
Do you know the contact details of Shimadaaaaa? Could not find any way to contact |
Preset more rotated anchors can achieve further improvement in my experiment (not shown in the paper). |
Have you solved the problem? @xjsxujingsong |
Hi, I tried to replace RetinaNet with YOLOv5 to get faster speed. The traning loss can decrease but mAP is always low. It cannot detect anything. Before replacement, I can sucessfully get 93% mAP using the default setting (RetinaNet). Could you please tell me if I miss anything here? I read the code about anchor part. It looks like only rectangle anchor is used, but i did not notice where is the way to resize the predicted box to original image corrdinate, and what is the purpose of weights in class BoxCoder
weights=(10., 10., 10., 5., 15.)
Here is the part I changed. I make anthor copy of yolo.py in YOLOv5/models. Only change the Detect class to replace cls head and reg head in RetinaNet. I also changed in anchor.py to reduce the pyramid level from 5 to 3 as in YOLOv5. self.pyramid_levels = [3, 4, 5]
class Detect(nn.Module):
def init(self, nc=80, anchors=(), ch=()): # detection layer
super(Detect, self).init()
self.nc = nc + 1 # number of classes
self.nr = 5 #xywha
self.na = 3 #len(anchors[0]) // 2 # number of anchors
self.cls_head = nn.ModuleList(nn.Conv2d(x, self.na * self.nc, 3, 1, 1) for x in ch) # output conv
self.reg_head = nn.ModuleList(nn.Conv2d(x, self.na * self.nr, 3, 1, 1) for x in ch) # output conv
self.init_weights()
I define another class to replace class RetinaNet, by only change a few lines.
class YOLOV5(nn.Module):
def init(self, cfg='yolov5l.yaml', ch=3, nc=None, export=False):
super(YOLOV5, self).init()
self.yolov5 = Model(cfg)
self.num_classes = 1 + 1 # class number + 1, I only have one class in the dataset
self.anchor_generator = Anchors(
ratios = np.array([0.5,1,2]),
)
self.num_anchors = self.anchor_generator.num_anchors
self.loss = IntegratedLoss(func='smooth')
self.box_coder = BoxCoder()
..........the other parts are the same.
The text was updated successfully, but these errors were encountered: