### Train FasterNet-T0 on ImageNet-1K (8-GPU) Source: https://github.com/jierunchen/fasternet/blob/master/README.MD Example command for training FasterNet-T0 on ImageNet-1K using 8 GPUs. Modify configuration, batch size, and other parameters as required for different variants or setups. ```bash python train_test.py -g 0,1,2,3,4,5,6,7 --num_nodes 1 -n 4 -b 4096 -e 2000 \ --data_dir ../../data/imagenet --pin_memory --wandb_project_name fasternet \ --model_ckpt_dir ./model_ckpt/$(date +'%Y%m%d_%H%M%S') --cfg cfg/fasternet_t0.yaml ``` -------------------------------- ### Install Project Dependencies Source: https://github.com/jierunchen/fasternet/blob/master/requirements.txt Installs all Python packages listed in the requirements.txt file. ```bash # pip install -r requirements.txt ``` -------------------------------- ### Clone Repository and Install Dependencies Source: https://github.com/jierunchen/fasternet/blob/master/README.MD Clones the FasterNet repository and installs all required Python packages listed in 'requirements.txt'. ```bash git clone https://github.com/JierunChen/FasterNet cd FasterNet/ pip install -r requirements.txt ``` -------------------------------- ### Install Detection Dependencies Source: https://github.com/jierunchen/fasternet/blob/master/detection/README.MD Install mmcv and mmdet for object detection tasks. Ensure compatibility with your CUDA version. ```bash pip install mmcv-full==1.6.0 -f https://download.openmmlab.com/mmcv/dist/cu113/torch1.11.0/index.html pip install mmdet==2.25.0 ``` -------------------------------- ### Evaluate FasterNet-T0 on ImageNet-1K Source: https://github.com/jierunchen/fasternet/blob/master/README.MD Example command to evaluate a pre-trained FasterNet-T0 model on ImageNet-1K using a single GPU. Adjust checkpoint path and data directory as needed. ```bash python train_test.py -c cfg/fasternet_t0.yaml \ --checkpoint_path model_ckpt/fasternet_t0-epoch=281-val_acc1=71.9180.pth \ --data_dir ../../data/imagenet --test_phase -g 1 -e 125 ``` -------------------------------- ### PyTorch Installation with CUDA Source: https://github.com/jierunchen/fasternet/blob/master/requirements.txt Installs PyTorch version 1.11.0 and Torchvision version 0.12.0 with CUDA 11.3 support. ```bash # --extra-index-url https://download.pytorch.org/whl/cu113 torch==1.11.0 torchvision==0.12.0 ``` -------------------------------- ### Install MMDetection with CUDA Source: https://github.com/jierunchen/fasternet/blob/master/requirements.txt Installs MMDetection version 2.25.0 with specific dependencies for CUDA 11.3 and PyTorch 1.11.0. ```bash # pip install mmcv-full==1.6.0 -f https://download.openmmlab.com/mmcv/dist/cu113/torch1.11.0/index.html # pip install mmdet==2.25.0 ``` -------------------------------- ### Create and Activate Conda Environment Source: https://github.com/jierunchen/fasternet/blob/master/README.MD Sets up a new conda virtual environment named 'fasternet' with Python 3.9.12 and activates it. ```bash conda create -n fasternet python=3.9.12 -y conda activate fasternet ``` -------------------------------- ### Create Conda Environment Source: https://github.com/jierunchen/fasternet/blob/master/requirements.txt Creates a Conda environment named 'fasternet' with Python 3.9.12. ```bash # conda create -n fasternet python=3.9.12 -y ``` -------------------------------- ### Activate Conda Environment Source: https://github.com/jierunchen/fasternet/blob/master/requirements.txt Activates the Conda environment named 'fasternet'. ```bash # conda activate fasternet ``` -------------------------------- ### ImageNet-1K Dataset Structure Source: https://github.com/jierunchen/fasternet/blob/master/README.MD Illustrates the required directory structure for the ImageNet-1K dataset for image classification tasks. ```text /path/to/imagenet-1k/ train/ class1/ img1.jpeg class2/ img2.jpeg val/ class1/ img3.jpeg class2/ img4.jpeg ``` -------------------------------- ### Measure Latency and Throughput Source: https://github.com/jierunchen/fasternet/blob/master/README.MD Command to measure model latency on CPU/ARM and throughput on GPU, with options for fused convolution and batch size. ```bash python train_test.py -c cfg/fasternet_t0.yaml \ --checkpoint_path model_ckpt/fasternet_t0-epoch=281-val_acc1=71.9180.pth \ --data_dir ../../data/imagenet --test_phase -g 1 -e 32 --measure_latency --fuse_conv_bn ``` -------------------------------- ### Measure GPU Throughput Source: https://github.com/jierunchen/fasternet/blob/master/detection/README.MD Measure the inference throughput of FasterNet on a GPU. This command uses PyTorch distributed launcher for benchmarking. ```python CUDA_VISIBLE_DEVICES=0 python -m torch.distributed.launch --nproc_per_node=1 --master_port=29500 \ benchmark.py configs/fasternet/mask_rcnn_fasternet_s_fpn_1x_coco.py \ ckpts/mask_rcnn_fasternet_s_fpn_1x_coco_20221111_063419.pth --launcher pytorch --fuse-conv-bn ``` -------------------------------- ### Train FasterNet on COCO Source: https://github.com/jierunchen/fasternet/blob/master/detection/README.MD Train FasterNet-T0 + Mask R-CNN on COCO train2017 using 8 GPUs. This command specifies the configuration file, number of GPUs, work directory, and a pre-trained model checkpoint. ```bash CUDA_VISIBLE_DEVICES=0,1,2,3,4,5,6,7 bash ./dist_train.sh \ configs/fasternet/mask_rcnn_fasternet_s_fpn_1x_coco.py 8 \ --work-dir work_dirs/mask_rcnn_fasternet_s_fpn_1x_coco/$(date +'%Y%m%d_%H%M%S') \ --cfg-options model.pretrained=../model_ckpt/fasternet_t0-epoch=281-val_acc1=71.9180.pth ``` -------------------------------- ### Measure FLOPs Source: https://github.com/jierunchen/fasternet/blob/master/detection/README.MD Calculate the Floating Point Operations (FLOPs) for a given FasterNet configuration. ```python python get_flops.py configs/fasternet/mask_rcnn_fasternet_s_fpn_1x_coco.py ``` -------------------------------- ### Evaluate FasterNet on COCO Source: https://github.com/jierunchen/fasternet/blob/master/detection/README.MD Evaluate FasterNet-T0 + Mask R-CNN on COCO val2017 using multiple GPUs. This command performs both bounding box and segmentation evaluation. ```bash bash ./dist_test.sh configs/fasternet/mask_rcnn_fasternet_s_fpn_1x_coco.py \ ckpts/mask_rcnn_fasternet_s_fpn_1x_coco_20221111_063419.pth 8 --eval bbox segm ``` -------------------------------- ### FasterNet Citation Source: https://github.com/jierunchen/fasternet/blob/master/README.MD BibTeX entry for citing the FasterNet paper. Use this in academic publications. ```bibtex @article{chen2023run, title={Run, Don't Walk: Chasing Higher FLOPS for Faster Neural Networks}, author={Chen, Jierun and Kao, Shiu-hong and He, Hao and Zhuo, Weipeng and Wen, Song and Lee, Chul-Ho and Chan, S-H Gary}, journal={arXiv preprint arXiv:2303.03667}, year={2023} } ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.