WongKinYiu / yolor

implementation of paper - You Only Learn One Representation: Unified Network for Multiple Tasks (https://arxiv.org/abs/2105.04206)
GNU General Public License v3.0
1.98k stars 524 forks source link

yolor_d6 cfg #140

Open Wooks-git opened 2 years ago

Wooks-git commented 2 years ago

Hi. where can i get yolord6.cfg file?

Deadpool5549 commented 2 years ago

Or tell us how to modify p6 or w6 cfg files to train a d6 model, Thanks

Somu-cSs commented 2 years ago

You can use the YAML file on paper branch.

mattmorgan6 commented 2 years ago

You can use the YAML file on paper branch.

Hi, I've found the YAML file. How do I convert the YAML to .cfg? Or is there a way to train with the YAML and not a .cfg? Thanks!

Deadpool5549 commented 2 years ago

Hi Matt! the training command in paper branch looks like this python train.py --batch-size 8 --img 1280 1280 --data data/coco.yaml **--cfg models/yolor-p6.yaml** --weights '' --device 0 --name yolor-p6 --hyp hyp.scratch.1280.yaml --epochs 300 I think you can use the YAML files directly.

mattmorgan6 commented 2 years ago

@Deadpool5549 Thanks for the help! That worked. I was getting an error originally because I was trying to use the models/yolor-d6.yaml on the main branch train.py when I should have been using the paper branch train.py. I ended up with better mAP@0.5 with yolor-w6 than yolor-d6 though.

rusvagzur commented 2 years ago

Hi I was wondering how to use D6 for inference with detect.py? by using the yolo_d6.yaml it does not work.

Deadpool5549 commented 2 years ago

Hi, this is the command I used for inference . Hope it helps ;) python detect.py --weights "path to weights" --conf <confidence value here> --source "path to video/image file/folder here"

rusvagzur commented 2 years ago

@Deadpool5549 Thanks for the hint. however in your command, the config d6 is not being indicated. How are you doing it?

Deadpool5549 commented 2 years ago

You're welcome, I don't think we need it, maybe because we already have weight.pt file.

santhoshnumberone commented 2 years ago

Hi. where can i get yolord6.cfg file?

I was having same doubt, I check in the repo for more info.

Inside WongKinYiu/yolor/tree/paper/models/yolo.py file Line 326 parser.add_argument('--cfg', type=str, default='yolov5s.yaml', help='model.yaml') You can find yolor-d6.yaml WongKinYiu/yolor/tree/paper/models/yolor-d6.yaml

File Location/Link
yolor-d6.yaml https://github.com/WongKinYiu/yolor/tree/paper/models/yolor-d6.yaml
yolor-d6.pt https://drive.google.com/file/d/1WX33ymg_XJLUJdoSf5oUYGHAtpSG2gj8/view or https://github.com/WongKinYiu/yolor/tree/paper

Hope this clears doubt for future visitors 🖖

Looking at the arguments the files require. WongKinYiu/yolor/tree/paper/detect.py cfg not required

parser = argparse.ArgumentParser()
    parser.add_argument('--weights', nargs='+', type=str, default='yolor-p6.pt', help='model.pt path(s)')
    parser.add_argument('--source', type=str, default='inference/images', help='source')  # file/folder, 0 for webcam
    parser.add_argument('--img-size', type=int, default=1280, help='inference size (pixels)')
    parser.add_argument('--conf-thres', type=float, default=0.25, help='object confidence threshold')
    parser.add_argument('--iou-thres', type=float, default=0.45, help='IOU threshold for NMS')
    parser.add_argument('--device', default='', help='cuda device, i.e. 0 or 0,1,2,3 or cpu')
    parser.add_argument('--view-img', action='store_true', help='display results')
    parser.add_argument('--save-txt', action='store_true', help='save results to *.txt')
    parser.add_argument('--save-conf', action='store_true', help='save confidences in --save-txt labels')
    parser.add_argument('--classes', nargs='+', type=int, help='filter by class: --class 0, or --class 0 2 3')
    parser.add_argument('--agnostic-nms', action='store_true', help='class-agnostic NMS')
    parser.add_argument('--augment', action='store_true', help='augmented inference')
    parser.add_argument('--update', action='store_true', help='update all models')
    parser.add_argument('--project', default='runs/detect', help='save results to project/name')
    parser.add_argument('--name', default='exp', help='save results to project/name')
    parser.add_argument('--exist-ok', action='store_true', help='existing project/name ok, do not increment')
    opt = parser.parse_args()
    print(opt)

    with torch.no_grad():
        if opt.update:  # update all models (to fix SourceChangeWarning)
            for opt.weights in ['yolor-p6.pt', 'yolor-w6.pt', 'yolor-e6.pt', 'yolor-d6.pt']:
                detect()
                strip_optimizer(opt.weights)
        else:
            detect()

WongKinYiu/yolor/tree/paper/train.py cfg not required but you can specify

    parser = argparse.ArgumentParser()
    parser.add_argument('--weights', type=str, default='yolor-p6.pt', help='initial weights path')
    parser.add_argument('--cfg', type=str, default='', help='model.yaml path')
    parser.add_argument('--data', type=str, default='data/coco.yaml', help='data.yaml path')
    parser.add_argument('--hyp', type=str, default='data/hyp.scratch.1280.yaml', help='hyperparameters path')
    parser.add_argument('--epochs', type=int, default=300)
    parser.add_argument('--batch-size', type=int, default=8, help='total batch size for all GPUs')
    parser.add_argument('--img-size', nargs='+', type=int, default=[1280, 1280], help='[train, test] image sizes')
    parser.add_argument('--rect', action='store_true', help='rectangular training')
    parser.add_argument('--resume', nargs='?', const=True, default=False, help='resume most recent training')
    parser.add_argument('--nosave', action='store_true', help='only save final checkpoint')
    parser.add_argument('--notest', action='store_true', help='only test final epoch')
    parser.add_argument('--noautoanchor', action='store_true', help='disable autoanchor check')
    parser.add_argument('--evolve', action='store_true', help='evolve hyperparameters')
    parser.add_argument('--bucket', type=str, default='', help='gsutil bucket')
    parser.add_argument('--cache-images', action='store_true', help='cache images for faster training')
    parser.add_argument('--image-weights', action='store_true', help='use weighted image selection for training')
    parser.add_argument('--device', default='', help='cuda device, i.e. 0 or 0,1,2,3 or cpu')
    parser.add_argument('--multi-scale', action='store_true', help='vary img-size +/- 50%%')
    parser.add_argument('--single-cls', action='store_true', help='train as single-class dataset')
    parser.add_argument('--adam', action='store_true', help='use torch.optim.Adam() optimizer')
    parser.add_argument('--sync-bn', action='store_true', help='use SyncBatchNorm, only available in DDP mode')
    parser.add_argument('--local_rank', type=int, default=-1, help='DDP parameter, do not modify')
    parser.add_argument('--log-imgs', type=int, default=16, help='number of images for W&B logging, max 100')
    parser.add_argument('--workers', type=int, default=8, help='maximum number of dataloader workers')
    parser.add_argument('--project', default='runs/train', help='save to project/name')
    parser.add_argument('--name', default='exp', help='save to project/name')
    parser.add_argument('--exist-ok', action='store_true', help='existing project/name ok, do not increment')
    opt = parser.parse_args()