Arulkumar03/Wheat_HEAD_Detection_Counting_ComputerVision_Model
0
1## Getting Started with Detectron22 3This document provides a brief intro of the usage of builtin command-line tools in detectron2.4 5For a tutorial that involves actual coding with the API,6see our [Colab Notebook](https://colab.research.google.com/drive/16jcaJoc6bCFAQ96jDe2HwtXj7BMD_-m5)7which covers how to run inference with an8existing model, and how to train a builtin model on a custom dataset.9 10 11### Inference Demo with Pre-trained Models12 131. Pick a model and its config file from14 [model zoo](MODEL_ZOO.md),15 for example, `mask_rcnn_R_50_FPN_3x.yaml`.162. We provide `demo.py` that is able to demo builtin configs. Run it with:17```18cd demo/19python demo.py --config-file ../configs/COCO-InstanceSegmentation/mask_rcnn_R_50_FPN_3x.yaml \20 --input input1.jpg input2.jpg \21 [--other-options]22 --opts MODEL.WEIGHTS detectron2://COCO-InstanceSegmentation/mask_rcnn_R_50_FPN_3x/137849600/model_final_f10217.pkl23```24The configs are made for training, therefore we need to specify `MODEL.WEIGHTS` to a model from model zoo for evaluation.25This command will run the inference and show visualizations in an OpenCV window.26 27For details of the command line arguments, see `demo.py -h` or look at its source code28to understand its behavior. Some common arguments are:29* To run __on your webcam__, replace `--input files` with `--webcam`.30* To run __on a video__, replace `--input files` with `--video-input video.mp4`.31* To run __on cpu__, add `MODEL.DEVICE cpu` after `--opts`.32* To save outputs to a directory (for images) or a file (for webcam or video), use `--output`.33 34 35### Training & Evaluation in Command Line36 37We provide two scripts in "tools/plain_train_net.py" and "tools/train_net.py",38that are made to train all the configs provided in detectron2. You may want to39use it as a reference to write your own training script.40 41Compared to "train_net.py", "plain_train_net.py" supports fewer default42features. It also includes fewer abstraction, therefore is easier to add custom43logic.44 45To train a model with "train_net.py", first46setup the corresponding datasets following47[datasets/README.md](./datasets/README.md),48then run:49```50cd tools/51./train_net.py --num-gpus 8 \52 --config-file ../configs/COCO-InstanceSegmentation/mask_rcnn_R_50_FPN_1x.yaml53```54 55The configs are made for 8-GPU training.56To train on 1 GPU, you may need to [change some parameters](https://arxiv.org/abs/1706.02677), e.g.:57```58./train_net.py \59 --config-file ../configs/COCO-InstanceSegmentation/mask_rcnn_R_50_FPN_1x.yaml \60 --num-gpus 1 SOLVER.IMS_PER_BATCH 2 SOLVER.BASE_LR 0.002561```62 63To evaluate a model's performance, use64```65./train_net.py \66 --config-file ../configs/COCO-InstanceSegmentation/mask_rcnn_R_50_FPN_1x.yaml \67 --eval-only MODEL.WEIGHTS /path/to/checkpoint_file68```69For more options, see `./train_net.py -h`.70 71### Use Detectron2 APIs in Your Code72 73See our [Colab Notebook](https://colab.research.google.com/drive/16jcaJoc6bCFAQ96jDe2HwtXj7BMD_-m5)74to learn how to use detectron2 APIs to:751. run inference with an existing model762. train a builtin model on a custom dataset77 78See [detectron2/projects](https://github.com/facebookresearch/detectron2/tree/main/projects)79for more ways to build your project on detectron2.80 