Skip to content

Latest commit

 

History

History
49 lines (38 loc) · 2.06 KB

GETTING_STARTED.md

File metadata and controls

49 lines (38 loc) · 2.06 KB

Getting Started with HCFormer

This document provides a brief intro of the usage of HCFormer.

Please see Getting Started with Detectron2 for full usage.

Inference Demo with Pre-trained Models

We provide demo.py that is able to demo builtin configs. Run it with:

cd demo/
python demo.py --config-file ../configs/coco/panoptic-segmentation/swin/hcformer+_swin_large_IN21k_384_bs16_200ep.yaml \
  --input input1.jpg input2.jpg \
  [--other-options]
  --opts MODEL.WEIGHTS /path/to/checkpoint_file

The configs are made for training, therefore we need to specify MODEL.WEIGHTS to a model for evaluation. This command will run the inference and show visualizations in an OpenCV window.

For details of the command line arguments, see demo.py -h or look at its source code to understand its behavior. Some common arguments are:

  • To run on your webcam, replace --input files with --webcam.
  • To run on a video, replace --input files with --video-input video.mp4.
  • To run on cpu, add MODEL.DEVICE cpu after --opts.
  • To save outputs to a directory (for images) or a file (for webcam or video), use --output.

The pre-trained model (HCFormer+ with SwinL backbone trained on COCO panoptic segmentation) can be downloaded from here.

Training & Evaluation in Command Line

We provide a script train_net.py, that is made to train all the configs provided in HCFormer.

To train a model with "train_net.py", first setup the corresponding datasets following datasets/README.md, then run:

python train_net.py --num-gpus 8 \
  --config-file configs/coco/panoptic-segmentation/hcformer_R50_bs16_50ep.yaml

To evaluate a model's performance, use

python train_net.py \
  --config-file configs/coco/panoptic-segmentation/hcformer_R50_bs16_50ep.yaml \
  --eval-only MODEL.WEIGHTS /path/to/checkpoint_file

For more options, see python train_net.py -h.