yolov7
yolov7 copied to clipboard
Error at the end of custom data training. And how to remove bounding box in instance segmentation.
- @WongKinYiu Hi, first of all thank you for adding the u7 branch. I have manage to train on custom dataset using transfer learning. However i encountered an error at the end of training, i am not sure where this error is coming, what could be the solution for this?
Epoch GPU_mem box_loss seg_loss obj_loss cls_loss Instances Size
213/299 13.8G 0.02478 0.01905 0.03724 0.001741 444 640: 100%|██████████| 9/9 [00:02<00:00, 3.18it/s]
Class Images Instances Box(P R mAP50 mAP50-95) Mask(P R mAP50 mAP50-95): 1
all 15 243 0.979 0.477 0.494 0.317 0.968 0.45 0.481 0.258
Stopping training early as no improvement observed in last 100 epochs. Best results observed at epoch 113, best model saved as best.pt.
To update EarlyStopping(patience=100) pass a new patience value, i.e. `python train.py --patience 300` or use `--patience 0` to disable EarlyStopping.
214 epochs completed in 0.252 hours.
Optimizer stripped from runs/train-seg/yolov7-seg17/weights/last.pt, 76.2MB
Optimizer stripped from runs/train-seg/yolov7-seg17/weights/best.pt, 76.2MB
Validating runs/train-seg/yolov7-seg17/weights/best.pt...
Fusing layers...
yolov7-seg summary: 325 layers, 37847870 parameters, 0 gradients, 141.9 GFLOPs
Class Images Instances Box(P R mAP50 mAP50-95) Mask(P R mAP50 mAP50-95):
Traceback (most recent call last):
File "segment/train.py", line 681, in <module>
main(opt)
File "segment/train.py", line 577, in main
train(opt.hyp, opt, device, callbacks)
File "segment/train.py", line 442, in train
results, _, _ = validate.run(
File "/home/jsm04/Documents/Enviroments/yolo_seg/lib/python3.8/site-packages/torch/autograd/grad_mode.py", line 27, in decorate_context
return func(*args, **kwargs)
File "/media/Nessus/jsm04/4th_year/yolo_seg/yolov7_u7/seg/segment/val.py", line 255, in run
out, train_out = model(im) # if training else model(im, augment=augment, val=True) # inference, loss
File "/home/jsm04/Documents/Enviroments/yolo_seg/lib/python3.8/site-packages/torch/nn/modules/module.py", line 1130, in _call_impl
return forward_call(*input, **kwargs)
File "/media/Nessus/jsm04/4th_year/yolo_seg/yolov7_u7/seg/models/yolo.py", line 300, in forward
return self._forward_once(x, profile, visualize) # single-scale inference, train
File "/media/Nessus/jsm04/4th_year/yolo_seg/yolov7_u7/seg/models/yolo.py", line 212, in _forward_once
x = m(x) # run
File "/home/jsm04/Documents/Enviroments/yolo_seg/lib/python3.8/site-packages/torch/nn/modules/module.py", line 1130, in _call_impl
return forward_call(*input, **kwargs)
File "/media/Nessus/jsm04/4th_year/yolo_seg/yolov7_u7/seg/models/yolo.py", line 179, in forward
x = self.detect(self, x)
File "/media/Nessus/jsm04/4th_year/yolo_seg/yolov7_u7/seg/models/yolo.py", line 131, in forward
xy = (xy * 2 + self.grid[i]) * self.stride[i] # xy
RuntimeError: Expected all tensors to be on the same device, but found at least two devices, cuda:0 and cpu!
- Since after training the weights were saved i was able to validate and predict using the files under segment. However, i wanted to remove the bounding box and the class name in the final predicted image. How can i tackle that?
Once again thanks and your feedback will be very much appreciated.
For the 2nd question i figured! I commented these lines and it worked.
# if save_img or save_crop or view_img: # Add bbox to image
# c = int(cls) # integer class
# label = None if hide_labels else (names[c] if hide_conf else f'{names[c]} {conf:.2f}')
# annotator.box_label(xyxy, label, color=colors(c, True))
# if save_crop:
# save_one_box(xyxy, imc, file=save_dir / 'crops' / names[c] / f'{p.stem}.jpg', BGR=True)
hi you, you can me teach me how to creat label for data. tks you
@chelsea456 Hi you can use roboflow or VGG annotator or labelme to label your data. If you are using robflow you should be able to extract the annotation in the form of YOLO v5. But if you are using VGG or Labelme, you can add your annotation file in the form of COCO format and then convert it to YOLOv5 format. Once you have that you should change a few things in the data folder for the segmentation. Good luck.
1st question is fixed.
@WongKinYiu Hey thanks, does this mean i should clone the updated version or should i change something in train.py file?
https://github.com/WongKinYiu/yolov7/commit/24f87b02424362efee9e7d386eeb8e64030375b2#diff-c0003d3eaede68e73ef1146eb29d1a32c010214a84b610b1886778bb36913497R248
@WongKinYiu Thanks it works.
Was just wondering how to extract only the mask from the test,py file. For example to calculate the area from the mask. Any Idea on that?
how to solve the 1st?