master 1ec3fe6f374f cached
593 files
3.3 MB
908.8k tokens
3150 symbols
1 requests
Download .txt
Showing preview only (3,623K chars total). Download the full file or copy to clipboard to get everything.
Repository: WZMIAOMIAO/deep-learning-for-image-processing
Branch: master
Commit: 1ec3fe6f374f
Files: 593
Total size: 3.3 MB

Directory structure:
gitextract_1s0rnibl/

├── .github/
│   └── ISSUE_TEMPLATE/
│       └── issue-template.md
├── .gitignore
├── LICENSE
├── README.md
├── article_link/
│   └── README.md
├── course_ppt/
│   └── README.md
├── data_set/
│   ├── README.md
│   └── split_data.py
├── deploying_service/
│   ├── deploying_pytorch/
│   │   ├── convert_onnx_cls/
│   │   │   ├── class_indices.json
│   │   │   ├── main.py
│   │   │   └── model.py
│   │   ├── convert_openvino/
│   │   │   ├── convert_resnet34/
│   │   │   │   ├── README.md
│   │   │   │   ├── compare_fps.py
│   │   │   │   ├── compare_onnx_and_ir.py
│   │   │   │   ├── convert_pytorch2onnx.py
│   │   │   │   ├── model.py
│   │   │   │   ├── quantization_int8.py
│   │   │   │   ├── requirements.txt
│   │   │   │   └── utils.py
│   │   │   └── convert_yolov5/
│   │   │       ├── README.md
│   │   │       ├── compare_fps.py
│   │   │       ├── compare_onnx_and_ir.py
│   │   │       ├── draw_box_utils.py
│   │   │       ├── evaluation.py
│   │   │       ├── predict.py
│   │   │       ├── quantization_int8.py
│   │   │       ├── requirements.txt
│   │   │       └── utils.py
│   │   ├── convert_tensorrt/
│   │   │   └── convert_resnet34/
│   │   │       ├── compare_onnx_and_trt.py
│   │   │       ├── convert_pytorch2onnx.py
│   │   │       ├── my_dataset.py
│   │   │       ├── quantization.py
│   │   │       └── utils.py
│   │   └── pytorch_flask_service/
│   │       ├── class_indices.json
│   │       ├── main.py
│   │       ├── model.py
│   │       ├── requirements.txt
│   │       └── templates/
│   │           └── up.html
│   └── pruning_model_pytorch/
│       ├── class_indices.json
│       ├── main.py
│       ├── model.py
│       ├── predict.py
│       └── train.py
├── others_project/
│   ├── draw_dilated_conv/
│   │   └── main.py
│   ├── kmeans_anchors/
│   │   ├── main.py
│   │   ├── plot_kmeans.py
│   │   ├── read_voc.py
│   │   └── yolo_kmeans.py
│   ├── openvinotest/
│   │   └── openvino_cls_test/
│   │       ├── class_indices.json
│   │       ├── create_imagenet_annotation.py
│   │       ├── float32vsint8.py
│   │       ├── main.py
│   │       ├── model.py
│   │       └── speed_test.py
│   ├── readPbFile/
│   │   ├── README.md
│   │   ├── pascal_label_map.pbtxt
│   │   ├── readPb.py
│   │   ├── test_images/
│   │   │   └── image_info.txt
│   │   └── using_function.py
│   ├── textcnnKeras/
│   │   ├── dataGenerator.py
│   │   ├── data_link.txt
│   │   ├── main.py
│   │   └── models.py
│   └── trans_widerface_to_xml/
│       ├── create_xml.py
│       └── main.py
├── pytorch_classification/
│   ├── ConfusionMatrix/
│   │   ├── class_indices.json
│   │   ├── main.py
│   │   └── model.py
│   ├── ConvNeXt/
│   │   ├── README.md
│   │   ├── model.py
│   │   ├── my_dataset.py
│   │   ├── predict.py
│   │   ├── train.py
│   │   └── utils.py
│   ├── MobileViT/
│   │   ├── README.md
│   │   ├── model.py
│   │   ├── model_config.py
│   │   ├── my_dataset.py
│   │   ├── predict.py
│   │   ├── train.py
│   │   ├── transformer.py
│   │   ├── unfold_test.py
│   │   └── utils.py
│   ├── README.md
│   ├── Test10_regnet/
│   │   ├── README.md
│   │   ├── model.py
│   │   ├── my_dataset.py
│   │   ├── predict.py
│   │   ├── pretrain_weights.py
│   │   ├── train.py
│   │   └── utils.py
│   ├── Test11_efficientnetV2/
│   │   ├── README.md
│   │   ├── class_indices.json
│   │   ├── model.py
│   │   ├── my_dataset.py
│   │   ├── predict.py
│   │   ├── train.py
│   │   ├── trans_effv2_weights.py
│   │   └── utils.py
│   ├── Test1_official_demo/
│   │   ├── model.py
│   │   ├── predict.py
│   │   └── train.py
│   ├── Test2_alexnet/
│   │   ├── class_indices.json
│   │   ├── model.py
│   │   ├── predict.py
│   │   └── train.py
│   ├── Test3_vggnet/
│   │   ├── class_indices.json
│   │   ├── model.py
│   │   ├── predict.py
│   │   └── train.py
│   ├── Test4_googlenet/
│   │   ├── class_indices.json
│   │   ├── model.py
│   │   ├── predict.py
│   │   └── train.py
│   ├── Test5_resnet/
│   │   ├── README.md
│   │   ├── batch_predict.py
│   │   ├── class_indices.json
│   │   ├── load_weights.py
│   │   ├── model.py
│   │   ├── predict.py
│   │   └── train.py
│   ├── Test6_mobilenet/
│   │   ├── class_indices.json
│   │   ├── model_v2.py
│   │   ├── model_v3.py
│   │   ├── predict.py
│   │   └── train.py
│   ├── Test7_shufflenet/
│   │   ├── README.md
│   │   ├── class_indices.json
│   │   ├── model.py
│   │   ├── my_dataset.py
│   │   ├── predict.py
│   │   ├── train.py
│   │   └── utils.py
│   ├── Test8_densenet/
│   │   ├── README.md
│   │   ├── model.py
│   │   ├── my_dataset.py
│   │   ├── predict.py
│   │   ├── train.py
│   │   └── utils.py
│   ├── Test9_efficientNet/
│   │   ├── README.md
│   │   ├── model.py
│   │   ├── my_dataset.py
│   │   ├── predict.py
│   │   ├── requirements.txt
│   │   ├── train.py
│   │   ├── trans_weights_to_pytorch.py
│   │   └── utils.py
│   ├── analyze_weights_featuremap/
│   │   ├── alexnet_model.py
│   │   ├── analyze_feature_map.py
│   │   ├── analyze_kernel_weight.py
│   │   └── resnet_model.py
│   ├── custom_dataset/
│   │   ├── main.py
│   │   ├── my_dataset.py
│   │   └── utils.py
│   ├── grad_cam/
│   │   ├── README.md
│   │   ├── imagenet1k_classes.txt
│   │   ├── imagenet21k_classes.txt
│   │   ├── main_cnn.py
│   │   ├── main_swin.py
│   │   ├── main_vit.py
│   │   ├── swin_model.py
│   │   ├── utils.py
│   │   └── vit_model.py
│   ├── mini_imagenet/
│   │   ├── README.md
│   │   ├── imagenet_class_index.json
│   │   ├── model.py
│   │   ├── multi_train_utils/
│   │   │   ├── __init__.py
│   │   │   ├── distributed_utils.py
│   │   │   └── train_eval_utils.py
│   │   ├── my_dataset.py
│   │   ├── restructure_csv.py
│   │   ├── train_multi_gpu_using_launch.py
│   │   └── train_single_gpu.py
│   ├── model_complexity/
│   │   ├── main.py
│   │   ├── model.py
│   │   └── utils.py
│   ├── swin_transformer/
│   │   ├── README.md
│   │   ├── create_confusion_matrix.py
│   │   ├── model.py
│   │   ├── my_dataset.py
│   │   ├── predict.py
│   │   ├── select_incorrect_samples.py
│   │   ├── train.py
│   │   └── utils.py
│   ├── tensorboard_test/
│   │   ├── data_utils.py
│   │   ├── model.py
│   │   ├── my_dataset.py
│   │   ├── requirements.txt
│   │   ├── train.py
│   │   └── train_eval_utils.py
│   ├── train_multi_GPU/
│   │   ├── README.md
│   │   ├── model.py
│   │   ├── multi_train_utils/
│   │   │   ├── distributed_utils.py
│   │   │   └── train_eval_utils.py
│   │   ├── my_dataset.py
│   │   ├── plot_results.py
│   │   ├── requirements.txt
│   │   ├── train_multi_gpu_using_launch.py
│   │   ├── train_multi_gpu_using_spawn.py
│   │   ├── train_single_gpu.py
│   │   └── utils.py
│   └── vision_transformer/
│       ├── README.md
│       ├── flops.py
│       ├── my_dataset.py
│       ├── predict.py
│       ├── train.py
│       ├── utils.py
│       └── vit_model.py
├── pytorch_keypoint/
│   ├── DeepPose/
│   │   ├── README.md
│   │   ├── datasets.py
│   │   ├── export_onnx.py
│   │   ├── model.py
│   │   ├── predict.py
│   │   ├── requirements.txt
│   │   ├── train.py
│   │   ├── train_multi_GPU.py
│   │   ├── train_utils/
│   │   │   ├── distributed_utils.py
│   │   │   ├── losses.py
│   │   │   ├── metrics.py
│   │   │   └── train_eval_utils.py
│   │   ├── transforms.py
│   │   ├── utils.py
│   │   └── wflw_horizontal_flip_indices.py
│   └── HRNet/
│       ├── README.md
│       ├── draw_utils.py
│       ├── model/
│       │   ├── __init__.py
│       │   └── hrnet.py
│       ├── my_dataset_coco.py
│       ├── person_keypoints.json
│       ├── plot_curve.py
│       ├── predict.py
│       ├── requirements.txt
│       ├── train.py
│       ├── train_multi_GPU.py
│       ├── train_utils/
│       │   ├── __init__.py
│       │   ├── coco_eval.py
│       │   ├── coco_utils.py
│       │   ├── distributed_utils.py
│       │   ├── group_by_aspect_ratio.py
│       │   ├── loss.py
│       │   └── train_eval_utils.py
│       ├── transforms.py
│       └── validation.py
├── pytorch_object_detection/
│   ├── faster_rcnn/
│   │   ├── README.md
│   │   ├── backbone/
│   │   │   ├── __init__.py
│   │   │   ├── feature_pyramid_network.py
│   │   │   ├── mobilenetv2_model.py
│   │   │   ├── resnet50_fpn_model.py
│   │   │   └── vgg_model.py
│   │   ├── change_backbone_with_fpn.py
│   │   ├── change_backbone_without_fpn.py
│   │   ├── draw_box_utils.py
│   │   ├── my_dataset.py
│   │   ├── network_files/
│   │   │   ├── __init__.py
│   │   │   ├── boxes.py
│   │   │   ├── det_utils.py
│   │   │   ├── faster_rcnn_framework.py
│   │   │   ├── image_list.py
│   │   │   ├── roi_head.py
│   │   │   ├── rpn_function.py
│   │   │   └── transform.py
│   │   ├── pascal_voc_classes.json
│   │   ├── plot_curve.py
│   │   ├── predict.py
│   │   ├── record_mAP.txt
│   │   ├── requirements.txt
│   │   ├── split_data.py
│   │   ├── train_mobilenetv2.py
│   │   ├── train_multi_GPU.py
│   │   ├── train_res50_fpn.py
│   │   ├── train_utils/
│   │   │   ├── __init__.py
│   │   │   ├── coco_eval.py
│   │   │   ├── coco_utils.py
│   │   │   ├── distributed_utils.py
│   │   │   ├── group_by_aspect_ratio.py
│   │   │   └── train_eval_utils.py
│   │   ├── transforms.py
│   │   └── validation.py
│   ├── mask_rcnn/
│   │   ├── README.md
│   │   ├── backbone/
│   │   │   ├── __init__.py
│   │   │   ├── feature_pyramid_network.py
│   │   │   └── resnet50_fpn_model.py
│   │   ├── coco91_indices.json
│   │   ├── det_results20220406-141544.txt
│   │   ├── draw_box_utils.py
│   │   ├── my_dataset_coco.py
│   │   ├── my_dataset_voc.py
│   │   ├── network_files/
│   │   │   ├── __init__.py
│   │   │   ├── boxes.py
│   │   │   ├── det_utils.py
│   │   │   ├── faster_rcnn_framework.py
│   │   │   ├── image_list.py
│   │   │   ├── mask_rcnn.py
│   │   │   ├── roi_head.py
│   │   │   ├── rpn_function.py
│   │   │   └── transform.py
│   │   ├── pascal_voc_indices.json
│   │   ├── plot_curve.py
│   │   ├── predict.py
│   │   ├── requirements.txt
│   │   ├── seg_results20220406-141544.txt
│   │   ├── train.py
│   │   ├── train_multi_GPU.py
│   │   ├── train_utils/
│   │   │   ├── __init__.py
│   │   │   ├── coco_eval.py
│   │   │   ├── coco_utils.py
│   │   │   ├── distributed_utils.py
│   │   │   ├── group_by_aspect_ratio.py
│   │   │   └── train_eval_utils.py
│   │   ├── transforms.py
│   │   └── validation.py
│   ├── retinaNet/
│   │   ├── README.md
│   │   ├── backbone/
│   │   │   ├── __init__.py
│   │   │   ├── feature_pyramid_network.py
│   │   │   └── resnet50_fpn_model.py
│   │   ├── draw_box_utils.py
│   │   ├── my_dataset.py
│   │   ├── network_files/
│   │   │   ├── __init__.py
│   │   │   ├── anchor_utils.py
│   │   │   ├── boxes.py
│   │   │   ├── det_utils.py
│   │   │   ├── image_list.py
│   │   │   ├── losses.py
│   │   │   ├── retinanet.py
│   │   │   └── transform.py
│   │   ├── pascal_voc_classes.json
│   │   ├── plot_curve.py
│   │   ├── predict.py
│   │   ├── requirements.txt
│   │   ├── results20210421-142632.txt
│   │   ├── train.py
│   │   ├── train_multi_GPU.py
│   │   ├── train_utils/
│   │   │   ├── __init__.py
│   │   │   ├── coco_eval.py
│   │   │   ├── coco_utils.py
│   │   │   ├── distributed_utils.py
│   │   │   ├── group_by_aspect_ratio.py
│   │   │   └── train_eval_utils.py
│   │   ├── transforms.py
│   │   └── validation.py
│   ├── ssd/
│   │   ├── README.md
│   │   ├── draw_box_utils.py
│   │   ├── my_dataset.py
│   │   ├── pascal_voc_classes.json
│   │   ├── plot_curve.py
│   │   ├── predict_test.py
│   │   ├── record_mAP.txt
│   │   ├── requirements.txt
│   │   ├── src/
│   │   │   ├── __init__.py
│   │   │   ├── res50_backbone.py
│   │   │   ├── ssd_model.py
│   │   │   └── utils.py
│   │   ├── train_multi_GPU.py
│   │   ├── train_ssd300.py
│   │   ├── train_utils/
│   │   │   ├── __init__.py
│   │   │   ├── coco_eval.py
│   │   │   ├── coco_utils.py
│   │   │   ├── distributed_utils.py
│   │   │   ├── group_by_aspect_ratio.py
│   │   │   └── train_eval_utils.py
│   │   ├── transforms.py
│   │   └── validation.py
│   ├── train_coco_dataset/
│   │   ├── README.md
│   │   ├── backbone/
│   │   │   ├── __init__.py
│   │   │   ├── feature_pyramid_network.py
│   │   │   ├── mobilenetv2_model.py
│   │   │   ├── resnet.py
│   │   │   ├── resnet50_fpn_model.py
│   │   │   └── vgg_model.py
│   │   ├── change_backbone_with_fpn.py
│   │   ├── coco91_indices.json
│   │   ├── compute_receptive_field.py
│   │   ├── draw_box_utils.py
│   │   ├── my_dataset.py
│   │   ├── network_files/
│   │   │   ├── __init__.py
│   │   │   ├── boxes.py
│   │   │   ├── det_utils.py
│   │   │   ├── faster_rcnn_framework.py
│   │   │   ├── image_list.py
│   │   │   ├── roi_head.py
│   │   │   ├── rpn_function.py
│   │   │   └── transform.py
│   │   ├── plot_curve.py
│   │   ├── predict.py
│   │   ├── requirements.txt
│   │   ├── results20220408-201436.txt
│   │   ├── train.py
│   │   ├── train_multi_GPU.py
│   │   ├── train_utils/
│   │   │   ├── __init__.py
│   │   │   ├── coco_eval.py
│   │   │   ├── distributed_utils.py
│   │   │   ├── group_by_aspect_ratio.py
│   │   │   └── train_eval_utils.py
│   │   ├── transforms.py
│   │   └── validation.py
│   └── yolov3_spp/
│       ├── README.md
│       ├── build_utils/
│       │   ├── __init__.py
│       │   ├── datasets.py
│       │   ├── img_utils.py
│       │   ├── layers.py
│       │   ├── parse_config.py
│       │   ├── torch_utils.py
│       │   └── utils.py
│       ├── calculate_dataset.py
│       ├── cfg/
│       │   ├── hyp.yaml
│       │   └── yolov3-spp.cfg
│       ├── draw_box_utils.py
│       ├── export_onnx.py
│       ├── load_onnx_test.py
│       ├── models.py
│       ├── predict_test.py
│       ├── requirements.txt
│       ├── results20210515-152935.txt
│       ├── train.py
│       ├── train_multi_GPU.py
│       ├── train_utils/
│       │   ├── __init__.py
│       │   ├── coco_eval.py
│       │   ├── coco_utils.py
│       │   ├── distributed_utils.py
│       │   ├── group_by_aspect_ratio.py
│       │   └── train_eval_utils.py
│       ├── trans_voc2yolo.py
│       └── validation.py
├── pytorch_segmentation/
│   ├── deeplab_v3/
│   │   ├── README.md
│   │   ├── get_palette.py
│   │   ├── my_dataset.py
│   │   ├── palette.json
│   │   ├── pascal_voc_classes.json
│   │   ├── predict.py
│   │   ├── requirements.txt
│   │   ├── results20211027-104607.txt
│   │   ├── src/
│   │   │   ├── __init__.py
│   │   │   ├── deeplabv3_model.py
│   │   │   ├── mobilenet_backbone.py
│   │   │   └── resnet_backbone.py
│   │   ├── train.py
│   │   ├── train_multi_GPU.py
│   │   ├── train_utils/
│   │   │   ├── __init__.py
│   │   │   ├── distributed_utils.py
│   │   │   └── train_and_eval.py
│   │   ├── transforms.py
│   │   └── validation.py
│   ├── fcn/
│   │   ├── README.md
│   │   ├── get_palette.py
│   │   ├── my_dataset.py
│   │   ├── palette.json
│   │   ├── pascal_voc_classes.json
│   │   ├── predict.py
│   │   ├── requirements.txt
│   │   ├── results20210918-122740.txt
│   │   ├── src/
│   │   │   ├── __init__.py
│   │   │   ├── backbone.py
│   │   │   └── fcn_model.py
│   │   ├── train.py
│   │   ├── train_multi_GPU.py
│   │   ├── train_utils/
│   │   │   ├── __init__.py
│   │   │   ├── distributed_utils.py
│   │   │   └── train_and_eval.py
│   │   ├── transforms.py
│   │   └── validation.py
│   ├── lraspp/
│   │   ├── README.md
│   │   ├── get_palette.py
│   │   ├── my_dataset.py
│   │   ├── palette.json
│   │   ├── pascal_voc_classes.json
│   │   ├── predict.py
│   │   ├── requirements.txt
│   │   ├── results20211028-105233.txt
│   │   ├── src/
│   │   │   ├── __init__.py
│   │   │   ├── lraspp_model.py
│   │   │   └── mobilenet_backbone.py
│   │   ├── train.py
│   │   ├── train_multi_GPU.py
│   │   ├── train_utils/
│   │   │   ├── __init__.py
│   │   │   ├── distributed_utils.py
│   │   │   └── train_and_eval.py
│   │   ├── transforms.py
│   │   └── validation.py
│   ├── u2net/
│   │   ├── README.md
│   │   ├── convert_weight.py
│   │   ├── my_dataset.py
│   │   ├── predict.py
│   │   ├── requirements.txt
│   │   ├── results20220723-123632.txt
│   │   ├── src/
│   │   │   ├── __init__.py
│   │   │   └── model.py
│   │   ├── train.py
│   │   ├── train_multi_GPU.py
│   │   ├── train_utils/
│   │   │   ├── __init__.py
│   │   │   ├── distributed_utils.py
│   │   │   └── train_and_eval.py
│   │   ├── transforms.py
│   │   └── validation.py
│   └── unet/
│       ├── README.md
│       ├── compute_mean_std.py
│       ├── my_dataset.py
│       ├── predict.py
│       ├── requirements.txt
│       ├── results20220109-165837.txt
│       ├── src/
│       │   ├── __init__.py
│       │   ├── mobilenet_unet.py
│       │   ├── unet.py
│       │   └── vgg_unet.py
│       ├── train.py
│       ├── train_multi_GPU.py
│       ├── train_utils/
│       │   ├── __init__.py
│       │   ├── dice_coefficient_loss.py
│       │   ├── distributed_utils.py
│       │   └── train_and_eval.py
│       └── transforms.py
├── summary_problem.md
└── tensorflow_classification/
    ├── ConfusionMatrix/
    │   ├── class_indices.json
    │   ├── main.py
    │   └── model.py
    ├── ConvNeXt/
    │   ├── model.py
    │   ├── predict.py
    │   ├── train.py
    │   ├── trans_weights.py
    │   └── utils.py
    ├── README.md
    ├── Test11_efficientnetV2/
    │   ├── model.py
    │   ├── predict.py
    │   ├── train.py
    │   ├── trans_weights.py
    │   └── utils.py
    ├── Test1_official_demo/
    │   ├── model.py
    │   └── train.py
    ├── Test2_alexnet/
    │   ├── class_indices.json
    │   ├── fine_train_alexnet.py
    │   ├── model.py
    │   ├── predict.py
    │   ├── read_pth.py
    │   ├── train.py
    │   └── trainGPU.py
    ├── Test3_vgg/
    │   ├── class_indices.json
    │   ├── fine_train_vgg16.py
    │   ├── model.py
    │   ├── predict.py
    │   ├── read_ckpt.py
    │   ├── train.py
    │   └── trainGPU.py
    ├── Test4_goolenet/
    │   ├── class_indices.json
    │   ├── model.py
    │   ├── model_add_bn.py
    │   ├── predict.py
    │   ├── read_pth.py
    │   ├── train.py
    │   ├── trainGPU.py
    │   └── train_add_bn.py
    ├── Test5_resnet/
    │   ├── batch_predict.py
    │   ├── class_indices.json
    │   ├── model.py
    │   ├── predict.py
    │   ├── read_ckpt.py
    │   ├── read_h5.py
    │   ├── subclassed_model.py
    │   ├── train.py
    │   └── trainGPU.py
    ├── Test6_mobilenet/
    │   ├── model_v2.py
    │   ├── model_v3.py
    │   ├── predict.py
    │   ├── read_ckpt.py
    │   ├── trainGPU_mobilenet_v2.py
    │   ├── train_mobilenet_v2.py
    │   ├── train_mobilenet_v3.py
    │   ├── trans_v3_weights.py
    │   └── utils.py
    ├── Test7_shuffleNet/
    │   ├── model.py
    │   ├── predict.py
    │   ├── train.py
    │   ├── trans_weights.py
    │   └── utils.py
    ├── Test9_efficientNet/
    │   ├── model.py
    │   ├── predict.py
    │   ├── train.py
    │   └── utils.py
    ├── analyze_weights_featuremap/
    │   ├── alexnet_model.py
    │   ├── analyze_feature_map.py
    │   └── analyze_kernel_weight.py
    ├── custom_dataset/
    │   ├── train_fit.py
    │   └── utils.py
    ├── swin_transformer/
    │   ├── model.py
    │   ├── predict.py
    │   ├── train.py
    │   ├── trans_weights.py
    │   └── utils.py
    ├── tensorboard_test/
    │   ├── train_fit.py
    │   └── train_not_fit.py
    └── vision_transformer/
        ├── predict.py
        ├── train.py
        ├── trans_weights.py
        ├── utils.py
        └── vit_model.py

================================================
FILE CONTENTS
================================================

================================================
FILE: .github/ISSUE_TEMPLATE/issue-template.md
================================================
---
name: Issue template
about: Use this template for reporting your problem
title: ''
labels: ''
assignees: ''

---

**System information**
* Have I written custom code:
* OS Platform(e.g., window10 or Linux Ubuntu 16.04):
* Python version:
* Deep learning framework and version(e.g., Tensorflow2.1 or Pytorch1.3):
* Use GPU or not:
* CUDA/cuDNN version(if you use GPU):
* The network you trained(e.g., Resnet34 network):

**Describe the current behavior**

**Error info / logs**


================================================
FILE: .gitignore
================================================
##ignore this file##
*.idea
__pycache__
*.zip
flower_data
*.h5
*.pth
*.pt
*.jpg
*.ckpt.*
*.ckpt
*.config
*.gz
*.onnx
*.xml
*.bin
*.mapping
*.csv
checkpoint
data
VOCdevkit
ssd_resnet50_v1_fpn_shared_box_predictor
runs


================================================
FILE: LICENSE
================================================
                    GNU GENERAL PUBLIC LICENSE
                       Version 3, 29 June 2007

 Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
 Everyone is permitted to copy and distribute verbatim copies
 of this license document, but changing it is not allowed.

                            Preamble

  The GNU General Public License is a free, copyleft license for
software and other kinds of works.

  The licenses for most software and other practical works are designed
to take away your freedom to share and change the works.  By contrast,
the GNU General Public License is intended to guarantee your freedom to
share and change all versions of a program--to make sure it remains free
software for all its users.  We, the Free Software Foundation, use the
GNU General Public License for most of our software; it applies also to
any other work released this way by its authors.  You can apply it to
your programs, too.

  When we speak of free software, we are referring to freedom, not
price.  Our General Public Licenses are designed to make sure that you
have the freedom to distribute copies of free software (and charge for
them if you wish), that you receive source code or can get it if you
want it, that you can change the software or use pieces of it in new
free programs, and that you know you can do these things.

  To protect your rights, we need to prevent others from denying you
these rights or asking you to surrender the rights.  Therefore, you have
certain responsibilities if you distribute copies of the software, or if
you modify it: responsibilities to respect the freedom of others.

  For example, if you distribute copies of such a program, whether
gratis or for a fee, you must pass on to the recipients the same
freedoms that you received.  You must make sure that they, too, receive
or can get the source code.  And you must show them these terms so they
know their rights.

  Developers that use the GNU GPL protect your rights with two steps:
(1) assert copyright on the software, and (2) offer you this License
giving you legal permission to copy, distribute and/or modify it.

  For the developers' and authors' protection, the GPL clearly explains
that there is no warranty for this free software.  For both users' and
authors' sake, the GPL requires that modified versions be marked as
changed, so that their problems will not be attributed erroneously to
authors of previous versions.

  Some devices are designed to deny users access to install or run
modified versions of the software inside them, although the manufacturer
can do so.  This is fundamentally incompatible with the aim of
protecting users' freedom to change the software.  The systematic
pattern of such abuse occurs in the area of products for individuals to
use, which is precisely where it is most unacceptable.  Therefore, we
have designed this version of the GPL to prohibit the practice for those
products.  If such problems arise substantially in other domains, we
stand ready to extend this provision to those domains in future versions
of the GPL, as needed to protect the freedom of users.

  Finally, every program is threatened constantly by software patents.
States should not allow patents to restrict development and use of
software on general-purpose computers, but in those that do, we wish to
avoid the special danger that patents applied to a free program could
make it effectively proprietary.  To prevent this, the GPL assures that
patents cannot be used to render the program non-free.

  The precise terms and conditions for copying, distribution and
modification follow.

                       TERMS AND CONDITIONS

  0. Definitions.

  "This License" refers to version 3 of the GNU General Public License.

  "Copyright" also means copyright-like laws that apply to other kinds of
works, such as semiconductor masks.

  "The Program" refers to any copyrightable work licensed under this
License.  Each licensee is addressed as "you".  "Licensees" and
"recipients" may be individuals or organizations.

  To "modify" a work means to copy from or adapt all or part of the work
in a fashion requiring copyright permission, other than the making of an
exact copy.  The resulting work is called a "modified version" of the
earlier work or a work "based on" the earlier work.

  A "covered work" means either the unmodified Program or a work based
on the Program.

  To "propagate" a work means to do anything with it that, without
permission, would make you directly or secondarily liable for
infringement under applicable copyright law, except executing it on a
computer or modifying a private copy.  Propagation includes copying,
distribution (with or without modification), making available to the
public, and in some countries other activities as well.

  To "convey" a work means any kind of propagation that enables other
parties to make or receive copies.  Mere interaction with a user through
a computer network, with no transfer of a copy, is not conveying.

  An interactive user interface displays "Appropriate Legal Notices"
to the extent that it includes a convenient and prominently visible
feature that (1) displays an appropriate copyright notice, and (2)
tells the user that there is no warranty for the work (except to the
extent that warranties are provided), that licensees may convey the
work under this License, and how to view a copy of this License.  If
the interface presents a list of user commands or options, such as a
menu, a prominent item in the list meets this criterion.

  1. Source Code.

  The "source code" for a work means the preferred form of the work
for making modifications to it.  "Object code" means any non-source
form of a work.

  A "Standard Interface" means an interface that either is an official
standard defined by a recognized standards body, or, in the case of
interfaces specified for a particular programming language, one that
is widely used among developers working in that language.

  The "System Libraries" of an executable work include anything, other
than the work as a whole, that (a) is included in the normal form of
packaging a Major Component, but which is not part of that Major
Component, and (b) serves only to enable use of the work with that
Major Component, or to implement a Standard Interface for which an
implementation is available to the public in source code form.  A
"Major Component", in this context, means a major essential component
(kernel, window system, and so on) of the specific operating system
(if any) on which the executable work runs, or a compiler used to
produce the work, or an object code interpreter used to run it.

  The "Corresponding Source" for a work in object code form means all
the source code needed to generate, install, and (for an executable
work) run the object code and to modify the work, including scripts to
control those activities.  However, it does not include the work's
System Libraries, or general-purpose tools or generally available free
programs which are used unmodified in performing those activities but
which are not part of the work.  For example, Corresponding Source
includes interface definition files associated with source files for
the work, and the source code for shared libraries and dynamically
linked subprograms that the work is specifically designed to require,
such as by intimate data communication or control flow between those
subprograms and other parts of the work.

  The Corresponding Source need not include anything that users
can regenerate automatically from other parts of the Corresponding
Source.

  The Corresponding Source for a work in source code form is that
same work.

  2. Basic Permissions.

  All rights granted under this License are granted for the term of
copyright on the Program, and are irrevocable provided the stated
conditions are met.  This License explicitly affirms your unlimited
permission to run the unmodified Program.  The output from running a
covered work is covered by this License only if the output, given its
content, constitutes a covered work.  This License acknowledges your
rights of fair use or other equivalent, as provided by copyright law.

  You may make, run and propagate covered works that you do not
convey, without conditions so long as your license otherwise remains
in force.  You may convey covered works to others for the sole purpose
of having them make modifications exclusively for you, or provide you
with facilities for running those works, provided that you comply with
the terms of this License in conveying all material for which you do
not control copyright.  Those thus making or running the covered works
for you must do so exclusively on your behalf, under your direction
and control, on terms that prohibit them from making any copies of
your copyrighted material outside their relationship with you.

  Conveying under any other circumstances is permitted solely under
the conditions stated below.  Sublicensing is not allowed; section 10
makes it unnecessary.

  3. Protecting Users' Legal Rights From Anti-Circumvention Law.

  No covered work shall be deemed part of an effective technological
measure under any applicable law fulfilling obligations under article
11 of the WIPO copyright treaty adopted on 20 December 1996, or
similar laws prohibiting or restricting circumvention of such
measures.

  When you convey a covered work, you waive any legal power to forbid
circumvention of technological measures to the extent such circumvention
is effected by exercising rights under this License with respect to
the covered work, and you disclaim any intention to limit operation or
modification of the work as a means of enforcing, against the work's
users, your or third parties' legal rights to forbid circumvention of
technological measures.

  4. Conveying Verbatim Copies.

  You may convey verbatim copies of the Program's source code as you
receive it, in any medium, provided that you conspicuously and
appropriately publish on each copy an appropriate copyright notice;
keep intact all notices stating that this License and any
non-permissive terms added in accord with section 7 apply to the code;
keep intact all notices of the absence of any warranty; and give all
recipients a copy of this License along with the Program.

  You may charge any price or no price for each copy that you convey,
and you may offer support or warranty protection for a fee.

  5. Conveying Modified Source Versions.

  You may convey a work based on the Program, or the modifications to
produce it from the Program, in the form of source code under the
terms of section 4, provided that you also meet all of these conditions:

    a) The work must carry prominent notices stating that you modified
    it, and giving a relevant date.

    b) The work must carry prominent notices stating that it is
    released under this License and any conditions added under section
    7.  This requirement modifies the requirement in section 4 to
    "keep intact all notices".

    c) You must license the entire work, as a whole, under this
    License to anyone who comes into possession of a copy.  This
    License will therefore apply, along with any applicable section 7
    additional terms, to the whole of the work, and all its parts,
    regardless of how they are packaged.  This License gives no
    permission to license the work in any other way, but it does not
    invalidate such permission if you have separately received it.

    d) If the work has interactive user interfaces, each must display
    Appropriate Legal Notices; however, if the Program has interactive
    interfaces that do not display Appropriate Legal Notices, your
    work need not make them do so.

  A compilation of a covered work with other separate and independent
works, which are not by their nature extensions of the covered work,
and which are not combined with it such as to form a larger program,
in or on a volume of a storage or distribution medium, is called an
"aggregate" if the compilation and its resulting copyright are not
used to limit the access or legal rights of the compilation's users
beyond what the individual works permit.  Inclusion of a covered work
in an aggregate does not cause this License to apply to the other
parts of the aggregate.

  6. Conveying Non-Source Forms.

  You may convey a covered work in object code form under the terms
of sections 4 and 5, provided that you also convey the
machine-readable Corresponding Source under the terms of this License,
in one of these ways:

    a) Convey the object code in, or embodied in, a physical product
    (including a physical distribution medium), accompanied by the
    Corresponding Source fixed on a durable physical medium
    customarily used for software interchange.

    b) Convey the object code in, or embodied in, a physical product
    (including a physical distribution medium), accompanied by a
    written offer, valid for at least three years and valid for as
    long as you offer spare parts or customer support for that product
    model, to give anyone who possesses the object code either (1) a
    copy of the Corresponding Source for all the software in the
    product that is covered by this License, on a durable physical
    medium customarily used for software interchange, for a price no
    more than your reasonable cost of physically performing this
    conveying of source, or (2) access to copy the
    Corresponding Source from a network server at no charge.

    c) Convey individual copies of the object code with a copy of the
    written offer to provide the Corresponding Source.  This
    alternative is allowed only occasionally and noncommercially, and
    only if you received the object code with such an offer, in accord
    with subsection 6b.

    d) Convey the object code by offering access from a designated
    place (gratis or for a charge), and offer equivalent access to the
    Corresponding Source in the same way through the same place at no
    further charge.  You need not require recipients to copy the
    Corresponding Source along with the object code.  If the place to
    copy the object code is a network server, the Corresponding Source
    may be on a different server (operated by you or a third party)
    that supports equivalent copying facilities, provided you maintain
    clear directions next to the object code saying where to find the
    Corresponding Source.  Regardless of what server hosts the
    Corresponding Source, you remain obligated to ensure that it is
    available for as long as needed to satisfy these requirements.

    e) Convey the object code using peer-to-peer transmission, provided
    you inform other peers where the object code and Corresponding
    Source of the work are being offered to the general public at no
    charge under subsection 6d.

  A separable portion of the object code, whose source code is excluded
from the Corresponding Source as a System Library, need not be
included in conveying the object code work.

  A "User Product" is either (1) a "consumer product", which means any
tangible personal property which is normally used for personal, family,
or household purposes, or (2) anything designed or sold for incorporation
into a dwelling.  In determining whether a product is a consumer product,
doubtful cases shall be resolved in favor of coverage.  For a particular
product received by a particular user, "normally used" refers to a
typical or common use of that class of product, regardless of the status
of the particular user or of the way in which the particular user
actually uses, or expects or is expected to use, the product.  A product
is a consumer product regardless of whether the product has substantial
commercial, industrial or non-consumer uses, unless such uses represent
the only significant mode of use of the product.

  "Installation Information" for a User Product means any methods,
procedures, authorization keys, or other information required to install
and execute modified versions of a covered work in that User Product from
a modified version of its Corresponding Source.  The information must
suffice to ensure that the continued functioning of the modified object
code is in no case prevented or interfered with solely because
modification has been made.

  If you convey an object code work under this section in, or with, or
specifically for use in, a User Product, and the conveying occurs as
part of a transaction in which the right of possession and use of the
User Product is transferred to the recipient in perpetuity or for a
fixed term (regardless of how the transaction is characterized), the
Corresponding Source conveyed under this section must be accompanied
by the Installation Information.  But this requirement does not apply
if neither you nor any third party retains the ability to install
modified object code on the User Product (for example, the work has
been installed in ROM).

  The requirement to provide Installation Information does not include a
requirement to continue to provide support service, warranty, or updates
for a work that has been modified or installed by the recipient, or for
the User Product in which it has been modified or installed.  Access to a
network may be denied when the modification itself materially and
adversely affects the operation of the network or violates the rules and
protocols for communication across the network.

  Corresponding Source conveyed, and Installation Information provided,
in accord with this section must be in a format that is publicly
documented (and with an implementation available to the public in
source code form), and must require no special password or key for
unpacking, reading or copying.

  7. Additional Terms.

  "Additional permissions" are terms that supplement the terms of this
License by making exceptions from one or more of its conditions.
Additional permissions that are applicable to the entire Program shall
be treated as though they were included in this License, to the extent
that they are valid under applicable law.  If additional permissions
apply only to part of the Program, that part may be used separately
under those permissions, but the entire Program remains governed by
this License without regard to the additional permissions.

  When you convey a copy of a covered work, you may at your option
remove any additional permissions from that copy, or from any part of
it.  (Additional permissions may be written to require their own
removal in certain cases when you modify the work.)  You may place
additional permissions on material, added by you to a covered work,
for which you have or can give appropriate copyright permission.

  Notwithstanding any other provision of this License, for material you
add to a covered work, you may (if authorized by the copyright holders of
that material) supplement the terms of this License with terms:

    a) Disclaiming warranty or limiting liability differently from the
    terms of sections 15 and 16 of this License; or

    b) Requiring preservation of specified reasonable legal notices or
    author attributions in that material or in the Appropriate Legal
    Notices displayed by works containing it; or

    c) Prohibiting misrepresentation of the origin of that material, or
    requiring that modified versions of such material be marked in
    reasonable ways as different from the original version; or

    d) Limiting the use for publicity purposes of names of licensors or
    authors of the material; or

    e) Declining to grant rights under trademark law for use of some
    trade names, trademarks, or service marks; or

    f) Requiring indemnification of licensors and authors of that
    material by anyone who conveys the material (or modified versions of
    it) with contractual assumptions of liability to the recipient, for
    any liability that these contractual assumptions directly impose on
    those licensors and authors.

  All other non-permissive additional terms are considered "further
restrictions" within the meaning of section 10.  If the Program as you
received it, or any part of it, contains a notice stating that it is
governed by this License along with a term that is a further
restriction, you may remove that term.  If a license document contains
a further restriction but permits relicensing or conveying under this
License, you may add to a covered work material governed by the terms
of that license document, provided that the further restriction does
not survive such relicensing or conveying.

  If you add terms to a covered work in accord with this section, you
must place, in the relevant source files, a statement of the
additional terms that apply to those files, or a notice indicating
where to find the applicable terms.

  Additional terms, permissive or non-permissive, may be stated in the
form of a separately written license, or stated as exceptions;
the above requirements apply either way.

  8. Termination.

  You may not propagate or modify a covered work except as expressly
provided under this License.  Any attempt otherwise to propagate or
modify it is void, and will automatically terminate your rights under
this License (including any patent licenses granted under the third
paragraph of section 11).

  However, if you cease all violation of this License, then your
license from a particular copyright holder is reinstated (a)
provisionally, unless and until the copyright holder explicitly and
finally terminates your license, and (b) permanently, if the copyright
holder fails to notify you of the violation by some reasonable means
prior to 60 days after the cessation.

  Moreover, your license from a particular copyright holder is
reinstated permanently if the copyright holder notifies you of the
violation by some reasonable means, this is the first time you have
received notice of violation of this License (for any work) from that
copyright holder, and you cure the violation prior to 30 days after
your receipt of the notice.

  Termination of your rights under this section does not terminate the
licenses of parties who have received copies or rights from you under
this License.  If your rights have been terminated and not permanently
reinstated, you do not qualify to receive new licenses for the same
material under section 10.

  9. Acceptance Not Required for Having Copies.

  You are not required to accept this License in order to receive or
run a copy of the Program.  Ancillary propagation of a covered work
occurring solely as a consequence of using peer-to-peer transmission
to receive a copy likewise does not require acceptance.  However,
nothing other than this License grants you permission to propagate or
modify any covered work.  These actions infringe copyright if you do
not accept this License.  Therefore, by modifying or propagating a
covered work, you indicate your acceptance of this License to do so.

  10. Automatic Licensing of Downstream Recipients.

  Each time you convey a covered work, the recipient automatically
receives a license from the original licensors, to run, modify and
propagate that work, subject to this License.  You are not responsible
for enforcing compliance by third parties with this License.

  An "entity transaction" is a transaction transferring control of an
organization, or substantially all assets of one, or subdividing an
organization, or merging organizations.  If propagation of a covered
work results from an entity transaction, each party to that
transaction who receives a copy of the work also receives whatever
licenses to the work the party's predecessor in interest had or could
give under the previous paragraph, plus a right to possession of the
Corresponding Source of the work from the predecessor in interest, if
the predecessor has it or can get it with reasonable efforts.

  You may not impose any further restrictions on the exercise of the
rights granted or affirmed under this License.  For example, you may
not impose a license fee, royalty, or other charge for exercise of
rights granted under this License, and you may not initiate litigation
(including a cross-claim or counterclaim in a lawsuit) alleging that
any patent claim is infringed by making, using, selling, offering for
sale, or importing the Program or any portion of it.

  11. Patents.

  A "contributor" is a copyright holder who authorizes use under this
License of the Program or a work on which the Program is based.  The
work thus licensed is called the contributor's "contributor version".

  A contributor's "essential patent claims" are all patent claims
owned or controlled by the contributor, whether already acquired or
hereafter acquired, that would be infringed by some manner, permitted
by this License, of making, using, or selling its contributor version,
but do not include claims that would be infringed only as a
consequence of further modification of the contributor version.  For
purposes of this definition, "control" includes the right to grant
patent sublicenses in a manner consistent with the requirements of
this License.

  Each contributor grants you a non-exclusive, worldwide, royalty-free
patent license under the contributor's essential patent claims, to
make, use, sell, offer for sale, import and otherwise run, modify and
propagate the contents of its contributor version.

  In the following three paragraphs, a "patent license" is any express
agreement or commitment, however denominated, not to enforce a patent
(such as an express permission to practice a patent or covenant not to
sue for patent infringement).  To "grant" such a patent license to a
party means to make such an agreement or commitment not to enforce a
patent against the party.

  If you convey a covered work, knowingly relying on a patent license,
and the Corresponding Source of the work is not available for anyone
to copy, free of charge and under the terms of this License, through a
publicly available network server or other readily accessible means,
then you must either (1) cause the Corresponding Source to be so
available, or (2) arrange to deprive yourself of the benefit of the
patent license for this particular work, or (3) arrange, in a manner
consistent with the requirements of this License, to extend the patent
license to downstream recipients.  "Knowingly relying" means you have
actual knowledge that, but for the patent license, your conveying the
covered work in a country, or your recipient's use of the covered work
in a country, would infringe one or more identifiable patents in that
country that you have reason to believe are valid.

  If, pursuant to or in connection with a single transaction or
arrangement, you convey, or propagate by procuring conveyance of, a
covered work, and grant a patent license to some of the parties
receiving the covered work authorizing them to use, propagate, modify
or convey a specific copy of the covered work, then the patent license
you grant is automatically extended to all recipients of the covered
work and works based on it.

  A patent license is "discriminatory" if it does not include within
the scope of its coverage, prohibits the exercise of, or is
conditioned on the non-exercise of one or more of the rights that are
specifically granted under this License.  You may not convey a covered
work if you are a party to an arrangement with a third party that is
in the business of distributing software, under which you make payment
to the third party based on the extent of your activity of conveying
the work, and under which the third party grants, to any of the
parties who would receive the covered work from you, a discriminatory
patent license (a) in connection with copies of the covered work
conveyed by you (or copies made from those copies), or (b) primarily
for and in connection with specific products or compilations that
contain the covered work, unless you entered into that arrangement,
or that patent license was granted, prior to 28 March 2007.

  Nothing in this License shall be construed as excluding or limiting
any implied license or other defenses to infringement that may
otherwise be available to you under applicable patent law.

  12. No Surrender of Others' Freedom.

  If conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License.  If you cannot convey a
covered work so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you may
not convey it at all.  For example, if you agree to terms that obligate you
to collect a royalty for further conveying from those to whom you convey
the Program, the only way you could satisfy both those terms and this
License would be to refrain entirely from conveying the Program.

  13. Use with the GNU Affero General Public License.

  Notwithstanding any other provision of this License, you have
permission to link or combine any covered work with a work licensed
under version 3 of the GNU Affero General Public License into a single
combined work, and to convey the resulting work.  The terms of this
License will continue to apply to the part which is the covered work,
but the special requirements of the GNU Affero General Public License,
section 13, concerning interaction through a network will apply to the
combination as such.

  14. Revised Versions of this License.

  The Free Software Foundation may publish revised and/or new versions of
the GNU General Public License from time to time.  Such new versions will
be similar in spirit to the present version, but may differ in detail to
address new problems or concerns.

  Each version is given a distinguishing version number.  If the
Program specifies that a certain numbered version of the GNU General
Public License "or any later version" applies to it, you have the
option of following the terms and conditions either of that numbered
version or of any later version published by the Free Software
Foundation.  If the Program does not specify a version number of the
GNU General Public License, you may choose any version ever published
by the Free Software Foundation.

  If the Program specifies that a proxy can decide which future
versions of the GNU General Public License can be used, that proxy's
public statement of acceptance of a version permanently authorizes you
to choose that version for the Program.

  Later license versions may give you additional or different
permissions.  However, no additional obligations are imposed on any
author or copyright holder as a result of your choosing to follow a
later version.

  15. Disclaimer of Warranty.

  THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
APPLICABLE LAW.  EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE.  THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
IS WITH YOU.  SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.

  16. Limitation of Liability.

  IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
SUCH DAMAGES.

  17. Interpretation of Sections 15 and 16.

  If the disclaimer of warranty and limitation of liability provided
above cannot be given local legal effect according to their terms,
reviewing courts shall apply local law that most closely approximates
an absolute waiver of all civil liability in connection with the
Program, unless a warranty or assumption of liability accompanies a
copy of the Program in return for a fee.

                     END OF TERMS AND CONDITIONS

            How to Apply These Terms to Your New Programs

  If you develop a new program, and you want it to be of the greatest
possible use to the public, the best way to achieve this is to make it
free software which everyone can redistribute and change under these terms.

  To do so, attach the following notices to the program.  It is safest
to attach them to the start of each source file to most effectively
state the exclusion of warranty; and each file should have at least
the "copyright" line and a pointer to where the full notice is found.

    <one line to give the program's name and a brief idea of what it does.>
    Copyright (C) <year>  <name of author>

    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <https://www.gnu.org/licenses/>.

Also add information on how to contact you by electronic and paper mail.

  If the program does terminal interaction, make it output a short
notice like this when it starts in an interactive mode:

    <program>  Copyright (C) <year>  <name of author>
    This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
    This is free software, and you are welcome to redistribute it
    under certain conditions; type `show c' for details.

The hypothetical commands `show w' and `show c' should show the appropriate
parts of the General Public License.  Of course, your program's commands
might be different; for a GUI interface, you would use an "about box".

  You should also get your employer (if you work as a programmer) or school,
if any, to sign a "copyright disclaimer" for the program, if necessary.
For more information on this, and how to apply and follow the GNU GPL, see
<https://www.gnu.org/licenses/>.

  The GNU General Public License does not permit incorporating your program
into proprietary programs.  If your program is a subroutine library, you
may consider it more useful to permit linking proprietary applications with
the library.  If this is what you want to do, use the GNU Lesser General
Public License instead of this License.  But first, please read
<https://www.gnu.org/licenses/why-not-lgpl.html>.


================================================
FILE: README.md
================================================
# 深度学习在图像处理中的应用教程

## 前言
* 本教程是对本人研究生期间的研究内容进行整理总结,总结的同时也希望能够帮助更多的小伙伴。后期如果有学习到新的知识也会与大家一起分享。
* 本教程会以视频的方式进行分享,教学流程如下:  
1)介绍网络的结构与创新点  
2)使用Pytorch进行网络的搭建与训练  
3)使用Tensorflow(内部的keras模块)进行网络的搭建与训练 
* 课程中所有PPT都放在`course_ppt`文件夹下,需要的自行下载。


## 教程目录,点击跳转相应视频(后期会根据学习内容增加)

* 图像分类
  * LeNet(已完成)
    * [Pytorch官方demo(Lenet)](https://www.bilibili.com/video/BV187411T7Ye)
    * [Tensorflow2官方demo](https://www.bilibili.com/video/BV1n7411T7o6)

  * AlexNet(已完成)
    * [AlexNet网络讲解](https://www.bilibili.com/video/BV1p7411T7Pc)
    * [Pytorch搭建AlexNet](https://www.bilibili.com/video/BV1W7411T7qc)
    * [Tensorflow2搭建Alexnet](https://www.bilibili.com/video/BV1s7411T7vs)

  * VggNet(已完成)
    * [VggNet网络讲解](https://www.bilibili.com/video/BV1q7411T7Y6)
    * [Pytorch搭建VGG网络](https://www.bilibili.com/video/BV1i7411T7ZN)
    * [Tensorflow2搭建VGG网络](https://www.bilibili.com/video/BV1q7411T76b)

  * GoogLeNet(已完成)
    * [GoogLeNet网络讲解](https://www.bilibili.com/video/BV1z7411T7ie)
    * [Pytorch搭建GoogLeNet网络](https://www.bilibili.com/video/BV1r7411T7M5)
    * [Tensorflow2搭建GoogLeNet网络](https://www.bilibili.com/video/BV1a7411T7Ht)

  * ResNet(已完成)
    * [ResNet网络讲解](https://www.bilibili.com/video/BV1T7411T7wa)
    * [Pytorch搭建ResNet网络](https://www.bilibili.com/video/BV14E411H7Uw)
    * [Tensorflow2搭建ResNet网络](https://www.bilibili.com/video/BV1WE41177Ya)

  * ResNeXt (已完成)
    * [ResNeXt网络讲解](https://www.bilibili.com/video/BV1Ap4y1p71v/)
    * [Pytorch搭建ResNeXt网络](https://www.bilibili.com/video/BV1rX4y1N7tE)

  * MobileNet_V1_V2(已完成)
    * [MobileNet_V1_V2网络讲解](https://www.bilibili.com/video/BV1yE411p7L7)
    * [Pytorch搭建MobileNetV2网络](https://www.bilibili.com/video/BV1qE411T7qZ)
    * [Tensorflow2搭建MobileNetV2网络](https://www.bilibili.com/video/BV1NE411K7tX)

  * MobileNet_V3(已完成)
    * [MobileNet_V3网络讲解](https://www.bilibili.com/video/BV1GK4y1p7uE)
    * [Pytorch搭建MobileNetV3网络](https://www.bilibili.com/video/BV1zT4y1P7pd)
    * [Tensorflow2搭建MobileNetV3网络](https://www.bilibili.com/video/BV1KA411g7wX)

  * ShuffleNet_V1_V2 (已完成)
    * [ShuffleNet_V1_V2网络讲解](https://www.bilibili.com/video/BV15y4y1Y7SY)
    * [使用Pytorch搭建ShuffleNetV2](https://www.bilibili.com/video/BV1dh411r76X)
    * [使用Tensorflow2搭建ShuffleNetV2](https://www.bilibili.com/video/BV1kr4y1N7bh)

  * EfficientNet_V1(已完成)
    * [EfficientNet网络讲解](https://www.bilibili.com/video/BV1XK4y1U7PX)
    * [使用Pytorch搭建EfficientNet](https://www.bilibili.com/video/BV19z4y1179h/)
    * [使用Tensorflow2搭建EfficientNet](https://www.bilibili.com/video/BV1PK4y1S7Jf)

  * EfficientNet_V2 (已完成)
    * [EfficientNetV2网络讲解](https://www.bilibili.com/video/BV19v41157AU)
    * [使用Pytorch搭建EfficientNetV2](https://www.bilibili.com/video/BV1Xy4y1g74u)
    * [使用Tensorflow搭建EfficientNetV2](https://www.bilibili.com/video/BV19K4y1g7m4)
  
  * RepVGG(已完成)
    * [RepVGG网络讲解](https://www.bilibili.com/video/BV15f4y1o7QR)

  * Vision Transformer(已完成)
    * [Multi-Head Attention讲解](https://www.bilibili.com/video/BV15v411W78M)
    * [Vision Transformer网络讲解](https://www.bilibili.com/video/BV1Jh411Y7WQ)
    * [使用Pytorch搭建Vision Transformer](https://www.bilibili.com/video/BV1AL411W7dT)
    * [使用tensorflow2搭建Vision Transformer](https://www.bilibili.com/video/BV1q64y1X7GY)

  * Swin Transformer(已完成)
    * [Swin Transformer网络讲解](https://www.bilibili.com/video/BV1pL4y1v7jC)
    * [使用Pytorch搭建Swin Transformer](https://www.bilibili.com/video/BV1yg411K7Yc)
    * [使用Tensorflow2搭建Swin Transformer](https://www.bilibili.com/video/BV1bR4y1t7qT)

  * ConvNeXt(已完成)
    * [ConvNeXt网络讲解](https://www.bilibili.com/video/BV1SS4y157fu)
    * [使用Pytorch搭建ConvNeXt](https://www.bilibili.com/video/BV14S4y1L791)
    * [使用Tensorflow2搭建ConvNeXt](https://www.bilibili.com/video/BV1TS4y1V7Gz)

  * MobileViT(已完成)
    * [MobileViT网络讲解](https://www.bilibili.com/video/BV1TG41137sb)
    * [使用Pytorch搭建MobileViT](https://www.bilibili.com/video/BV1ae411L7Ki)

* 目标检测
  * Faster-RCNN/FPN(已完成)
    * [Faster-RCNN网络讲解](https://www.bilibili.com/video/BV1af4y1m7iL)
    * [FPN网络讲解](https://www.bilibili.com/video/BV1dh411U7D9)
    * [Faster-RCNN源码解析(Pytorch)](https://www.bilibili.com/video/BV1of4y1m7nj)

  * SSD/RetinaNet (已完成)
    * [SSD网络讲解](https://www.bilibili.com/video/BV1fT4y1L7Gi)
    * [RetinaNet网络讲解](https://www.bilibili.com/video/BV1Q54y1L7sM)
    * [SSD源码解析(Pytorch)](https://www.bilibili.com/video/BV1vK411H771)

  * YOLO Series (已完成)
    * [YOLO系列网络讲解(V1~V3)](https://www.bilibili.com/video/BV1yi4y1g7ro)
    * [YOLOv3 SPP源码解析(Pytorch版)](https://www.bilibili.com/video/BV1t54y1C7ra)
    * [YOLOV4网络讲解](https://www.bilibili.com/video/BV1NF41147So)
    * [YOLOV5网络讲解](https://www.bilibili.com/video/BV1T3411p7zR)
    * [YOLOX 网络讲解](https://www.bilibili.com/video/BV1JW4y1k76c)
  
  * FCOS(已完成)
    * [FCOS网络讲解](https://www.bilibili.com/video/BV1G5411X7jw)

* 语义分割 
  * FCN (已完成)
    * [FCN网络讲解](https://www.bilibili.com/video/BV1J3411C7zd)
    * [FCN源码解析(Pytorch版)](https://www.bilibili.com/video/BV19q4y1971Q)

  * DeepLabV3 (已完成)
    * [DeepLabV1网络讲解](https://www.bilibili.com/video/BV1SU4y1N7Ao)
    * [DeepLabV2网络讲解](https://www.bilibili.com/video/BV1gP4y1G7TC)
    * [DeepLabV3网络讲解](https://www.bilibili.com/video/BV1Jb4y1q7j7)
    * [DeepLabV3源码解析(Pytorch版)](https://www.bilibili.com/video/BV1TD4y1c7Wx)

  * LR-ASPP (已完成)
    * [LR-ASPP网络讲解](https://www.bilibili.com/video/BV1LS4y1M76E)
    * [LR-ASPP源码解析(Pytorch版)](https://www.bilibili.com/video/bv13D4y1F7ML)
  
  * U-Net (已完成)
    * [U-Net网络讲解](https://www.bilibili.com/video/BV1Vq4y127fB/)
    * [U-Net源码解析(Pytorch版)](https://www.bilibili.com/video/BV1Vq4y127fB)
  
  * U2Net (已完成)
    * [U2Net网络讲解](https://www.bilibili.com/video/BV1yB4y1z7mj)
    * [U2Net源码解析(Pytorch版)](https://www.bilibili.com/video/BV1Kt4y137iS)

* 实例分割
  * Mask R-CNN(已完成)
    * [Mask R-CNN网络讲解](https://www.bilibili.com/video/BV1ZY411774T)
    * [Mask R-CNN源码解析(Pytorch版)](https://www.bilibili.com/video/BV1hY411E7wD)

* 关键点检测
  * DeepPose(已完成)
    * [DeepPose网络讲解](https://www.bilibili.com/video/BV1bm421g7aJ)
    * [DeepPose源码解析(Pytorch版)](https://www.bilibili.com/video/BV1bm421g7aJ)

  * HRNet(已完成)
    * [HRNet网络讲解](https://www.bilibili.com/video/BV1bB4y1y7qP)
    * [HRNet源码解析(Pytorch版)](https://www.bilibili.com/video/BV1ar4y157JM)

**[更多相关视频请进入我的bilibili频道查看](https://space.bilibili.com/18161609/channel/index)**

---

欢迎大家关注下我的微信公众号(**阿喆学习小记**),平时会总结些相关学习博文。    

如果有什么问题,也可以到我的CSDN中一起讨论。
[https://blog.csdn.net/qq_37541097/article/details/103482003](https://blog.csdn.net/qq_37541097/article/details/103482003)

我的bilibili频道:
[https://space.bilibili.com/18161609/channel/index](https://space.bilibili.com/18161609/channel/index)


================================================
FILE: article_link/README.md
================================================
# 文献链接

## 图像分类(Classification)
- LeNet [http://yann.lecun.com/exdb/lenet/index.html](http://yann.lecun.com/exdb/lenet/index.html)
- AlexNet [http://papers.nips.cc/paper/4824-imagenet-classification-with-deep-convolutional-neural-networks.pdf](http://papers.nips.cc/paper/4824-imagenet-classification-with-deep-convolutional-neural-networks.pdf)
- ZFNet(Visualizing and Understanding Convolutional Networks) [https://arxiv.org/abs/1311.2901](https://arxiv.org/abs/1311.2901)
- VGG [https://arxiv.org/abs/1409.1556](https://arxiv.org/abs/1409.1556)
- GoogLeNet, Inceptionv1(Going deeper with convolutions) [https://arxiv.org/abs/1409.4842](https://arxiv.org/abs/1409.4842)
- Batch Normalization [https://arxiv.org/abs/1502.03167](https://arxiv.org/abs/1502.03167)
- Inceptionv3(Rethinking the Inception Architecture for Computer Vision) [https://arxiv.org/abs/1512.00567](https://arxiv.org/abs/1512.00567)
- Inceptionv4, Inception-ResNet [https://arxiv.org/abs/1602.07261](https://arxiv.org/abs/1602.07261)
- Xception(Deep Learning with Depthwise Separable Convolutions) [https://arxiv.org/abs/1610.02357](https://arxiv.org/abs/1610.02357)
- ResNet [https://arxiv.org/abs/1512.03385](https://arxiv.org/abs/1512.03385)
- ResNeXt [https://arxiv.org/abs/1611.05431](https://arxiv.org/abs/1611.05431)
- DenseNet [https://arxiv.org/abs/1608.06993](https://arxiv.org/abs/1608.06993)
- NASNet-A(Learning Transferable Architectures for Scalable Image Recognition) [https://arxiv.org/abs/1707.07012](https://arxiv.org/abs/1707.07012)
- SENet(Squeeze-and-Excitation Networks) [https://arxiv.org/abs/1709.01507](https://arxiv.org/abs/1709.01507)
- MobileNet(v1) [https://arxiv.org/abs/1704.04861](https://arxiv.org/abs/1704.04861)
- MobileNet(v2) [https://arxiv.org/abs/1801.04381](https://arxiv.org/abs/1801.04381)
- MobileNet(v3) [https://arxiv.org/abs/1905.02244](https://arxiv.org/abs/1905.02244)
- ShuffleNet(v1) [https://arxiv.org/abs/1707.01083](https://arxiv.org/abs/1707.01083)
- ShuffleNet(v2) [https://arxiv.org/abs/1807.11164](https://arxiv.org/abs/1807.11164)
- Bag of Tricks for Image Classification with Convolutional Neural Networks [https://arxiv.org/abs/1812.01187](https://arxiv.org/abs/1812.01187)
- EfficientNet(v1) [https://arxiv.org/abs/1905.11946](https://arxiv.org/abs/1905.11946)
- EfficientNet(v2) [https://arxiv.org/abs/2104.00298](https://arxiv.org/abs/2104.00298)
- CSPNet [https://arxiv.org/abs/1911.11929](https://arxiv.org/abs/1911.11929)
- RegNet [https://arxiv.org/abs/2003.13678](https://arxiv.org/abs/2003.13678)
- NFNets(High-Performance Large-Scale Image Recognition Without Normalization) [https://arxiv.org/abs/2102.06171](https://arxiv.org/abs/2102.06171)
- Vision Transformer [https://arxiv.org/abs/2010.11929](https://arxiv.org/abs/2010.11929)
- DeiT(Training data-efficient image transformers ) [https://arxiv.org/abs/2012.12877](https://arxiv.org/abs/2012.12877)
- Swin Transformer [https://arxiv.org/abs/2103.14030](https://arxiv.org/abs/2103.14030)
- Swin Transformer V2: Scaling Up Capacity and Resolution [https://arxiv.org/abs/2111.09883](https://arxiv.org/abs/2111.09883)
- BEiT: BERT Pre-Training of Image Transformers [https://arxiv.org/abs/2106.08254](https://arxiv.org/abs/2106.08254)
- MAE(Masked Autoencoders Are Scalable Vision Learners) [https://arxiv.org/abs/2111.06377](https://arxiv.org/abs/2111.06377)
- ConvNeXt(A ConvNet for the 2020s) [https://arxiv.org/abs/2201.03545](https://arxiv.org/abs/2201.03545)
- MobileViT V1 [https://arxiv.org/abs/2110.02178](https://arxiv.org/abs/2110.02178)
- MobileViT V2(Separable Self-attention for Mobile Vision Transformers) [https://arxiv.org/abs/2206.02680](https://arxiv.org/abs/2206.02680)
- MobileOne(An Improved One millisecond Mobile Backbone) [https://arxiv.org/abs/2206.04040](https://arxiv.org/abs/2206.04040)


## 目标检测(Object Detection)
- R-CNN [https://arxiv.org/abs/1311.2524](https://arxiv.org/abs/1311.2524)
- Fast R-CNN [https://arxiv.org/abs/1504.08083](https://arxiv.org/abs/1504.08083)
- Faster R-CNN [https://arxiv.org/abs/1506.01497](https://arxiv.org/abs/1506.01497)
- Cascade R-CNN: Delving into High Quality Object Detection [https://arxiv.org/abs/1712.00726](https://arxiv.org/abs/1712.00726)
- Mask R-CNN [https://arxiv.org/abs/1703.06870](https://arxiv.org/abs/1703.06870)
- SSD [https://arxiv.org/abs/1512.02325](https://arxiv.org/abs/1512.02325)
- FPN(Feature Pyramid Networks for Object Detection) [https://arxiv.org/abs/1612.03144](https://arxiv.org/abs/1612.03144)
- RetinaNet(Focal Loss for Dense Object Detection) [https://arxiv.org/abs/1708.02002](https://arxiv.org/abs/1708.02002)
- Bag of Freebies for Training Object Detection Neural Networks [https://arxiv.org/abs/1902.04103](https://arxiv.org/abs/1902.04103)
- YOLOv1 [https://arxiv.org/abs/1506.02640](https://arxiv.org/abs/1506.02640)
- YOLOv2 [https://arxiv.org/abs/1612.08242](https://arxiv.org/abs/1612.08242)
- YOLOv3 [https://arxiv.org/abs/1804.02767](https://arxiv.org/abs/1804.02767)
- YOLOv4 [https://arxiv.org/abs/2004.10934](https://arxiv.org/abs/2004.10934)
- YOLOX(Exceeding YOLO Series in 2021) [https://arxiv.org/abs/2107.08430](https://arxiv.org/abs/2107.08430)
- YOLOv7 [https://arxiv.org/abs/2207.02696](https://arxiv.org/abs/2207.02696)
- PP-YOLO [https://arxiv.org/abs/2007.12099](https://arxiv.org/abs/2007.12099)
- PP-YOLOv2 [https://arxiv.org/abs/2104.10419](https://arxiv.org/abs/2104.10419)
- CornerNet [https://arxiv.org/abs/1808.01244](https://arxiv.org/abs/1808.01244)
- FCOS(Old) [https://arxiv.org/abs/1904.01355](https://arxiv.org/abs/1904.01355)
- FCOS(New) [https://arxiv.org/abs/2006.09214](https://arxiv.org/abs/2006.09214)
- CenterNet [https://arxiv.org/abs/1904.07850](https://arxiv.org/abs/1904.07850)


## 语义分割(Semantic Segmentation)
- FCN(Fully Convolutional Networks for Semantic Segmentation) [https://arxiv.org/abs/1411.4038](https://arxiv.org/abs/1411.4038)
- UNet(U-Net: Convolutional Networks for Biomedical Image Segmentation) [https://arxiv.org/abs/1505.04597](https://arxiv.org/abs/1505.04597)
- DeepLabv1(Semantic Image Segmentation with Deep Convolutional Nets and Fully Connected CRFs) [https://arxiv.org/abs/1412.7062](https://arxiv.org/abs/1412.7062)
- DeepLabv2(Semantic Image Segmentation with Deep Convolutional Nets, Atrous Convolution, and Fully Connected CRFs) [https://arxiv.org/abs/1606.00915](https://arxiv.org/abs/1606.00915)
- DeepLabv3(Rethinking Atrous Convolution for Semantic Image Segmentation) [https://arxiv.org/abs/1706.05587](https://arxiv.org/abs/1706.05587)
- DeepLabv3+(Encoder-Decoder with Atrous Separable Convolution for Semantic Image Segmentation) [https://arxiv.org/abs/1802.02611](https://arxiv.org/abs/1802.02611)
- SegFormer [https://arxiv.org/abs/2105.15203](https://arxiv.org/abs/2105.15203)


## 显著性目标检测(Salient Object Detection)
- U2Net [https://arxiv.org/abs/2005.09007](https://arxiv.org/abs/2005.09007)


## 实例分割(Instance Segmentation)
- Mask R-CNN [https://arxiv.org/abs/1703.06870](https://arxiv.org/abs/1703.06870)


## 关键点检测(Keypoint Detection)
- HRNet(Deep High-Resolution Representation Learning for Human Pose Estimation) [https://arxiv.org/abs/1902.09212](https://arxiv.org/abs/1902.09212)

## 网络量化(Quantization)
- Quantization and Training of Neural Networks for Efficient Integer-Arithmetic-Only Inference [https://arxiv.org/abs/1712.05877](https://arxiv.org/abs/1712.05877)
- Quantizing deep convolutional networks for efficient inference: A whitepaper [https://arxiv.org/abs/1806.08342](https://arxiv.org/abs/1806.08342)
- Data-Free Quantization Through Weight Equalization and Bias Correction [https://arxiv.org/abs/1906.04721](https://arxiv.org/abs/1906.04721)
- LSQ: Learned Step Size Quantization [https://arxiv.org/abs/1902.08153](https://arxiv.org/abs/1902.08153)
- LSQ+: Improving low-bit quantization through learnable offsets and better initialization [https://arxiv.org/abs/2004.09576](https://arxiv.org/abs/2004.09576)



## 自然语言处理
- Attention Is All You Need [https://arxiv.org/abs/1706.03762](https://arxiv.org/abs/1706.03762)

## Others
- Microsoft COCO: Common Objects in Context [https://arxiv.org/abs/1405.0312](https://arxiv.org/abs/1405.0312)
- The PASCALVisual Object Classes Challenge: A Retrospective [http://host.robots.ox.ac.uk/pascal/VOC/pubs/everingham15.pdf](http://host.robots.ox.ac.uk/pascal/VOC/pubs/everingham15.pdf)
- Grad-CAM: Visual Explanations from Deep Networks via Gradient-based Localization [https://arxiv.org/abs/1610.02391](https://arxiv.org/abs/1610.02391)


================================================
FILE: course_ppt/README.md
================================================
# 为了精简项目,课程中的所有ppt都已转存至百度云

**所有PPT都放在该文件夹中** 链接:https://pan.baidu.com/s/1VL6QTQ86sfY2aMDVo4Z-kg 提取码:4ydw

**下面为单独每个ppt的链接**:
## 分类网络相关
- **AlexNet** 链接: https://pan.baidu.com/s/1RJn5lzY8LwrmckUPvXcjmg  提取码: 34ue
- **VGG** 链接: https://pan.baidu.com/s/1BnYpdaDwAIcgRm7YwakEZw  提取码: 8ev0
- **GoogleNet** 链接: https://pan.baidu.com/s/1XjZXprvayV3dDMvLjoOk3A  提取码: 9hq4
- **ResNet** 链接: https://pan.baidu.com/s/1I2LUlwCSjNKr37T0n3NKzg  提取码: f1s9
- **ResNext** 链接:https://pan.baidu.com/s/1-anFYX5572MJmiQym9D4Eg 提取码:f8ob 
- **MobileNet_v1_v2** 链接: https://pan.baidu.com/s/1ReDDCuK8wyH0XqniUgiSYQ  提取码: ipqv
- **MobileNet_v3**  链接:https://pan.baidu.com/s/13mzSpyxuA4T4ki7kEN1Xqw 提取码:fp5g 
- **ShuffleNet_v1_v2** 链接:https://pan.baidu.com/s/1-DDwePMPCDvjw08YU8nAAA 提取码:ad6n
- **EfficientNet_v1** 链接:https://pan.baidu.com/s/1Sep9W0vLzfjhcHAXr6Bv0Q  提取码:eufl 
- **EfficientNet_v2** 链接:https://pan.baidu.com/s/1tesrgY4CHLmq6P7s7TcHCw  提取码:y2kz
- **Transformer** 链接:https://pan.baidu.com/s/1DE6RDySr7NS0HQ35gBqP_g 提取码:y9e7
- **Vision Transformer** 链接:https://pan.baidu.com/s/1wzpHG8EK5gxg6UCMscYqMw 提取码:cm1m
- **Swin Transformer** 链接:https://pan.baidu.com/s/1O6XEEZUb6B6AGYON7-EOgA 提取码:qkrn
- **ConvNeXt** 链接:https://pan.baidu.com/s/1mgZjkirJPZ8huVls-O0xXA  提取码:kvqx
- **RepVGG** 链接:https://pan.baidu.com/s/1uJP3hCHI79-tUdBNR_VAWQ  提取码:qe8a
- **MobileViT** 链接:https://pan.baidu.com/s/1F8QJtFhTPWX8Vjr8_97scQ  提取码:lfn5
- **ConfusionMatrix** 链接: https://pan.baidu.com/s/1EtKzHkZyv2XssYtqmGYCLg  提取码: uoo5
- **Grad-CAM** 链接:https://pan.baidu.com/s/1ZHKBW7hINQXFI36hBYdC0Q  提取码:aru7


## 目标检测网络相关
- **R-CNN** 链接: https://pan.baidu.com/s/1l_ZxkfJdyp3KoMLqwWbx5A  提取码: nm1l
- **Fast R-CNN** 链接: https://pan.baidu.com/s/1Pe_Tg43OVo-yZWj7t-_L6Q  提取码: fe73
- **Faster R-CNN** 链接:https://pan.baidu.com/s/1Dd0d_LY8l7Y1YkHQhp-WfA  提取码:vzp4
- **FPN** 链接:https://pan.baidu.com/s/1O9H0iqQMg9f_FZezUEKZ9g 提取码:qbl8 
- **SSD** 链接: https://pan.baidu.com/s/15zF3GhIdg-E_tZX2Y2X-rw  提取码: u7k1
- **RetinaNet**  链接:https://pan.baidu.com/s/1beW612VCSnSu-v8iu_2-fA 提取码:vqbu 
- **YOLOv1** 链接: https://pan.baidu.com/s/1vVyUNQHYEGjqosezlx_1Mg  提取码: b3i0
- **YOLOv2** 链接: https://pan.baidu.com/s/132aW1e_NYbaxxGi3cDVLYg  提取码: tak7
- **YOLOv3** 链接:https://pan.baidu.com/s/1hZqdgh7wA7QeGAYTttlVOQ  提取码:5ulo
- **YOLOv3SPP** 链接: https://pan.baidu.com/s/15LRssnPez9pn6jRpW89Wlw  提取码: nv9f
- **YOLOv4** 链接:https://pan.baidu.com/s/1Ltw4v1pg0eZNFYR2ZBbZmQ  提取码:qjx4
- **YOLOv5** 链接:https://pan.baidu.com/s/1rnvjwHLvOlJ9KpJ5z95GWw  提取码:kt04
- **YOLOX** 链接:https://pan.baidu.com/s/1ex54twQC7hBE3szNko_K5A  提取码:al0r
- **FCOS** 链接: https://pan.baidu.com/s/1KUc9dzvAbtwtGGm3ZZy_cw  提取码: h0as
- **Calculate mAP** 链接: https://pan.baidu.com/s/1jdA_n78J7nSUoOg6TTO5Bg  提取码: eh62
- **coco数据集简介** 链接:https://pan.baidu.com/s/1HfCvjt-8o9j5a916IYNVjw  提取码:6rec 


## 图像分割网络相关
- **语义分割前言** 链接:https://pan.baidu.com/s/1cwxe2wbaA_2DqNYADq3myA 提取码:zzij
- **转置卷积** 链接:https://pan.baidu.com/s/1A8688168fuWHyxJQtzupHw 提取码:pgnf
- **FCN** 链接:https://pan.baidu.com/s/1XLUneTLrdUyDAiV6kqi9rw 提取码:126a
- **膨胀卷积** 链接:https://pan.baidu.com/s/1QlQyniuMhBeXyEK420MIdQ 提取码:ry6p
- **DeepLab V1** 链接:https://pan.baidu.com/s/1NFxb7ADQOMVYLxmIKqTONQ  提取码:500s
- **DeepLab V2** 链接:https://pan.baidu.com/s/1woe3lJYBVkOdnn6XXlKf8g 提取码:76ec
- **DeepLab V3** 链接:https://pan.baidu.com/s/1WVBgc2Ld13D0_dkHGwhTpA 提取码:m54m
- **UNet** 链接: https://pan.baidu.com/s/1WDwI-DuzYklMvwyRxVUXjA 提取码: rd4j
- **U2Net**  链接:https://pan.baidu.com/s/1ekbEm4dsjlFamK8dCs8yfA  提取码:472j


## 实例分割
- **Mask R-CNN** 链接:https://pan.baidu.com/s/1JpQ7ENEv_x9A1-O_NpjwYA 提取码:1t4i

## 关键点检测
- **HRNet** 链接: https://pan.baidu.com/s/1-8AJdU82K1j70KZK_rN7aQ  提取码: t4me



================================================
FILE: data_set/README.md
================================================
## 该文件夹是用来存放训练数据的目录
### 使用步骤如下:
* (1)在data_set文件夹下创建新文件夹"flower_data"
* (2)点击链接下载花分类数据集 [https://storage.googleapis.com/download.tensorflow.org/example_images/flower_photos.tgz](https://storage.googleapis.com/download.tensorflow.org/example_images/flower_photos.tgz)
* (3)解压数据集到flower_data文件夹下
* (4)执行"split_data.py"脚本自动将数据集划分成训练集train和验证集val    

```
├── flower_data   
       ├── flower_photos(解压的数据集文件夹,3670个样本)  
       ├── train(生成的训练集,3306个样本)  
       └── val(生成的验证集,364个样本) 
```


================================================
FILE: data_set/split_data.py
================================================
import os
from shutil import copy, rmtree
import random


def mk_file(file_path: str):
    if os.path.exists(file_path):
        # 如果文件夹存在,则先删除原文件夹在重新创建
        rmtree(file_path)
    os.makedirs(file_path)


def main():
    # 保证随机可复现
    random.seed(0)

    # 将数据集中10%的数据划分到验证集中
    split_rate = 0.1

    # 指向你解压后的flower_photos文件夹
    cwd = os.getcwd()
    data_root = os.path.join(cwd, "flower_data")
    origin_flower_path = os.path.join(data_root, "flower_photos")
    assert os.path.exists(origin_flower_path), "path '{}' does not exist.".format(origin_flower_path)

    flower_class = [cla for cla in os.listdir(origin_flower_path)
                    if os.path.isdir(os.path.join(origin_flower_path, cla))]

    # 建立保存训练集的文件夹
    train_root = os.path.join(data_root, "train")
    mk_file(train_root)
    for cla in flower_class:
        # 建立每个类别对应的文件夹
        mk_file(os.path.join(train_root, cla))

    # 建立保存验证集的文件夹
    val_root = os.path.join(data_root, "val")
    mk_file(val_root)
    for cla in flower_class:
        # 建立每个类别对应的文件夹
        mk_file(os.path.join(val_root, cla))

    for cla in flower_class:
        cla_path = os.path.join(origin_flower_path, cla)
        images = os.listdir(cla_path)
        num = len(images)
        # 随机采样验证集的索引
        eval_index = random.sample(images, k=int(num*split_rate))
        for index, image in enumerate(images):
            if image in eval_index:
                # 将分配至验证集中的文件复制到相应目录
                image_path = os.path.join(cla_path, image)
                new_path = os.path.join(val_root, cla)
                copy(image_path, new_path)
            else:
                # 将分配至训练集中的文件复制到相应目录
                image_path = os.path.join(cla_path, image)
                new_path = os.path.join(train_root, cla)
                copy(image_path, new_path)
            print("\r[{}] processing [{}/{}]".format(cla, index+1, num), end="")  # processing bar
        print()

    print("processing done!")


if __name__ == '__main__':
    main()


================================================
FILE: deploying_service/deploying_pytorch/convert_onnx_cls/class_indices.json
================================================
{
    "0": "daisy",
    "1": "dandelion",
    "2": "roses",
    "3": "sunflowers",
    "4": "tulips"
}

================================================
FILE: deploying_service/deploying_pytorch/convert_onnx_cls/main.py
================================================
from PIL import Image
import torchvision.transforms as transforms
import torch
import torch.onnx
import onnx
import onnxruntime
import numpy as np
from model import resnet34

device = torch.device("cpu")


def to_numpy(tensor):
    return tensor.detach().cpu().numpy() if tensor.requires_grad else tensor.cpu().numpy()


def main(save_path=None):
    assert isinstance(save_path, str), "lack of save_path parameter..."
    # create model
    model = resnet34(num_classes=5)
    # load model weights
    model_weight_path = "./resNet34.pth"
    model.load_state_dict(torch.load(model_weight_path, map_location=device))
    model.eval()
    # input to the model
    # [batch, channel, height, width]
    x = torch.rand(1, 3, 224, 224, requires_grad=True)
    torch_out = model(x)

    # export the model
    torch.onnx.export(model,                       # model being run
                      x,                           # model input (or a tuple for multiple inputs)
                      save_path,                   # where to save the model (can be a file or file-like object)
                      export_params=True,          # store the trained parameter weights inside the model file
                      opset_version=10,            # the ONNX version to export the model to
                      do_constant_folding=True,    # whether to execute constant folding for optimization
                      input_names=["input"],       # the model's input names
                      output_names=["output"],     # the model's output names
                      dynamic_axes={"input": {0: "batch_size"},  # variable length axes
                                    "output": {0: "batch_size"}})

    # check onnx model
    onnx_model = onnx.load(save_path)
    onnx.checker.check_model(onnx_model)

    ort_session = onnxruntime.InferenceSession(save_path)

    # compute ONNX Runtime output prediction
    ort_inputs = {ort_session.get_inputs()[0].name: to_numpy(x)}
    ort_outs = ort_session.run(None, ort_inputs)

    # compare ONNX Runtime and Pytorch results
    # assert_allclose: Raises an AssertionError if two objects are not equal up to desired tolerance.
    np.testing.assert_allclose(to_numpy(torch_out), ort_outs[0], rtol=1e-03, atol=1e-05)
    print("Exported model has been tested with ONNXRuntime, and the result looks good!")

    # load test image
    img = Image.open("../tulip.jpg")

    # pre-process
    preprocess = transforms.Compose([transforms.Resize([224, 224]),
                                     transforms.ToTensor(),
                                     transforms.Normalize([0.485, 0.456, 0.406], [0.229, 0.224, 0.225])])
    img = preprocess(img)
    img = img.unsqueeze_(0)

    # feed image into onnx model
    ort_inputs = {ort_session.get_inputs()[0].name: to_numpy(img)}
    ort_outs = ort_session.run(None, ort_inputs)
    prediction = ort_outs[0]

    # np softmax process
    prediction -= np.max(prediction, keepdims=True)  # 为了稳定地计算softmax概率, 一般会减掉最大元素
    prediction = np.exp(prediction) / np.sum(np.exp(prediction), keepdims=True)
    print(prediction)


if __name__ == '__main__':
    onnx_file_name = "resnet34.onnx"
    main(save_path=onnx_file_name)


================================================
FILE: deploying_service/deploying_pytorch/convert_onnx_cls/model.py
================================================
import torch.nn as nn
import torch


class BasicBlock(nn.Module):
    expansion = 1

    def __init__(self, in_channel, out_channel, stride=1, downsample=None):
        super(BasicBlock, self).__init__()
        self.conv1 = nn.Conv2d(in_channels=in_channel, out_channels=out_channel,
                               kernel_size=3, stride=stride, padding=1, bias=False)
        self.bn1 = nn.BatchNorm2d(out_channel)
        self.relu = nn.ReLU()
        self.conv2 = nn.Conv2d(in_channels=out_channel, out_channels=out_channel,
                               kernel_size=3, stride=1, padding=1, bias=False)
        self.bn2 = nn.BatchNorm2d(out_channel)
        self.downsample = downsample

    def forward(self, x):
        identity = x
        if self.downsample is not None:
            identity = self.downsample(x)

        out = self.conv1(x)
        out = self.bn1(out)
        out = self.relu(out)

        out = self.conv2(out)
        out = self.bn2(out)

        out += identity
        out = self.relu(out)

        return out


class Bottleneck(nn.Module):
    expansion = 4

    def __init__(self, in_channel, out_channel, stride=1, downsample=None):
        super(Bottleneck, self).__init__()
        self.conv1 = nn.Conv2d(in_channels=in_channel, out_channels=out_channel,
                               kernel_size=1, stride=1, bias=False)  # squeeze channels
        self.bn1 = nn.BatchNorm2d(out_channel)
        # -----------------------------------------
        self.conv2 = nn.Conv2d(in_channels=out_channel, out_channels=out_channel,
                               kernel_size=3, stride=stride, bias=False, padding=1)
        self.bn2 = nn.BatchNorm2d(out_channel)
        # -----------------------------------------
        self.conv3 = nn.Conv2d(in_channels=out_channel, out_channels=out_channel*self.expansion,
                               kernel_size=1, stride=1, bias=False)  # unsqueeze channels
        self.bn3 = nn.BatchNorm2d(out_channel*self.expansion)
        self.relu = nn.ReLU(inplace=True)
        self.downsample = downsample

    def forward(self, x):
        identity = x
        if self.downsample is not None:
            identity = self.downsample(x)

        out = self.conv1(x)
        out = self.bn1(out)
        out = self.relu(out)

        out = self.conv2(out)
        out = self.bn2(out)
        out = self.relu(out)

        out = self.conv3(out)
        out = self.bn3(out)

        out += identity
        out = self.relu(out)

        return out


class ResNet(nn.Module):

    def __init__(self, block, blocks_num, num_classes=1000, include_top=True):
        super(ResNet, self).__init__()
        self.include_top = include_top
        self.in_channel = 64

        self.conv1 = nn.Conv2d(3, self.in_channel, kernel_size=7, stride=2,
                               padding=3, bias=False)
        self.bn1 = nn.BatchNorm2d(self.in_channel)
        self.relu = nn.ReLU(inplace=True)
        self.maxpool = nn.MaxPool2d(kernel_size=3, stride=2, padding=1)
        self.layer1 = self._make_layer(block, 64, blocks_num[0])
        self.layer2 = self._make_layer(block, 128, blocks_num[1], stride=2)
        self.layer3 = self._make_layer(block, 256, blocks_num[2], stride=2)
        self.layer4 = self._make_layer(block, 512, blocks_num[3], stride=2)
        if self.include_top:
            self.avgpool = nn.AdaptiveAvgPool2d((1, 1))  # output size = (1, 1)
            self.fc = nn.Linear(512 * block.expansion, num_classes)

        for m in self.modules():
            if isinstance(m, nn.Conv2d):
                nn.init.kaiming_normal_(m.weight, mode='fan_out', nonlinearity='relu')

    def _make_layer(self, block, channel, block_num, stride=1):
        downsample = None
        if stride != 1 or self.in_channel != channel * block.expansion:
            downsample = nn.Sequential(
                nn.Conv2d(self.in_channel, channel * block.expansion, kernel_size=1, stride=stride, bias=False),
                nn.BatchNorm2d(channel * block.expansion))

        layers = []
        layers.append(block(self.in_channel, channel, downsample=downsample, stride=stride))
        self.in_channel = channel * block.expansion

        for _ in range(1, block_num):
            layers.append(block(self.in_channel, channel))

        return nn.Sequential(*layers)

    def forward(self, x):
        x = self.conv1(x)
        x = self.bn1(x)
        x = self.relu(x)
        x = self.maxpool(x)

        x = self.layer1(x)
        x = self.layer2(x)
        x = self.layer3(x)
        x = self.layer4(x)

        if self.include_top:
            x = self.avgpool(x)
            x = torch.flatten(x, 1)
            x = self.fc(x)

        return x


def resnet34(num_classes=1000, include_top=True):
    return ResNet(BasicBlock, [3, 4, 6, 3], num_classes=num_classes, include_top=include_top)


def resnet101(num_classes=1000, include_top=True):
    return ResNet(Bottleneck, [3, 4, 23, 3], num_classes=num_classes, include_top=include_top)


================================================
FILE: deploying_service/deploying_pytorch/convert_openvino/convert_resnet34/README.md
================================================
本项目展示如何将Pytorch中的ResNet34网络转成Openvino的IR格式,并进行量化处理,具体使用流程如下:
1. 按照`requirements.txt`配置环境
2. 下载事先训练好的ResNet34权重(之前在花分类数据集上训练得到的)放在当前文件夹下。百度云链接: https://pan.baidu.com/s/1x4WFX1HynYcXLium3UaaFQ  密码: qvi6
3. 使用`convert_pytorch2onnx.py`将Resnet34转成ONNX格式
4. 在命令行中使用以下指令将ONNX转成IR格式:
```
mo  --input_model resnet34.onnx \
    --input_shape "[1,3,224,224]" \
    --mean_values="[123.675,116.28,103.53]" \
    --scale_values="[58.395,57.12,57.375]" \
    --data_type FP32 \
    --output_dir ir_output
```
5. 下载并解压花分类数据集,将`quantization_int8.py`中的`data_path`指向解压后的`flower_photos`
6. 使用`quantization_int8.py`量化模型

================================================
FILE: deploying_service/deploying_pytorch/convert_openvino/convert_resnet34/compare_fps.py
================================================
import time
import numpy as np
import torch
import onnxruntime
import matplotlib.pyplot as plt
from openvino.runtime import Core
from torchvision.models import resnet34


def normalize(image: np.ndarray) -> np.ndarray:
    """
    Normalize the image to the given mean and standard deviation
    """
    image = image.astype(np.float32)
    mean = (0.485, 0.456, 0.406)
    std = (0.229, 0.224, 0.225)
    image /= 255.0
    image -= mean
    image /= std
    return image


def onnx_inference(onnx_path: str, image: np.ndarray, num_images: int = 20):
    # load onnx model
    ort_session = onnxruntime.InferenceSession(onnx_path)

    # compute onnx Runtime output prediction
    ort_inputs = {ort_session.get_inputs()[0].name: image}

    start = time.perf_counter()
    for _ in range(num_images):
        ort_session.run(None, ort_inputs)
    end = time.perf_counter()
    time_onnx = end - start
    print(
        f"ONNX model in Inference Engine/CPU: {time_onnx / num_images:.3f} "
        f"seconds per image, FPS: {num_images / time_onnx:.2f}"
    )

    return num_images / time_onnx


def ir_inference(ir_path: str, image: np.ndarray, num_images: int = 20):
    # Load the network in Inference Engine
    ie = Core()
    model_ir = ie.read_model(model=ir_path)
    compiled_model_ir = ie.compile_model(model=model_ir, device_name="CPU")

    # Get input and output layers
    input_layer_ir = next(iter(compiled_model_ir.inputs))
    output_layer_ir = next(iter(compiled_model_ir.outputs))

    start = time.perf_counter()
    request_ir = compiled_model_ir.create_infer_request()
    for _ in range(num_images):
        request_ir.infer(inputs={input_layer_ir.any_name: image})
    end = time.perf_counter()
    time_ir = end - start
    print(
        f"IR model in Inference Engine/CPU: {time_ir / num_images:.3f} "
        f"seconds per image, FPS: {num_images / time_ir:.2f}"
    )

    return num_images / time_ir


def pytorch_inference(image: np.ndarray, num_images: int = 20):
    image = torch.as_tensor(image, dtype=torch.float32)

    model = resnet34(pretrained=False, num_classes=5)
    model.eval()

    with torch.no_grad():
        start = time.perf_counter()
        for _ in range(num_images):
            model(image)
        end = time.perf_counter()
        time_torch = end - start

    print(
        f"PyTorch model on CPU: {time_torch / num_images:.3f} seconds per image, "
        f"FPS: {num_images / time_torch:.2f}"
    )

    return num_images / time_torch


def plot_fps(v: dict):
    x = list(v.keys())
    y = list(v.values())

    plt.bar(range(len(x)), y, align='center')
    plt.xticks(range(len(x)), x)
    for i, v in enumerate(y):
        plt.text(x=i, y=v+0.5, s=f"{v:.2f}", ha='center')
    plt.xlabel('model format')
    plt.ylabel('fps')
    plt.title('FPS comparison')
    plt.show()
    plt.savefig('fps_vs.jpg')


def main():
    image_h = 224
    image_w = 224
    onnx_path = "resnet34.onnx"
    ir_path = "ir_output/resnet34.xml"

    image = np.random.randn(image_h, image_w, 3)
    normalized_image = normalize(image)

    # Convert the resized images to network input shape
    # [h, w, c] -> [c, h, w] -> [1, c, h, w]
    input_image = np.expand_dims(np.transpose(image, (2, 0, 1)), 0)
    normalized_input_image = np.expand_dims(np.transpose(normalized_image, (2, 0, 1)), 0)

    onnx_fps = onnx_inference(onnx_path, normalized_input_image, num_images=100)
    ir_fps = ir_inference(ir_path, input_image, num_images=100)
    pytorch_fps = pytorch_inference(normalized_input_image, num_images=100)
    plot_fps({"pytorch": round(pytorch_fps, 2),
              "onnx": round(onnx_fps, 2),
              "ir": round(ir_fps, 2)})


if __name__ == '__main__':
    main()


================================================
FILE: deploying_service/deploying_pytorch/convert_openvino/convert_resnet34/compare_onnx_and_ir.py
================================================
import numpy as np
import onnxruntime
from openvino.runtime import Core


def normalize(image: np.ndarray) -> np.ndarray:
    """
    Normalize the image to the given mean and standard deviation
    """
    image = image.astype(np.float32)
    mean = (0.485, 0.456, 0.406)
    std = (0.229, 0.224, 0.225)
    image /= 255.0
    image -= mean
    image /= std
    return image


def onnx_inference(onnx_path: str, image: np.ndarray):
    # load onnx model
    ort_session = onnxruntime.InferenceSession(onnx_path)

    # compute onnx Runtime output prediction
    ort_inputs = {ort_session.get_inputs()[0].name: image}
    res_onnx = ort_session.run(None, ort_inputs)[0]
    return res_onnx


def ir_inference(ir_path: str, image: np.ndarray):
    # Load the network in Inference Engine
    ie = Core()
    model_ir = ie.read_model(model=ir_path)
    compiled_model_ir = ie.compile_model(model=model_ir, device_name="CPU")

    # Get input and output layers
    input_layer_ir = next(iter(compiled_model_ir.inputs))
    output_layer_ir = next(iter(compiled_model_ir.outputs))

    # Run inference on the input image
    res_ir = compiled_model_ir([image])[output_layer_ir]
    return res_ir


def main():
    image_h = 224
    image_w = 224
    onnx_path = "resnet34.onnx"
    ir_path = "ir_output/resnet34.xml"

    image = np.random.randn(image_h, image_w, 3)
    normalized_image = normalize(image)

    # Convert the resized images to network input shape
    # [h, w, c] -> [c, h, w] -> [1, c, h, w]
    input_image = np.expand_dims(np.transpose(image, (2, 0, 1)), 0)
    normalized_input_image = np.expand_dims(np.transpose(normalized_image, (2, 0, 1)), 0)

    onnx_res = onnx_inference(onnx_path, normalized_input_image)
    ir_res = ir_inference(ir_path, input_image)
    np.testing.assert_allclose(onnx_res, ir_res, rtol=1e-03, atol=1e-05)
    print("Exported model has been tested with OpenvinoRuntime, and the result looks good!")


if __name__ == '__main__':
    main()


================================================
FILE: deploying_service/deploying_pytorch/convert_openvino/convert_resnet34/convert_pytorch2onnx.py
================================================
import torch
import torch.onnx
import onnx
import onnxruntime
import numpy as np
from torchvision.models import resnet34

device = torch.device("cpu")


def to_numpy(tensor):
    return tensor.detach().cpu().numpy() if tensor.requires_grad else tensor.cpu().numpy()


def main():
    weights_path = "resNet34(flower).pth"
    onnx_file_name = "resnet34.onnx"
    batch_size = 1
    img_h = 224
    img_w = 224
    img_channel = 3

    # create model and load pretrain weights
    model = resnet34(pretrained=False, num_classes=5)
    model.load_state_dict(torch.load(weights_path, map_location='cpu'))

    model.eval()
    # input to the model
    # [batch, channel, height, width]
    x = torch.rand(batch_size, img_channel, img_h, img_w, requires_grad=True)
    torch_out = model(x)

    # export the model
    torch.onnx.export(model,             # model being run
                      x,                 # model input (or a tuple for multiple inputs)
                      onnx_file_name,    # where to save the model (can be a file or file-like object)
                      verbose=False)

    # check onnx model
    onnx_model = onnx.load(onnx_file_name)
    onnx.checker.check_model(onnx_model)

    ort_session = onnxruntime.InferenceSession(onnx_file_name)

    # compute ONNX Runtime output prediction
    ort_inputs = {ort_session.get_inputs()[0].name: to_numpy(x)}
    ort_outs = ort_session.run(None, ort_inputs)

    # compare ONNX Runtime and Pytorch results
    # assert_allclose: Raises an AssertionError if two objects are not equal up to desired tolerance.
    np.testing.assert_allclose(to_numpy(torch_out), ort_outs[0], rtol=1e-03, atol=1e-05)
    print("Exported model has been tested with ONNXRuntime, and the result looks good!")


if __name__ == '__main__':
    main()


================================================
FILE: deploying_service/deploying_pytorch/convert_openvino/convert_resnet34/model.py
================================================
from typing import Callable, List, Optional

import torch
from torch import nn, Tensor
from torch.nn import functional as F
from functools import partial


def _make_divisible(ch, divisor=8, min_ch=None):
    """
    This function is taken from the original tf repo.
    It ensures that all layers have a channel number that is divisible by 8
    It can be seen here:
    https://github.com/tensorflow/models/blob/master/research/slim/nets/mobilenet/mobilenet.py
    """
    if min_ch is None:
        min_ch = divisor
    new_ch = max(min_ch, int(ch + divisor / 2) // divisor * divisor)
    # Make sure that round down does not go down by more than 10%.
    if new_ch < 0.9 * ch:
        new_ch += divisor
    return new_ch


class ConvBNActivation(nn.Sequential):
    def __init__(self,
                 in_planes: int,
                 out_planes: int,
                 kernel_size: int = 3,
                 stride: int = 1,
                 groups: int = 1,
                 norm_layer: Optional[Callable[..., nn.Module]] = None,
                 activation_layer: Optional[Callable[..., nn.Module]] = None):
        padding = (kernel_size - 1) // 2
        if norm_layer is None:
            norm_layer = nn.BatchNorm2d
        if activation_layer is None:
            activation_layer = nn.ReLU6
        super(ConvBNActivation, self).__init__(nn.Conv2d(in_channels=in_planes,
                                                         out_channels=out_planes,
                                                         kernel_size=kernel_size,
                                                         stride=stride,
                                                         padding=padding,
                                                         groups=groups,
                                                         bias=False),
                                               norm_layer(out_planes),
                                               activation_layer(inplace=True))


class SqueezeExcitation(nn.Module):
    def __init__(self, input_c: int, squeeze_factor: int = 4):
        super(SqueezeExcitation, self).__init__()
        squeeze_c = _make_divisible(input_c // squeeze_factor, 8)
        self.fc1 = nn.Conv2d(input_c, squeeze_c, 1)
        self.fc2 = nn.Conv2d(squeeze_c, input_c, 1)

    def forward(self, x: Tensor) -> Tensor:
        scale = F.adaptive_avg_pool2d(x, output_size=(1, 1))
        scale = self.fc1(scale)
        scale = F.relu(scale, inplace=True)
        scale = self.fc2(scale)
        scale = F.hardsigmoid(scale, inplace=True)
        return scale * x


class InvertedResidualConfig:
    def __init__(self,
                 input_c: int,
                 kernel: int,
                 expanded_c: int,
                 out_c: int,
                 use_se: bool,
                 activation: str,
                 stride: int,
                 width_multi: float):
        self.input_c = self.adjust_channels(input_c, width_multi)
        self.kernel = kernel
        self.expanded_c = self.adjust_channels(expanded_c, width_multi)
        self.out_c = self.adjust_channels(out_c, width_multi)
        self.use_se = use_se
        self.use_hs = activation == "HS"  # whether using h-swish activation
        self.stride = stride

    @staticmethod
    def adjust_channels(channels: int, width_multi: float):
        return _make_divisible(channels * width_multi, 8)


class InvertedResidual(nn.Module):
    def __init__(self,
                 cnf: InvertedResidualConfig,
                 norm_layer: Callable[..., nn.Module]):
        super(InvertedResidual, self).__init__()

        if cnf.stride not in [1, 2]:
            raise ValueError("illegal stride value.")

        self.use_res_connect = (cnf.stride == 1 and cnf.input_c == cnf.out_c)

        layers: List[nn.Module] = []
        activation_layer = nn.Hardswish if cnf.use_hs else nn.ReLU

        # expand
        if cnf.expanded_c != cnf.input_c:
            layers.append(ConvBNActivation(cnf.input_c,
                                           cnf.expanded_c,
                                           kernel_size=1,
                                           norm_layer=norm_layer,
                                           activation_layer=activation_layer))

        # depthwise
        layers.append(ConvBNActivation(cnf.expanded_c,
                                       cnf.expanded_c,
                                       kernel_size=cnf.kernel,
                                       stride=cnf.stride,
                                       groups=cnf.expanded_c,
                                       norm_layer=norm_layer,
                                       activation_layer=activation_layer))

        if cnf.use_se:
            layers.append(SqueezeExcitation(cnf.expanded_c))

        # project
        layers.append(ConvBNActivation(cnf.expanded_c,
                                       cnf.out_c,
                                       kernel_size=1,
                                       norm_layer=norm_layer,
                                       activation_layer=nn.Identity))

        self.block = nn.Sequential(*layers)
        self.out_channels = cnf.out_c
        self.is_strided = cnf.stride > 1

    def forward(self, x: Tensor) -> Tensor:
        result = self.block(x)
        if self.use_res_connect:
            result += x

        return result


class MobileNetV3(nn.Module):
    def __init__(self,
                 inverted_residual_setting: List[InvertedResidualConfig],
                 last_channel: int,
                 num_classes: int = 1000,
                 block: Optional[Callable[..., nn.Module]] = None,
                 norm_layer: Optional[Callable[..., nn.Module]] = None):
        super(MobileNetV3, self).__init__()

        if not inverted_residual_setting:
            raise ValueError("The inverted_residual_setting should not be empty.")
        elif not (isinstance(inverted_residual_setting, List) and
                  all([isinstance(s, InvertedResidualConfig) for s in inverted_residual_setting])):
            raise TypeError("The inverted_residual_setting should be List[InvertedResidualConfig]")

        if block is None:
            block = InvertedResidual

        if norm_layer is None:
            norm_layer = partial(nn.BatchNorm2d, eps=0.001, momentum=0.01)

        layers: List[nn.Module] = []

        # building first layer
        firstconv_output_c = inverted_residual_setting[0].input_c
        layers.append(ConvBNActivation(3,
                                       firstconv_output_c,
                                       kernel_size=3,
                                       stride=2,
                                       norm_layer=norm_layer,
                                       activation_layer=nn.Hardswish))
        # building inverted residual blocks
        for cnf in inverted_residual_setting:
            layers.append(block(cnf, norm_layer))

        # building last several layers
        lastconv_input_c = inverted_residual_setting[-1].out_c
        lastconv_output_c = 6 * lastconv_input_c
        layers.append(ConvBNActivation(lastconv_input_c,
                                       lastconv_output_c,
                                       kernel_size=1,
                                       norm_layer=norm_layer,
                                       activation_layer=nn.Hardswish))
        self.features = nn.Sequential(*layers)
        self.avgpool = nn.AdaptiveAvgPool2d(1)
        self.classifier = nn.Sequential(nn.Linear(lastconv_output_c, last_channel),
                                        nn.Hardswish(inplace=True),
                                        nn.Dropout(p=0.2, inplace=True),
                                        nn.Linear(last_channel, num_classes))

        # initial weights
        for m in self.modules():
            if isinstance(m, nn.Conv2d):
                nn.init.kaiming_normal_(m.weight, mode="fan_out")
                if m.bias is not None:
                    nn.init.zeros_(m.bias)
            elif isinstance(m, (nn.BatchNorm2d, nn.GroupNorm)):
                nn.init.ones_(m.weight)
                nn.init.zeros_(m.bias)
            elif isinstance(m, nn.Linear):
                nn.init.normal_(m.weight, 0, 0.01)
                nn.init.zeros_(m.bias)

    def _forward_impl(self, x: Tensor) -> Tensor:
        x = self.features(x)
        x = self.avgpool(x)
        x = torch.flatten(x, 1)
        x = self.classifier(x)

        return x

    def forward(self, x: Tensor) -> Tensor:
        return self._forward_impl(x)


def mobilenet_v3_large(num_classes: int = 1000,
                       reduced_tail: bool = False) -> MobileNetV3:
    """
    Constructs a large MobileNetV3 architecture from
    "Searching for MobileNetV3" <https://arxiv.org/abs/1905.02244>.

    weights_link:
    https://download.pytorch.org/models/mobilenet_v3_large-8738ca79.pth

    Args:
        num_classes (int): number of classes
        reduced_tail (bool): If True, reduces the channel counts of all feature layers
            between C4 and C5 by 2. It is used to reduce the channel redundancy in the
            backbone for Detection and Segmentation.
    """
    width_multi = 1.0
    bneck_conf = partial(InvertedResidualConfig, width_multi=width_multi)
    adjust_channels = partial(InvertedResidualConfig.adjust_channels, width_multi=width_multi)

    reduce_divider = 2 if reduced_tail else 1

    inverted_residual_setting = [
        # input_c, kernel, expanded_c, out_c, use_se, activation, stride
        bneck_conf(16, 3, 16, 16, False, "RE", 1),
        bneck_conf(16, 3, 64, 24, False, "RE", 2),  # C1
        bneck_conf(24, 3, 72, 24, False, "RE", 1),
        bneck_conf(24, 5, 72, 40, True, "RE", 2),  # C2
        bneck_conf(40, 5, 120, 40, True, "RE", 1),
        bneck_conf(40, 5, 120, 40, True, "RE", 1),
        bneck_conf(40, 3, 240, 80, False, "HS", 2),  # C3
        bneck_conf(80, 3, 200, 80, False, "HS", 1),
        bneck_conf(80, 3, 184, 80, False, "HS", 1),
        bneck_conf(80, 3, 184, 80, False, "HS", 1),
        bneck_conf(80, 3, 480, 112, True, "HS", 1),
        bneck_conf(112, 3, 672, 112, True, "HS", 1),
        bneck_conf(112, 5, 672, 160 // reduce_divider, True, "HS", 2),  # C4
        bneck_conf(160 // reduce_divider, 5, 960 // reduce_divider, 160 // reduce_divider, True, "HS", 1),
        bneck_conf(160 // reduce_divider, 5, 960 // reduce_divider, 160 // reduce_divider, True, "HS", 1),
    ]
    last_channel = adjust_channels(1280 // reduce_divider)  # C5

    return MobileNetV3(inverted_residual_setting=inverted_residual_setting,
                       last_channel=last_channel,
                       num_classes=num_classes)


def mobilenet_v3_small(num_classes: int = 1000,
                       reduced_tail: bool = False) -> MobileNetV3:
    """
    Constructs a large MobileNetV3 architecture from
    "Searching for MobileNetV3" <https://arxiv.org/abs/1905.02244>.

    weights_link:
    https://download.pytorch.org/models/mobilenet_v3_small-047dcff4.pth

    Args:
        num_classes (int): number of classes
        reduced_tail (bool): If True, reduces the channel counts of all feature layers
            between C4 and C5 by 2. It is used to reduce the channel redundancy in the
            backbone for Detection and Segmentation.
    """
    width_multi = 1.0
    bneck_conf = partial(InvertedResidualConfig, width_multi=width_multi)
    adjust_channels = partial(InvertedResidualConfig.adjust_channels, width_multi=width_multi)

    reduce_divider = 2 if reduced_tail else 1

    inverted_residual_setting = [
        # input_c, kernel, expanded_c, out_c, use_se, activation, stride
        bneck_conf(16, 3, 16, 16, True, "RE", 2),  # C1
        bneck_conf(16, 3, 72, 24, False, "RE", 2),  # C2
        bneck_conf(24, 3, 88, 24, False, "RE", 1),
        bneck_conf(24, 5, 96, 40, True, "HS", 2),  # C3
        bneck_conf(40, 5, 240, 40, True, "HS", 1),
        bneck_conf(40, 5, 240, 40, True, "HS", 1),
        bneck_conf(40, 5, 120, 48, True, "HS", 1),
        bneck_conf(48, 5, 144, 48, True, "HS", 1),
        bneck_conf(48, 5, 288, 96 // reduce_divider, True, "HS", 2),  # C4
        bneck_conf(96 // reduce_divider, 5, 576 // reduce_divider, 96 // reduce_divider, True, "HS", 1),
        bneck_conf(96 // reduce_divider, 5, 576 // reduce_divider, 96 // reduce_divider, True, "HS", 1)
    ]
    last_channel = adjust_channels(1024 // reduce_divider)  # C5

    return MobileNetV3(inverted_residual_setting=inverted_residual_setting,
                       last_channel=last_channel,
                       num_classes=num_classes)


================================================
FILE: deploying_service/deploying_pytorch/convert_openvino/convert_resnet34/quantization_int8.py
================================================
from addict import Dict
from compression.engines.ie_engine import IEEngine
from compression.graph import load_model, save_model
from compression.graph.model_utils import compress_model_weights
from compression.pipeline.initializer import create_pipeline
from utils import MyDataLoader, Accuracy, read_split_data


def main():
    data_path = "/data/flower_photos"
    ir_model_xml = "ir_output/resnet34.xml"
    ir_model_bin = "ir_output/resnet34.bin"
    save_dir = "quant_ir_output"
    model_name = "quantized_resnet34"
    img_w = 224
    img_h = 224

    model_config = Dict({
        'model_name': 'resnet34',
        'model': ir_model_xml,
        'weights': ir_model_bin
    })
    engine_config = Dict({
        'device': 'CPU',
        'stat_requests_number': 2,
        'eval_requests_number': 2
    })
    dataset_config = {
        'data_source': data_path
    }
    algorithms = [
        {
            'name': 'DefaultQuantization',
            'params': {
                'target_device': 'CPU',
                'preset': 'performance',
                'stat_subset_size': 300
            }
        }
    ]

    # Steps 1-7: Model optimization
    # Step 1: Load the model.
    model = load_model(model_config)

    # Step 2: Initialize the data loader.
    _, _, val_images_path, val_images_label = read_split_data(data_path, val_rate=0.2)
    data_loader = MyDataLoader(dataset_config, val_images_path, val_images_label, img_w, img_h)

    # Step 3 (Optional. Required for AccuracyAwareQuantization): Initialize the metric.
    metric = Accuracy(top_k=1)

    # Step 4: Initialize the engine for metric calculation and statistics collection.
    engine = IEEngine(engine_config, data_loader, metric)

    # Step 5: Create a pipeline of compression algorithms.
    pipeline = create_pipeline(algorithms, engine)

    # Step 6: Execute the pipeline.
    compressed_model = pipeline.run(model)

    # Step 7 (Optional): Compress model weights quantized precision
    #                    in order to reduce the size of final .bin file.
    compress_model_weights(compressed_model)

    # Step 8: Save the compressed model to the desired path.
    compressed_model_paths = save_model(model=compressed_model,
                                        save_path=save_dir,
                                        model_name=model_name)

    # Step 9: Compare accuracy of the original and quantized models.
    metric_results = pipeline.evaluate(model)
    if metric_results:
        for name, value in metric_results.items():
            print(f"Accuracy of the original model: {name}: {value}")

    metric_results = pipeline.evaluate(compressed_model)
    if metric_results:
        for name, value in metric_results.items():
            print(f"Accuracy of the optimized model: {name}: {value}")


if __name__ == '__main__':
    main()


================================================
FILE: deploying_service/deploying_pytorch/convert_openvino/convert_resnet34/requirements.txt
================================================
torch==1.11.0
torchvision==0.12.0
onnx==1.13.0
onnxruntime==1.8.0
protobuf==3.19.5
openvino-dev==2022.1.0
matplotlib

================================================
FILE: deploying_service/deploying_pytorch/convert_openvino/convert_resnet34/utils.py
================================================
import os
import json
import random

from PIL import Image
import numpy as np
from compression.api import DataLoader, Metric
from torchvision.transforms import transforms


def read_split_data(root: str, val_rate: float = 0.2):
    random.seed(0)  # 保证随机结果可复现
    assert os.path.exists(root), "dataset root: {} does not exist.".format(root)

    # 遍历文件夹,一个文件夹对应一个类别
    flower_class = [cla for cla in os.listdir(root) if os.path.isdir(os.path.join(root, cla))]
    # 排序,保证顺序一致
    flower_class.sort()
    # 生成类别名称以及对应的数字索引
    class_indices = dict((k, v) for v, k in enumerate(flower_class))
    json_str = json.dumps(dict((val, key) for key, val in class_indices.items()), indent=4)
    with open('class_indices.json', 'w') as json_file:
        json_file.write(json_str)

    train_images_path = []  # 存储训练集的所有图片路径
    train_images_label = []  # 存储训练集图片对应索引信息
    val_images_path = []  # 存储验证集的所有图片路径
    val_images_label = []  # 存储验证集图片对应索引信息
    every_class_num = []  # 存储每个类别的样本总数
    supported = [".jpg", ".JPG", ".png", ".PNG"]  # 支持的文件后缀类型
    # 遍历每个文件夹下的文件
    for cla in flower_class:
        cla_path = os.path.join(root, cla)
        # 遍历获取supported支持的所有文件路径
        images = [os.path.join(root, cla, i) for i in os.listdir(cla_path)
                  if os.path.splitext(i)[-1] in supported]
        # 获取该类别对应的索引
        image_class = class_indices[cla]
        # 记录该类别的样本数量
        every_class_num.append(len(images))
        # 按比例随机采样验证样本
        val_path = random.sample(images, k=int(len(images) * val_rate))

        for img_path in images:
            if img_path in val_path:  # 如果该路径在采样的验证集样本中则存入验证集
                val_images_path.append(img_path)
                val_images_label.append(image_class)
            else:  # 否则存入训练集
                train_images_path.append(img_path)
                train_images_label.append(image_class)

    print("{} images were found in the dataset.".format(sum(every_class_num)))
    print("{} images for training.".format(len(train_images_path)))
    print("{} images for validation.".format(len(val_images_path)))

    return train_images_path, train_images_label, val_images_path, val_images_label


# Custom implementation of classification accuracy metric.
class Accuracy(Metric):
    # Required methods
    def __init__(self, top_k=1):
        super().__init__()
        self._top_k = top_k
        self._name = 'accuracy@top{}'.format(self._top_k)
        self._matches = []

    @property
    def value(self):
        """ Returns accuracy metric value for the last model output. """
        return {self._name: self._matches[-1]}

    @property
    def avg_value(self):
        """ Returns accuracy metric value for all model outputs. """
        return {self._name: np.ravel(self._matches).mean()}

    def update(self, output, target):
        """ Updates prediction matches.
        :param output: model output
        :param target: annotations
        """
        if len(output) > 1:
            raise Exception('The accuracy metric cannot be calculated '
                            'for a model with multiple outputs')
        if isinstance(target, dict):
            target = list(target.values())
        predictions = np.argsort(output[0], axis=1)[:, -self._top_k:]
        match = [float(t in predictions[i]) for i, t in enumerate(target)]

        self._matches.append(match)

    def reset(self):
        """ Resets collected matches """
        self._matches = []

    def get_attributes(self):
        """
        Returns a dictionary of metric attributes {metric_name: {attribute_name: value}}.
        Required attributes: 'direction': 'higher-better' or 'higher-worse'
                             'type': metric type
        """
        return {self._name: {'direction': 'higher-better',
                             'type': 'accuracy'}}


class MyDataLoader(DataLoader):
    def __init__(self, cfg, images_path: list, images_label: list, img_w: int = 224, img_h: int = 224):
        super().__init__(cfg)
        self.images_path = images_path
        self.images_label = images_label
        self.image_w = img_w
        self.image_h = img_h
        self.transforms = transforms.Compose([
            transforms.Resize(min(img_h, img_w)),
            transforms.CenterCrop((img_h, img_w))
        ])

    def __len__(self):
        return len(self.images_label)

    def __getitem__(self, index):
        """
        Return one sample of index, label and picture.
        :param index: index of the taken sample.
        """
        if index >= len(self):
            raise IndexError

        img = Image.open(self.images_path[index])
        img = self.transforms(img)

        # Convert the resized images to network input shape
        # [h, w, c] -> [c, h, w] -> [1, c, h, w]
        img = np.expand_dims(np.transpose(np.array(img), (2, 0, 1)), 0)

        return (index, self.images_label[index]), img


================================================
FILE: deploying_service/deploying_pytorch/convert_openvino/convert_yolov5/README.md
================================================
OpenVINO量化YOLOv5

1. 按照`requirements.txt`配置环境
2. 将YOLOv5转为ONNX
YOLOv5官方有提供导出ONNX以及OpenVINO的方法,但我这里仅导出成ONNX,这里以YOLOv5s为例
```
python export.py --weights yolov5s.pt --include onnx
```

3. ONNX转换为IR
使用OpenVINO的`mo`工具将ONNX转为OpenVINO的IR格式
```
mo  --input_model yolov5s.onnx \
    --input_shape "[1,3,640,640]" \
    --scale 255 \
    --data_type FP32 \
    --output_dir ir_output
```

4. 量化模型
使用`quantization_int8.py`进行模型的量化,量化过程中需要使用到COCO2017数据集,需要将`data_path`指向coco2017目录
```
├── coco2017: 数据集根目录
     ├── train2017: 所有训练图像文件夹(118287张)
     ├── val2017: 所有验证图像文件夹(5000张)
     └── annotations: 对应标注文件夹
              ├── instances_train2017.json: 对应目标检测、分割任务的训练集标注文件
              ├── instances_val2017.json: 对应目标检测、分割任务的验证集标注文件
              ├── captions_train2017.json: 对应图像描述的训练集标注文件
              ├── captions_val2017.json: 对应图像描述的验证集标注文件
              ├── person_keypoints_train2017.json: 对应人体关键点检测的训练集标注文件
              └── person_keypoints_val2017.json: 对应人体关键点检测的验证集标注文件夹
```

5. benchmark
直接利用`benchmark_app`工具测试量化前后的`Throughput`,这里以`CPU: Intel(R) Core(TM) i7-6700 CPU @ 3.40GHz`设备为例
```
benchmark_app -m ir_output/yolov5s.xml -d CPU -api sync
```
output:
```
Latency:
    Median:     59.56 ms
    AVG:        63.30 ms
    MIN:        57.88 ms
    MAX:        99.89 ms
Throughput: 16.79 FPS
```

```
benchmark_app -m quant_ir_output/quantized_yolov5s.xml -d CPU -api sync
```
output:
```
Latency:
    Median:     42.97 ms
    AVG:        46.56 ms
    MIN:        41.18 ms
    MAX:        95.75 ms
Throughput: 23.27 FPS
```

================================================
FILE: deploying_service/deploying_pytorch/convert_openvino/convert_yolov5/compare_fps.py
================================================
import time
import numpy as np
import torch
import onnxruntime
import matplotlib.pyplot as plt
from openvino.runtime import Core


def normalize(image: np.ndarray) -> np.ndarray:
    """
    Normalize the image to the given mean and standard deviation
    """
    image = image.astype(np.float32)
    image /= 255.0
    return image


def onnx_inference(onnx_path: str, image: np.ndarray, num_images: int = 20):
    # load onnx model
    ort_session = onnxruntime.InferenceSession(onnx_path)

    # compute onnx Runtime output prediction
    ort_inputs = {ort_session.get_inputs()[0].name: image}

    start = time.perf_counter()
    for _ in range(num_images):
        ort_session.run(None, ort_inputs)
    end = time.perf_counter()
    time_onnx = end - start
    print(
        f"ONNX model in Inference Engine/CPU: {time_onnx / num_images:.3f} "
        f"seconds per image, FPS: {num_images / time_onnx:.2f}"
    )

    return num_images / time_onnx


def ir_inference(ir_path: str, image: np.ndarray, num_images: int = 20):
    # Load the network in Inference Engine
    ie = Core()
    model_ir = ie.read_model(model=ir_path)
    compiled_model_ir = ie.compile_model(model=model_ir, device_name="CPU")

    # Get input and output layers
    input_layer_ir = next(iter(compiled_model_ir.inputs))
    output_layer_ir = next(iter(compiled_model_ir.outputs))

    start = time.perf_counter()
    request_ir = compiled_model_ir.create_infer_request()
    for _ in range(num_images):
        request_ir.infer(inputs={input_layer_ir.any_name: image})
    end = time.perf_counter()
    time_ir = end - start
    print(
        f"IR model in Inference Engine/CPU: {time_ir / num_images:.3f} "
        f"seconds per image, FPS: {num_images / time_ir:.2f}"
    )

    return num_images / time_ir


def pytorch_inference(image: np.ndarray, num_images: int = 20):
    image = torch.as_tensor(image, dtype=torch.float32)

    model = torch.hub.load('ultralytics/yolov5', 'yolov5s')
    model.eval()

    with torch.no_grad():
        start = time.perf_counter()
        for _ in range(num_images):
            model(image)
        end = time.perf_counter()
        time_torch = end - start

    print(
        f"PyTorch model on CPU: {time_torch / num_images:.3f} seconds per image, "
        f"FPS: {num_images / time_torch:.2f}"
    )

    return num_images / time_torch


def plot_fps(v: dict):
    x = list(v.keys())
    y = list(v.values())

    plt.bar(range(len(x)), y, align='center')
    plt.xticks(range(len(x)), x)
    for i, v in enumerate(y):
        plt.text(x=i, y=v+0.5, s=f"{v:.2f}", ha='center')
    plt.xlabel('model format')
    plt.ylabel('fps')
    plt.title('FPS comparison')
    plt.show()
    plt.savefig('fps_vs.jpg')


def main():
    image_h = 640
    image_w = 640
    onnx_path = "yolov5s.onnx"
    ir_path = "ir_output/yolov5s.xml"

    image = np.random.randn(image_h, image_w, 3)
    normalized_image = normalize(image)

    # Convert the resized images to network input shape
    # [h, w, c] -> [c, h, w] -> [1, c, h, w]
    input_image = np.expand_dims(np.transpose(image, (2, 0, 1)), 0)
    normalized_input_image = np.expand_dims(np.transpose(normalized_image, (2, 0, 1)), 0)

    onnx_fps = onnx_inference(onnx_path, normalized_input_image, num_images=100)
    ir_fps = ir_inference(ir_path, input_image, num_images=100)
    pytorch_fps = pytorch_inference(normalized_input_image, num_images=100)
    plot_fps({"pytorch": round(pytorch_fps, 2),
              "onnx": round(onnx_fps, 2),
              "ir": round(ir_fps, 2)})


if __name__ == '__main__':
    main()


================================================
FILE: deploying_service/deploying_pytorch/convert_openvino/convert_yolov5/compare_onnx_and_ir.py
================================================
import numpy as np
import onnxruntime
from openvino.runtime import Core


def normalize(image: np.ndarray) -> np.ndarray:
    """
    Normalize the image to the given mean and standard deviation
    """
    image = image.astype(np.float32)
    image /= 255.0
    return image


def onnx_inference(onnx_path: str, image: np.ndarray):
    # load onnx model
    ort_session = onnxruntime.InferenceSession(onnx_path)

    # compute onnx Runtime output prediction
    ort_inputs = {ort_session.get_inputs()[0].name: image}
    res_onnx = ort_session.run(None, ort_inputs)[0]
    return res_onnx


def ir_inference(ir_path: str, image: np.ndarray):
    # Load the network in Inference Engine
    ie = Core()
    model_ir = ie.read_model(model=ir_path)
    compiled_model_ir = ie.compile_model(model=model_ir, device_name="CPU")

    # Get input and output layers
    input_layer_ir = next(iter(compiled_model_ir.inputs))
    output_layer_ir = next(iter(compiled_model_ir.outputs))

    # Run inference on the input image
    res_ir = compiled_model_ir([image])[output_layer_ir]
    return res_ir


def main():
    image_h = 640
    image_w = 640
    onnx_path = "yolov5s.onnx"
    ir_path = "ir_output/yolov5s.xml"

    image = np.random.randn(image_h, image_w, 3)
    normalized_image = normalize(image)

    # Convert the resized images to network input shape
    # [h, w, c] -> [c, h, w] -> [1, c, h, w]
    input_image = np.expand_dims(np.transpose(image, (2, 0, 1)), 0)
    normalized_input_image = np.expand_dims(np.transpose(normalized_image, (2, 0, 1)), 0)

    onnx_res = onnx_inference(onnx_path, normalized_input_image)
    ir_res = ir_inference(ir_path, input_image)
    np.testing.assert_allclose(onnx_res, ir_res, rtol=1e-03, atol=1e-05)
    print("Exported model has been tested with OpenvinoRuntime, and the result looks good!")


if __name__ == '__main__':
    main()


================================================
FILE: deploying_service/deploying_pytorch/convert_openvino/convert_yolov5/draw_box_utils.py
================================================
from PIL.Image import Image, fromarray
import PIL.ImageDraw as ImageDraw
import PIL.ImageFont as ImageFont
from PIL import ImageColor
import numpy as np

STANDARD_COLORS = [
    'AliceBlue', 'Chartreuse', 'Aqua', 'Aquamarine', 'Azure', 'Beige', 'Bisque',
    'BlanchedAlmond', 'BlueViolet', 'BurlyWood', 'CadetBlue', 'AntiqueWhite',
    'Chocolate', 'Coral', 'CornflowerBlue', 'Cornsilk', 'Crimson', 'Cyan',
    'DarkCyan', 'DarkGoldenRod', 'DarkGrey', 'DarkKhaki', 'DarkOrange',
    'DarkOrchid', 'DarkSalmon', 'DarkSeaGreen', 'DarkTurquoise', 'DarkViolet',
    'DeepPink', 'DeepSkyBlue', 'DodgerBlue', 'FireBrick', 'FloralWhite',
    'ForestGreen', 'Fuchsia', 'Gainsboro', 'GhostWhite', 'Gold', 'GoldenRod',
    'Salmon', 'Tan', 'HoneyDew', 'HotPink', 'IndianRed', 'Ivory', 'Khaki',
    'Lavender', 'LavenderBlush', 'LawnGreen', 'LemonChiffon', 'LightBlue',
    'LightCoral', 'LightCyan', 'LightGoldenRodYellow', 'LightGray', 'LightGrey',
    'LightGreen', 'LightPink', 'LightSalmon', 'LightSeaGreen', 'LightSkyBlue',
    'LightSlateGray', 'LightSlateGrey', 'LightSteelBlue', 'LightYellow', 'Lime',
    'LimeGreen', 'Linen', 'Magenta', 'MediumAquaMarine', 'MediumOrchid',
    'MediumPurple', 'MediumSeaGreen', 'MediumSlateBlue', 'MediumSpringGreen',
    'MediumTurquoise', 'MediumVioletRed', 'MintCream', 'MistyRose', 'Moccasin',
    'NavajoWhite', 'OldLace', 'Olive', 'OliveDrab', 'Orange', 'OrangeRed',
    'Orchid', 'PaleGoldenRod', 'PaleGreen', 'PaleTurquoise', 'PaleVioletRed',
    'PapayaWhip', 'PeachPuff', 'Peru', 'Pink', 'Plum', 'PowderBlue', 'Purple',
    'Red', 'RosyBrown', 'RoyalBlue', 'SaddleBrown', 'Green', 'SandyBrown',
    'SeaGreen', 'SeaShell', 'Sienna', 'Silver', 'SkyBlue', 'SlateBlue',
    'SlateGray', 'SlateGrey', 'Snow', 'SpringGreen', 'SteelBlue', 'GreenYellow',
    'Teal', 'Thistle', 'Tomato', 'Turquoise', 'Violet', 'Wheat', 'White',
    'WhiteSmoke', 'Yellow', 'YellowGreen'
]


def draw_text(draw,
              box: list,
              cls: int,
              score: float,
              category_index: dict,
              color: str,
              font: str = 'arial.ttf',
              font_size: int = 24):
    """
    将目标边界框和类别信息绘制到图片上
    """
    try:
        font = ImageFont.truetype(font, font_size)
    except IOError:
        font = ImageFont.load_default()

    left, top, right, bottom = box
    # If the total height of the display strings added to the top of the bounding
    # box exceeds the top of the image, stack the strings below the bounding box
    # instead of above.
    display_str = f"{category_index[str(cls)]}: {int(100 * score)}%"
    display_str_heights = [font.getsize(ds)[1] for ds in display_str]
    # Each display_str has a top and bottom margin of 0.05x.
    display_str_height = (1 + 2 * 0.05) * max(display_str_heights)

    if top > display_str_height:
        text_top = top - display_str_height
        text_bottom = top
    else:
        text_top = bottom
        text_bottom = bottom + display_str_height

    for ds in display_str:
        text_width, text_height = font.getsize(ds)
        margin = np.ceil(0.05 * text_width)
        draw.rectangle([(left, text_top),
                        (left + text_width + 2 * margin, text_bottom)], fill=color)
        draw.text((left + margin, text_top),
                  ds,
                  fill='black',
                  font=font)
        left += text_width


def draw_masks(image, masks, colors, thresh: float = 0.7, alpha: float = 0.5):
    np_image = np.array(image)
    masks = np.where(masks > thresh, True, False)

    # colors = np.array(colors)
    img_to_draw = np.copy(np_image)
    # TODO: There might be a way to vectorize this
    for mask, color in zip(masks, colors):
        img_to_draw[mask] = color

    out = np_image * (1 - alpha) + img_to_draw * alpha
    return fromarray(out.astype(np.uint8))


def draw_objs(image: Image,
              boxes: np.ndarray = None,
              classes: np.ndarray = None,
              scores: np.ndarray = None,
              masks: np.ndarray = None,
              category_index: dict = None,
              box_thresh: float = 0.1,
              mask_thresh: float = 0.5,
              line_thickness: int = 8,
              font: str = 'arial.ttf',
              font_size: int = 24,
              draw_boxes_on_image: bool = True,
              draw_masks_on_image: bool = False):
    """
    将目标边界框信息,类别信息,mask信息绘制在图片上
    Args:
        image: 需要绘制的图片
        boxes: 目标边界框信息
        classes: 目标类别信息
        scores: 目标概率信息
        masks: 目标mask信息
        category_index: 类别与名称字典
        box_thresh: 过滤的概率阈值
        mask_thresh:
        line_thickness: 边界框宽度
        font: 字体类型
        font_size: 字体大小
        draw_boxes_on_image:
        draw_masks_on_image:

    Returns:

    """

    # 过滤掉低概率的目标
    idxs = np.greater(scores, box_thresh)
    boxes = boxes[idxs]
    classes = classes[idxs]
    scores = scores[idxs]
    if masks is not None:
        masks = masks[idxs]
    if len(boxes) == 0:
        return image

    colors = [ImageColor.getrgb(STANDARD_COLORS[cls % len(STANDARD_COLORS)]) for cls in classes]

    if draw_boxes_on_image:
        # Draw all boxes onto image.
        draw = ImageDraw.Draw(image)
        for box, cls, score, color in zip(boxes, classes, scores, colors):
            left, top, right, bottom = box
            # 绘制目标边界框
            draw.line([(left, top), (left, bottom), (right, bottom),
                       (right, top), (left, top)], width=line_thickness, fill=color)
            # 绘制类别和概率信息
            draw_text(draw, box.tolist(), int(cls), float(score), category_index, color, font, font_size)

    if draw_masks_on_image and (masks is not None):
        # Draw all mask onto image.
        image = draw_masks(image, masks, colors, mask_thresh)

    return image


================================================
FILE: deploying_service/deploying_pytorch/convert_openvino/convert_yolov5/evaluation.py
================================================
from tqdm import tqdm
import torch
from openvino.runtime import Core
from utils import MyDataLoader, EvalCOCOMetric, non_max_suppression


def main():
    data_path = "/data/coco2017"
    ir_model_xml = "quant_ir_output/quantized_yolov5s.xml"
    img_size = (640, 640)  # h, w

    data_loader = MyDataLoader(data_path, "val", size=img_size)
    coco80_to_91 = data_loader.coco_id80_to_id91
    metrics = EvalCOCOMetric(coco=data_loader.coco, classes_mapping=coco80_to_91)

    # Load the network in Inference Engine
    ie = Core()
    model_ir = ie.read_model(model=ir_model_xml)
    compiled_model = ie.compile_model(model=model_ir, device_name="CPU")
    inputs_names = compiled_model.inputs
    outputs_names = compiled_model.outputs

    # inference
    request = compiled_model.create_infer_request()
    for i in tqdm(range(len(data_loader))):
        data = data_loader[i]
        ann, img, info = data
        ann = ann + (info,)

        request.infer(inputs={inputs_names[0]: img})
        result = request.get_output_tensor(outputs_names[0].index).data

        # post-process
        result = non_max_suppression(torch.Tensor(result), conf_thres=0.001, iou_thres=0.6, multi_label=True)[0]
        boxes = result[:, :4].numpy()
        scores = result[:, 4].numpy()
        cls = result[:, 5].numpy().astype(int)
        metrics.update(ann, [boxes, cls, scores])

    metrics.evaluate()


if __name__ == '__main__':
    main()


================================================
FILE: deploying_service/deploying_pytorch/convert_openvino/convert_yolov5/predict.py
================================================
import cv2
import numpy as np
import torch
from PIL import Image
import matplotlib.pyplot as plt
from openvino.runtime import Core
from utils import letterbox, scale_coords, non_max_suppression, coco80_names
from draw_box_utils import draw_objs


def main():
    img_path = "test.jpg"
    ir_model_xml = "ir_output/yolov5s.xml"
    img_size = (640, 640)  # h, w

    origin_img = cv2.cvtColor(cv2.imread(img_path), cv2.COLOR_BGR2RGB)
    reshape_img, ratio, pad = letterbox(origin_img, img_size, auto=False)
    input_img = np.expand_dims(np.transpose(reshape_img, [2, 0, 1]), 0).astype(np.float32)

    # Load the network in Inference Engine
    ie = Core()
    model_ir = ie.read_model(model=ir_model_xml)
    compiled_model = ie.compile_model(model=model_ir, device_name="CPU")
    inputs_names = compiled_model.inputs
    outputs_names = compiled_model.outputs

    # inference
    request = compiled_model.create_infer_request()
    request.infer(inputs={inputs_names[0]: input_img})
    result = request.get_output_tensor(outputs_names[0].index).data

    # post-process
    result = non_max_suppression(torch.Tensor(result))[0]
    boxes = result[:, :4].numpy()
    scores = result[:, 4].numpy()
    cls = result[:, 5].numpy().astype(int)
    boxes = scale_coords(reshape_img.shape, boxes, origin_img.shape, (ratio, pad))

    draw_img = draw_objs(Image.fromarray(origin_img),
                         boxes,
                         cls,
                         scores,
                         category_index=dict([(str(i), v) for i, v in enumerate(coco80_names)]))
    plt.imshow(draw_img)
    plt.show()
    draw_img.save("predict.jpg")


if __name__ == '__main__':
    main()


================================================
FILE: deploying_service/deploying_pytorch/convert_openvino/convert_yolov5/quantization_int8.py
================================================
import time
from addict import Dict
from compression.engines.ie_engine import IEEngine
from compression.graph import load_model, save_model
from compression.graph.model_utils import compress_model_weights
from compression.pipeline.initializer import create_pipeline
from yaspin import yaspin
from utils import MyDataLoader, MAPMetric


def main():
    data_path = "/data/coco2017"
    ir_model_xml = "ir_output/yolov5s.xml"
    ir_model_bin = "ir_output/yolov5s.bin"
    save_dir = "quant_ir_output"
    model_name = "quantized_yolov5s"
    img_w = 640
    img_h = 640

    model_config = Dict({
        'model_name': 'yolov5s',
        'model': ir_model_xml,
        'weights': ir_model_bin,
        'inputs': 'images',
        'outputs': 'output'
    })
    engine_config = Dict({'device': 'CPU'})

    algorithms = [
        {
            'name': 'DefaultQuantization',
            'params': {
                'target_device': 'CPU',
                'preset': 'performance',
                'stat_subset_size': 300
            }
        }
    ]

    # Step 1: Load the model.
    model = load_model(model_config)

    # Step 2: Initialize the data loader.
    data_loader = MyDataLoader(data_path, "val", (img_h, img_w))

    # Step 3: initialize the metric
    # For DefaultQuantization, specifying a metric is optional: metric can be set to None
    metric = MAPMetric(map_value="map")

    # Step 4: Initialize the engine for metric calculation and statistics collection.
    engine = IEEngine(config=engine_config, data_loader=data_loader, metric=metric)

    # Step 5: Create a pipeline of compression algorithms.
    pipeline = create_pipeline(algorithms, engine)

    # Step 6: Execute the pipeline to quantize the model
    algorithm_name = pipeline.algo_seq[0].name
    with yaspin(
            text=f"Executing POT pipeline on {model_config['model']} with {algorithm_name}"
    ) as sp:
        start_time = time.perf_counter()
        compressed_model = pipeline.run(model)
        end_time = time.perf_counter()
        sp.ok("✔")
    print(f"Quantization finished in {end_time - start_time:.2f} seconds")

    # Step 7 (Optional): Compress model weights to quantized precision
    #                    in order to reduce the size of the final .bin file
    compress_model_weights(compressed_model)

    # Step 8: Save the compressed model to the desired path.
    # Set save_path to the directory where the compressed model should be stored
    compressed_model_paths = save_model(
        model=compressed_model,
        save_path=save_dir,
        model_name=model_name,
    )

    compressed_model_path = compressed_model_paths[0]["model"]
    print("The quantized model is stored at", compressed_model_path)

    # Compute the mAP on the quantized model and compare with the mAP on the FP16 IR model.
    ir_model = load_model(model_config=model_config)
    evaluation_pipeline = create_pipeline(algo_config=dict(), engine=engine)

    with yaspin(text="Evaluating original IR model") as sp:
        original_metric = evaluation_pipeline.evaluate(ir_model)

    if original_metric:
        for key, value in original_metric.items():
            print(f"The {key} score of the original model is {value:.5f}")

    with yaspin(text="Evaluating quantized IR model") as sp:
        quantized_metric = pipeline.evaluate(compressed_model)

    if quantized_metric:
        for key, value in quantized_metric.items():
            print(f"The {key} score of the quantized INT8 model is {value:.5f}")


if __name__ == '__main__':
    main()


================================================
FILE: deploying_service/deploying_pytorch/convert_openvino/convert_yolov5/requirements.txt
================================================
torch==1.13.1
torchvision==0.12.0
onnx==1.13.0
onnxruntime==1.8.0
protobuf==3.19.5
openvino-dev==2022.1.0
matplotlib
torchmetrics==0.9.1

================================================
FILE: deploying_service/deploying_pytorch/convert_openvino/convert_yolov5/utils.py
================================================
import os
import time
import json
import copy

import cv2
import numpy as np
import torch
from torchmetrics.detection.mean_ap import MeanAveragePrecision
import torchvision
from pycocotools.coco import COCO
from pycocotools.cocoeval import COCOeval
from compression.api import DataLoader, Metric


coco80_names = ['person', 'bicycle', 'car', 'motorcycle', 'airplane', 'bus', 'train', 'truck', 'boat', 'traffic light',
                'fire hydrant', 'stop sign', 'parking meter', 'bench', 'bird', 'cat', 'dog', 'horse', 'sheep', 'cow',
                'elephant', 'bear', 'zebra', 'giraffe', 'backpack', 'umbrella', 'handbag', 'tie', 'suitcase', 'frisbee',
                'skis', 'snowboard', 'sports ball', 'kite', 'baseball bat', 'baseball glove', 'skateboard', 'surfboard',
                'tennis racket', 'bottle', 'wine glass', 'cup', 'fork', 'knife', 'spoon', 'bowl', 'banana', 'apple',
                'sandwich', 'orange', 'broccoli', 'carrot', 'hot dog', 'pizza', 'donut', 'cake', 'chair', 'couch',
                'potted plant', 'bed', 'dining table', 'toilet', 'tv', 'laptop', 'mouse', 'remote', 'keyboard',
                'cell phone', 'microwave', 'oven', 'toaster', 'sink', 'refrigerator', 'book', 'clock', 'vase',
                'scissors', 'teddy bear', 'hair drier', 'toothbrush']


def box_iou(box1, box2):
    # https://github.com/pytorch/vision/blob/master/torchvision/ops/boxes.py
    """
    Return intersection-over-union (Jaccard index) of boxes.
    Both sets of boxes are expected to be in (x1, y1, x2, y2) format.
    Arguments:
        box1 (Tensor[N, 4])
        box2 (Tensor[M, 4])
    Returns:
        iou (Tensor[N, M]): the NxM matrix containing the pairwise
            IoU values for every element in boxes1 and boxes2
    """

    def box_area(box):
        # box = 4xn
        return (box[2] - box[0]) * (box[3] - box[1])

    area1 = box_area(box1.T)
    area2 = box_area(box2.T)

    # inter(N,M) = (rb(N,M,2) - lt(N,M,2)).clamp(0).prod(2)
    inter = (torch.min(box1[:, None, 2:], box2[:, 2:]) - torch.max(box1[:, None, :2], box2[:, :2])).clamp(0).prod(2)
    return inter / (area1[:, None] + area2 - inter)  # iou = inter / (area1 + area2 - inter)


def xywh2xyxy(x):
    # Convert nx4 boxes from [x, y, w, h] to [x1, y1, x2, y2] where xy1=top-left, xy2=bottom-right
    y = x.clone() if isinstance(x, torch.Tensor) else np.copy(x)
    y[:, 0] = x[:, 0] - x[:, 2] / 2  # top left x
    y[:, 1] = x[:, 1] - x[:, 3] / 2  # top left y
    y[:, 2] = x[:, 0] + x[:, 2] / 2  # bottom right x
    y[:, 3] = x[:, 1] + x[:, 3] / 2  # bottom right y
    return y


def non_max_suppression(prediction, conf_thres=0.25, iou_thres=0.45, classes=None, agnostic=False, multi_label=False,
                        labels=(), max_det=300):
    """Runs Non-Maximum Suppression (NMS) on inference results

    Returns:
         list of detections, on (n,6) tensor per image [xyxy, conf, cls]
    """

    nc = prediction.shape[2] - 5  # number of classes
    xc = prediction[..., 4] > conf_thres  # candidates

    # Checks
    assert 0 <= conf_thres <= 1, f'Invalid Confidence threshold {conf_thres}, valid values are between 0.0 and 1.0'
    assert 0 <= iou_thres <= 1, f'Invalid IoU {iou_thres}, valid values are between 0.0 and 1.0'

    # Settings
    min_wh, max_wh = 2, 7680  # (pixels) minimum and maximum box width and height
    max_nms = 30000  # maximum number of boxes into torchvision.ops.nms()
    time_limit = 10.0  # seconds to quit after
    redundant = True  # require redundant detections
    multi_label &= nc > 1  # multiple labels per box (adds 0.5ms/img)
    merge = False  # use merge-NMS

    t = time.time()
    output = [torch.zeros((0, 6), device=prediction.device)] * prediction.shape[0]
    for xi, x in enumerate(prediction):  # image index, image inference
        # Apply constraints
        x[((x[..., 2:4] < min_wh) | (x[..., 2:4] > max_wh)).any(1), 4] = 0  # width-height
        x = x[xc[xi]]  # confidence

        # Cat apriori labels if autolabelling
        if labels and len(labels[xi]):
            lb = labels[xi]
            v = torch.zeros((len(lb), nc + 5), device=x.device)
            v[:, :4] = lb[:, 1:5]  # box
            v[:, 4] = 1.0  # conf
            v[range(len(lb)), lb[:, 0].long() + 5] = 1.0  # cls
            x = torch.cat((x, v), 0)

        # If none remain process next image
        if not x.shape[0]:
            continue

        # Compute conf
        x[:, 5:] *= x[:, 4:5]  # conf = obj_conf * cls_conf

        # Box (center x, center y, width, height) to (x1, y1, x2, y2)
        box = xywh2xyxy(x[:, :4])

        # Detections matrix nx6 (xyxy, conf, cls)
        if multi_label:
            i, j = (x[:, 5:] > conf_thres).nonzero(as_tuple=False).T
            x = torch.cat((box[i], x[i, j + 5, None], j[:, None].float()), 1)
        else:  # best class only
            conf, j = x[:, 5:].max(1, keepdim=True)
            x = torch.cat((box, conf, j.float()), 1)[conf.view(-1) > conf_thres]

        # Filter by class
        if classes is not None:
            x = x[(x[:, 5:6] == torch.tensor(classes, device=x.device)).any(1)]

        # Apply finite constraint
        # if not torch.isfinite(x).all():
        #     x = x[torch.isfinite(x).all(1)]

        # Check shape
        n = x.shape[0]  # number of boxes
        if not n:  # no boxes
            continue
        elif n > max_nms:  # excess boxes
            x = x[x[:, 4].argsort(descending=True)[:max_nms]]  # sort by confidence

        # Batched NMS
        c = x[:, 5:6] * (0 if agnostic else max_wh)  # classes
        boxes, scores = x[:, :4] + c, x[:, 4]  # boxes (offset by class), scores
        i = torchvision.ops.nms(boxes, scores, iou_thres)  # NMS
        if i.shape[0] > max_det:  # limit detections
            i = i[:max_det]
        if merge and (1 < n < 3E3):  # Merge NMS (boxes merged using weighted mean)
            # update boxes as boxes(i,4) = weights(i,n) * boxes(n,4)
            iou = box_iou(boxes[i], boxes) > iou_thres  # iou matrix
            weights = iou * scores[None]  # box weights
            x[i, :4] = torch.mm(weights, x[:, :4]).float() / weights.sum(1, keepdim=True)  # merged boxes
            if redundant:
                i = i[iou.sum(1) > 1]  # require redundancy

        output[xi] = x[i]
        if (time.time() - t) > time_limit:
            print(f'WARNING: NMS time limit {time_limit}s exceeded')
            break  # time limit exceeded

    return output


class MAPMetric(Metric):
    def __init__(self, map_value="map", conf_thres=0.001, iou_thres=0.6):
        """
        Mean Average Precision Metric. Wraps torchmetrics implementation, see
        https://torchmetrics.readthedocs.io/en/stable/detection/mean_average_precision.html

        :map_value: specific metric to return. Default: "map"
                    Change `to one of the values in the list below to return a different value
                    ['mar_1', 'mar_10', 'mar_100', 'mar_small', 'mar_medium', 'mar_large',
                     'map', 'map_50', 'map_75', 'map_small', 'map_medium', 'map_large']
                    See torchmetrics documentation for more details.
        """

        self._name = map_value
        self.metric = MeanAveragePrecision(box_format="xyxy")
        self.conf_thres = conf_thres
        self.iou_thres = iou_thres
        super().__init__()

    @property
    def value(self):
        """
        Returns metric value for the last model output.
        Possible format: {metric_name: [metric_values_per_image]}
        """
        return {self._name: [0]}

    @property
    def avg_value(self):
        """
        Returns average metric value for all model outputs.
        Possible format: {metric_name: metric_value}
        """
        return {self._name: self.metric.compute()[self._name].item()}

    def update(self, output, target):
        """
        Convert network output and labels to the format that torchmetrics' MAP
        implementation expects, and call `metric.update()`.

        :param output: model output
        :param target: annotations for model output
        """
        targetboxes = []
        targetlabels = []
        predboxes = []
        predlabels = []
        scores = []

        for single_target in target[0]:
            txmin, tymin, txmax, tymax = single_target["bbox"]
            category = single_target["category_id"]

            targetbox = [round(txmin), round(tymin), round(txmax), round(tymax)]
            targetboxes.append(targetbox)
            targetlabels.append(category)

        output = torch.Tensor(output[0]).float()
        output = non_max_suppression(output, conf_thres=self.conf_thres, iou_thres=self.iou_thres, multi_label=True)
        for single_output in output:
            for pred in single_output.numpy():
                xmin, ymin, xmax, ymax, conf, label = pred

                predbox = [round(xmin), round(ymin), round(xmax), round(ymax)]
                predboxes.append(predbox)
                predlabels.append(label)
                scores.append(conf)

        preds = [
            dict(
                boxes=torch.Tensor(predboxes).float(),
                labels=torch.Tensor(predlabels).short(),
                scores=torch.Tensor(scores),
            )
        ]
        targets = [
            dict(
                boxes=torch.Tensor(targetboxes).float(),
                labels=torch.Tensor(targetlabels).short(),
            )
        ]
        self.metric.update(preds, targets)

    def reset(self):
        """
        Resets metric
        """
        self.metric.reset()

    def get_attributes(self):
        """
        Returns a dictionary of metric attributes {metric_name: {attribute_name: value}}.
        Required attributes: 'direction': 'higher-better' or 'higher-worse'
                             'type': metric type
        """
        return {self._name: {"direction": "higher-better", "type": "mAP"}}


def _coco_remove_images_without_annotations(dataset, ids):
    """
    删除coco数据集中没有目标,或者目标面积非常小的数据
    refer to:
    https://github.com/pytorch/vision/blob/master/references/detection/coco_utils.py
    :param dataset:
    :param cat_list:
    :return:
    """
    def _has_only_empty_bbox(anno):
        return all(any(o <= 1 for o in obj["bbox"][2:]) for obj in anno)

    def _has_valid_annotation(anno):
        # if it's empty, there is no annotation
        if len(anno) == 0:
            return False
        # if all boxes have close to zero area, there is no annotation
        if _has_only_empty_bbox(anno):
            return False

        return True

    valid_ids = []
    for ds_idx, img_id in enumerate(ids):
        ann_ids = dataset.getAnnIds(imgIds=img_id, iscrowd=None)
        anno = dataset.loadAnns(ann_ids)

        if _has_valid_annotation(anno):
            valid_ids.append(img_id)

    return valid_ids


def scale_coords(img1_shape, coords, img0_shape, ratio_pad=None):
    # Rescale coords (xyxy) from img1_shape to img0_shape
    if ratio_pad is None:  # calculate from img0_shape
        gain = min(img1_shape[0] / img0_shape[0], img1_shape[1] / img0_shape[1])  # gain  = old / new
        pad = (img1_shape[1] - img0_shape[1] * gain) / 2, (img1_shape[0] - img0_shape[0] * gain) / 2  # wh padding
    else:
        assert ratio_pad[0][0] == ratio_pad[0][1]
        gain = ratio_pad[0][0]
        pad = ratio_pad[1]

    coords[:, [0, 2]] -= pad[0]  # x padding
    coords[:, [1, 3]] -= pad[1]  # y padding
    coords[:, :4] /= gain
    clip_coords(coords, img0_shape)
    return coords


def clip_coords(boxes, shape):
    # Clip bounding xyxy bounding boxes to image shape (height, width)
    if isinstance(boxes, torch.Tensor):  # faster individually
        boxes[:, 0].clamp_(0, shape[1])  # x1
        boxes[:, 1].clamp_(0, shape[0])  # y1
        boxes[:, 2].clamp_(0, shape[1])  # x2
        boxes[:, 3].clamp_(0, shape[0])  # y2
    else:  # np.array (faster grouped)
        boxes[:, [0, 2]] = boxes[:, [0, 2]].clip(0, shape[1])  # x1, x2
        boxes[:, [1, 3]] = boxes[:, [1, 3]].clip(0, shape[0])  # y1, y2


def letterbox(im, new_shape=(640, 640), color=(114, 114, 114), auto=True, scaleFill=False, scaleup=True, stride=32):
    # Resize and pad image while meeting stride-multiple constraints
    shape = im.shape[:2]  # current shape [height, width]
    if isinstance(new_shape, int):
        new_shape = (new_shape, new_shape)

    # Scale ratio (new / old)
    r = min(new_shape[0] / shape[0], new_shape[1] / shape[1])
    if not scaleup:  # only scale down, do not scale up (for better val mAP)
        r = min(r, 1.0)

    # Compute padding
    ratio = r, r  # width, height ratios
    new_unpad = int(round(shape[1] * r)), int(round(shape[0] * r))
    dw, dh = new_shape[1] - new_unpad[0], new_shape[0] - new_unpad[1]  # wh padding
    if auto:  # minimum rectangle
        dw, dh = np.mod(dw, stride), np.mod(dh, stride)  # wh padding
    elif scaleFill:  # stretch
        dw, dh = 0.0, 0.0
        new_unpad = (new_shape[1], new_shape[0])
        ratio = new_shape[1] / shape[1], new_shape[0] / shape[0]  # width, height ratios

    dw /= 2  # divide padding into 2 sides
    dh /= 2

    if shape[::-1] != new_unpad:  # resize
        im = cv2.resize(im, new_unpad, interpolation=cv2.INTER_LINEAR)
    top, bottom = int(round(dh - 0.1)), int(round(dh + 0.1))
    left, right = int(round(dw - 0.1)), int(round(dw + 0.1))
    im = cv2.copyMakeBorder(im, top, bottom, left, right, cv2.BORDER_CONSTANT, value=color)  # add border
    return im, ratio, (left, top)


class MyDataLoader(DataLoader):
    """`MS Coco Detection <https://cocodataset.org/>`_ Dataset.

    Args:
        root (string): Root directory where images are downloaded to.
        dataset (string): "train" or "val.
        size (tuple): (h, w)
    """
    def __init__(self, root, dataset="train", size=(640, 640)):
        assert dataset in ["train", "val"], 'dataset must be in ["train", "val"]'
        anno_file = "instances_{}2017.json".format(dataset)
        assert os.path.exists(root), "file '{}' does not exist.".format(root)
        self.img_root = os.path.join(root, "{}2017".format(dataset))
        assert os.path.exists(self.img_root), "path '{}' does not exist.".format(self.img_root)
        self.anno_path = os.path.join(root, "annotations", anno_file)
        assert os.path.exists(self.anno_path), "file '{}' does not exist.".format(self.anno_path)

        self.mode = dataset
        self.size = size
        self.coco = COCO(self.anno_path)

        self.coco91_id2classes = dict([(v["id"], v["name"]) for k, v in self.coco.cats.items()])
        coco90_classes2id = dict([(v["name"], v["id"]) for k, v in self.coco.cats.items()])

        self.coco80_classes = coco80_names
        self.coco_id80_to_id91 = dict([(i, coco90_classes2id[k]) for i, k in enumerate(coco80_names)])

        ids = list(sorted(self.coco.imgs.keys()))

        # 移除没有目标,或者目标面积非常小的数据
        valid_ids = _coco_remove_images_without_annotations(self.coco, ids)
        self.ids = valid_ids

    def parse_targets(self,
                      coco_targets: list,
                      w: int = None,
                      h: int = None,
                      ratio: tuple = None,
                      pad: tuple = None):
        assert w > 0
        assert h > 0

        # 只筛选出单个对象的情况
        anno = [obj for obj in coco_targets if obj['iscrowd'] == 0]

        boxes = [obj["bbox"] for obj in anno]

        # guard against no boxes via resizing
        boxes = np.array(boxes, dtype=np.float32).reshape(-1, 4)
        # [xmin, ymin, w, h] -> [xmin, ymin, xmax, ymax]
        boxes[:, 2:] += boxes[:, :2]
        boxes[:, 0::2] = np.clip(boxes[:, 0::2], a_min=0, a_max=w)
        boxes[:, 1::2] = np.clip(boxes[:, 1::2], a_min=0, a_max=h)

        classes = [self.coco80_classes.index(self.coco91_id2classes[obj["category_id"]])
                   for obj in anno]
        classes = np.array(classes, dtype=int)

        # 筛选出合法的目标,即x_max>x_min且y_max>y_min
        keep = (boxes[:, 3] > boxes[:, 1]) & (boxes[:, 2] > boxes[:, 0])
        boxes = boxes[keep]
        classes = classes[keep]

        if ratio is not None:
            # width, height ratios
            boxes[:, 0::2] *= ratio[0]
            boxes[:, 1::2] *= ratio[1]

        if pad is not None:
            # dw, dh padding
            dw, dh = pad
            boxes[:, 0::2] += dw
            boxes[:, 1::2] += dh

        target_annotations = []
        for i in range(boxes.shape[0]):
            target_annotation = {
                "category_id": int(classes[i]),
                "bbox": boxes[i].tolist()
            }
            target_annotations.append(target_annotation)

        return target_annotations

    def __getitem__(self, index):
        """
        Get an item from the dataset at the specified index.
        Detection boxes are converted from absolute coordinates to relative coordinates
        between 0 and 1 by dividing xmin, xmax by image width and ymin, ymax by image height.

        :return: (annotation, input_image, metadata) where annotation is (index, target_annotation)
                 with target_annotation as a dictionary with keys category_id, image_width, image_height
                 and bbox, containing the relative bounding box coordinates [xmin, ymin, xmax, ymax]
                 (with values between 0 and 1) and metadata a dictionary: {"filename": path_to_image}
        """
        coco = self.coco
        img_id = self.ids[index]
        ann_ids = coco.getAnnIds(imgIds=img_id)
        coco_target = coco.loadAnns(ann_ids)

        image_path = coco.loadImgs(img_id)[0]['file_name']
        img = cv2.imread(os.path.join(self.img_root, image_path))

        origin_h, origin_w, c = img.shape
        image, ratio, pad = letterbox(img, auto=False, new_shape=self.size)
        target_annotations = self.parse_targets(coco_target, origin_w, origin_h, ratio, pad)

        item_annotation = (index, target_annotations)
        input_image = np.expand_dims(image.transpose(2, 0, 1), axis=0).astype(
            np.float32
        )
        return (
            item_annotation,
            input_image,
            {"filename": str(image_path),
             "origin_shape": img.shape,
             "shape": image.shape,
             "img_id": img_id,
             "ratio_pad": [ratio, pad]},
        )

    def __len__(self):
        return len(self.ids)

    @staticmethod
    def collate_fn(x):
        return x


class EvalCOCOMetric:
    def __init__(self,
                 coco: COCO = None,
                 iou_type: str = "bbox",
                 results_file_name: str = "predict_results.json",
                 classes_mapping: dict = None):
        self.coco = copy.deepcopy(coco)
        self.results = []
        self.classes_mapping = classes_mapping
        self.coco_evaluator = None
        assert iou_type in ["bbox"]
        self.iou_type = iou_type
        self.results_file_name = results_file_name

    def prepare_for_coco_detection(self, ann, output):
        """将预测的结果转换成COCOeval指定的格式,针对目标检测任务"""
        # 遍历每张图像的预测结果
        if len(output[0]) == 0:
            return

        img_id = ann[2]["img_id"]
        per_image_boxes = output[0]
        per_image_boxes = scale_coords(img1_shape=ann[2]["shape"],
                                       coords=per_image_boxes,
                                       img0_shape=ann[2]["origin_shape"],
                                       ratio_pad=ann[2]["ratio_pad"])
        # 对于coco_eval, 需要的每个box的数据格式为[x_min, y_min, w, h]
        # 而我们预测的box格式是[x_min, y_min, x_max, y_max],所以需要转下格式
        per_image_boxes[:, 2:] -= per_image_boxes[:, :2]
        per_image_classes = output[1].tolist()
        per_image_scores = output[2].tolist()

        # 遍历每个目标的信息
        for object_score, object_class, object_box in zip(
                per_image_scores, per_image_classes, per_image_boxes):
            object_score = float(object_score)
            class_idx = int(object_class)
            if self.classes_mapping is not None:
                class_idx = self.classes_mapping[class_idx]
            # We recommend rounding coordinates to the nearest tenth of a pixel
            # to reduce resulting JSON file size.
            object_box = [round(b, 2) for b in object_box.tolist()]

            res = {"image_id": img_id,
                   "category_id": class_idx,
                   "bbox": object_box,
                   "score": round(object_score, 3)}
            self.results.append(res)

    def update(self, targets, outputs):
        if self.iou_type == "bbox":
            self.prepare_for_coco_detection(targets, outputs)
        else:
            raise KeyError(f"not support iou_type: {self.iou_type}")

    def evaluate(self):
        # write predict results into json file
        json_str = json.dumps(self.results, indent=4)
        with open(self.results_file_name, 'w') as json_file:
            json_file.write(json_str)

        # accumulate predictions from all images
        coco_true = self.coco
        coco_pre = coco_true.loadRes(self.results_file_name)

        self.coco_evaluator = COCOeval(cocoGt=coco_true, cocoDt=coco_pre, iouType=self.iou_type)

        self.coco_evaluator.evaluate()
        self.coco_evaluator.accumulate()
        print(f"IoU metric: {self.iou_type}")
        self.coco_evaluator.summarize()

        coco_info = self.coco_evaluator.stats.tolist()  # numpy to list
        return coco_info



================================================
FILE: deploying_service/deploying_pytorch/convert_tensorrt/convert_resnet34/compare_onnx_and_trt.py
================================================
import numpy as np
import tensorrt as trt
import onnxruntime
import pycuda.driver as cuda
import pycuda.autoinit


def normalize(image: np.ndarray) -> np.ndarray:
    """
    Normalize the image to the given mean and standard deviation
    """
    image = image.astype(np.float32)
    mean = (0.485, 0.456, 0.406)
    std = (0.229, 0.224, 0.225)
    image /= 255.0
    image -= mean
    image /= std
    return image


def onnx_inference(onnx_path: str, image: np.ndarray):
    # load onnx model
    ort_session = onnxruntime.InferenceSession(onnx_path)

    # compute onnx Runtime output prediction
    ort_inputs = {ort_session.get_inputs()[0].name: image}
    res_onnx = ort_session.run(None, ort_inputs)[0]
    return res_onnx


def trt_inference(trt_path: str, image: np.ndarray):
    # Load the network in Inference Engine
    trt_logger = trt.Logger(trt.Logger.WARNING)
    with open(trt_path, "rb") as f, trt.Runtime(trt_logger) as runtime:
        engine = runtime.deserialize_cuda_engine(f.read())

    with engine.create_execution_context() as context:
        # Set input shape based on image dimensions for inference
        context.set_binding_shape(engine.get_binding_index("input"), (1, 3, image.shape[-2], image.shape[-1]))
        # Allocate host and device buffers
        bindings = []
        for binding in engine:
            binding_idx = engine.get_binding_index(binding)
            size = trt.volume(context.get_binding_shape(binding_idx))
            dtype = trt.nptype(engine.get_binding_dtype(binding))
            if engine.binding_is_input(binding):
                input_buffer = np.ascontiguousarray(image)
                input_memory = cuda.mem_alloc(image.nbytes)
                bindings.append(int(input_memory))
            else:
                output_buffer = cuda.pagelocked_empty(size, dtype)
                output_memory = cuda.mem_alloc(output_buffer.nbytes)
                bindings.append(int(output_memory))

        stream = cuda.Stream()
        # Transfer input data to the GPU.
        cuda.memcpy_htod_async(input_memory, input_buffer, stream)
        # Run inference
        context.execute_async_v2(bindings=bindings, stream_handle=stream.handle)
        # Transfer prediction output from the GPU.
        cuda.memcpy_dtoh_async(output_buffer, output_memory, stream)
        # Synchronize the stream
        stream.synchronize()

        res_trt = np.reshape(output_buffer, (1, -1))

    return res_trt


def main():
    image_h = 224
    image_w = 224
    onnx_path = "resnet34.onnx"
    trt_path = "trt_output/resnet34.trt"

    image = np.random.randn(image_h, image_w, 3)
    normalized_image = normalize(image)

    # Convert the resized images to network input shape
    # [h, w, c] -> [c, h, w] -> [1, c, h, w]
    normalized_image = np.expand_dims(np.transpose(normalized_image, (2, 0, 1)), 0)

    onnx_res = onnx_inference(onnx_path, normalized_image)
    ir_res = trt_inference(trt_path, normalized_image)
    np.testing.assert_allclose(onnx_res, ir_res, rtol=1e-03, atol=1e-05)
    print("Exported model has been tested with TensorRT Runtime, and the result looks good!")


if __name__ == '__main__':
    main()


================================================
FILE: deploying_service/deploying_pytorch/convert_tensorrt/convert_resnet34/convert_pytorch2onnx.py
================================================
import torch
import torch.onnx
import onnx
import onnxruntime
import numpy as np
from torchvision.models import resnet34

device = torch.device("cpu")


def to_numpy(tensor):
    return tensor.detach().cpu().numpy() if tensor.requires_grad else tensor.cpu().numpy()


def main():
    weights_path = "resNet34(flower).pth"
    onnx_file_name = "resnet34.onnx"
    batch_size = 1
    img_h = 224
    img_w = 224
    img_channel = 3

    # create model and load pretrain weights
    model = resnet34(pretrained=False, num_classes=5)
    model.load_state_dict(torch.load(weights_path, map_location='cpu'))

    model.eval()
    # input to the model
    # [batch, channel, height, width]
    x = torch.rand(batch_size, img_channel, img_h, img_w, requires_grad=True)
    torch_out = model(x)

    # export the model
    torch.onnx.export(model,             # model being run
                      x,                 # model input (or a tuple for multiple inputs)
                      onnx_file_name,    # where to save the model (can be a file or file-like object)
                      input_names=["input"],
                      output_names=["output"],
                      verbose=False)

    # check onnx model
    onnx_model = onnx.load(onnx_file_name)
    onnx.checker.check_model(onnx_model)

    ort_session = onnxruntime.InferenceSession(onnx_file_name)

    # compute ONNX Runtime output prediction
    ort_inputs = {ort_session.get_inputs()[0].name: to_numpy(x)}
    ort_outs = ort_session.run(None, ort_inputs)

    # compare ONNX Runtime and Pytorch results
    # assert_allclose: Raises an AssertionError if two objects are not equal up to desired tolerance.
    np.testing.assert_allclose(to_numpy(torch_out), ort_outs[0], rtol=1e-03, atol=1e-05)
    print("Exported model has been tested with ONNXRuntime, and the result looks good!")


if __name__ == '__main__':
    main()


================================================
FILE: deploying_service/deploying_pytorch/convert_tensorrt/convert_resnet34/my_dataset.py
================================================
from PIL import Image
import torch
from torch.utils.data import Dataset


class MyDataSet(Dataset):
    """自定义数据集"""

    def __init__(self, images_path: list, images_class: list, transform=None):
        self.images_path = images_path
        self.images_class = images_class
        self.transform = transform

    def __len__(self):
        return len(self.images_path)

    def __getitem__(self, item):
        img = Image.open(self.images_path[item])
        # RGB为彩色图片,L为灰度图片
        if img.mode != 'RGB':
            raise ValueError("image: {} isn't RGB mode.".format(self.images_path[item]))
        label = self.images_class[item]

        if self.transform is not None:
            img = self.transform(img)

        return img, label

    @staticmethod
    def collate_fn(batch):
        # 官方实现的default_collate可以参考
        # https://github.com/pytorch/pytorch/blob/67b7e751e6b5931a9f45274653f4f653a4e6cdf6/torch/utils/data/_utils/collate.py
        images, labels = tuple(zip(*batch))

        images = torch.stack(images, dim=0)
        labels = torch.as_tensor(labels)
        return images, labels


================================================
FILE: deploying_service/deploying_pytorch/convert_tensorrt/convert_resnet34/quantization.py
================================================
"""
refer to:
https://docs.nvidia.com/deeplearning/tensorrt/pytorch-quantization-toolkit/docs/userguide.html
"""
import os
import math
import argparse

from absl import logging
from tqdm import tqdm
import torch
import torch.optim as optim
import torch.optim.lr_scheduler as lr_scheduler
from torchvision import transforms
from torchvision.models.resnet import resnet34 as create_model
from pytorch_quantization import nn as quant_nn
from pytorch_quantization import quant_modules, calib
from pytorch_quantization.tensor_quant import QuantDescriptor

from my_dataset import MyDataSet
from utils import read_split_data, train_one_epoch, evaluate

logging.set_verbosity(logging.FATAL)


def export_onnx(model, onnx_filename, onnx_bs):
    model.eval()
    # We have to shift to pytorch's fake quant ops before exporting the model to ONNX
    quant_nn.TensorQuantizer.use_fb_fake_quant = True
    opset_version = 13

    print(f"Export ONNX file: {onnx_filename}")
    dummy_input = torch.randn(onnx_bs, 3, 224, 224).cuda()
    torch.onnx.export(model,
                      dummy_input,
                      onnx_filename,
                      verbose=False,
                      opset_version=opset_version,
                      enable_onnx_checker=False,
                      input_names=["input"],
                      output_names=["output"])


def collect_stats(model, data_loader, num_batches):
    """Feed data to the network and collect statistic"""

    # Enable calibrators
    for name, module in model.named_modules():
        if isinstance(module, quant_nn.TensorQuantizer):
            if module._calibrator is not None:
                module.disable_quant()
                module.enable_calib()
            else:
                module.disable()

    for i, (images, _) in tqdm(enumerate(data_loader), total=num_batches):
        model(images.cuda())
        if i >= num_batches:
            break

    # Disable calibrators
    for name, module in model.named_modules():
        if isinstance(module, quant_nn.TensorQuantizer):
            if module._calibrator is not None:
                module.enable_quant()
                module.disable_calib()
            else:
                module.enable()


def compute_amax(model, **kwargs):
    # Load calib result
    for name, module in model.named_modules():
        if isinstance(module, quant_nn.TensorQuantizer):
            if module._calibrator is not None:
                if isinstance(module._calibrator, calib.MaxCalibrator):
                    module.load_calib_amax()
                else:
                    module.load_calib_amax(**kwargs)
            print(f"{name:40}: {module}")
    model.cuda()


def main(args):
    quant_modules.initialize()
    assert torch.cuda.is_available(), "only support GPU!"

    train_images_path, train_images_label, val_images_path, val_images_label = read_split_data(args.data_path)

    data_transform = {
        "train": transforms.Compose([transforms.RandomResizedCrop(224),
                                     transforms.RandomHorizontalFlip(),
                                     transforms.ToTensor(),
                                     transforms.Normalize([0.5, 0.5, 0.5], [0.5, 0.5, 0.5])]),
        "val": transforms.Compose([transforms.Resize(256),
                                   transforms.CenterCrop(224),
                                   transforms.ToTensor(),
                                   transforms.Normalize([0.5, 0.5, 0.5], [0.5, 0.5, 0.5])])}

    # 实例化训练数据集
    train_dataset = MyDataSet(images_path=train_images_path,
                              images_class=train_images_label,
                              transform=data_transform["train"])

    # 实例化验证数据集
    val_dataset = MyDataSet(images_path=val_images_path,
                            images_class=val_images_label,
                            transform=data_transform["val"])

    batch_size = args.batch_size
    nw = min([os.cpu_count(), batch_size if batch_size > 1 else 0, 8])  # number of workers
    print('Using {} dataloader workers every process'.format(nw))
    train_loader = torch.utils.data.DataLoader(train_dataset,
                                               batch_size=batch_size,
                                               shuffle=True,
                                               pin_memory=True,
                                               num_workers=nw,
                                               collate_fn=train_dataset.collate_fn)

    val_loader = torch.utils.data.DataLoader(val_dataset,
                                             batch_size=batch_size,
                                             shuffle=False,
                                             pin_memory=True,
                                             num_workers=nw,
                                             collate_fn=val_dataset.collate_fn)

    # ########################## #
    # Post Training Quantization #
    # ########################## #
    # We will use histogram based calibration for activations and the default max calibration for weights.
    quant_desc_input = QuantDescriptor(calib_method='histogram')
    quant_nn.QuantConv2d.set_default_quant_desc_input(quant_desc_input)
    quant_nn.QuantLinear.set_default_quant_desc_input(quant_desc_input)

    model = create_model(num_classes=args.num_classes)
    assert os.path.exists(args.weights), "weights file: '{}' not exist.".format(args.weights)
    model.load_state_dict(torch.load(args.weights, map_location='cpu'))
    model.cuda()

    # It is a bit slow since we collect histograms on CPU
    with torch.no_grad():
        collect_stats(model, val_loader, num_batches=1000 // batch_size)
        compute_amax(model, method="percentile", percentile=99.99)
        # validate
        evaluate(model=model, data_loader=val_loader, epoch=0)

    torch.save(model.state_dict(), "quant_model_calibrated.pth")

    if args.qat:
        # ########################### #
        # Quantization Aware Training #
        # ########################### #
        pg = [p for p in model.parameters() if p.requires_grad]
        optimizer = optim.SGD(pg, lr=args.lr, momentum=0.9, weight_decay=5E-5)
        # Scheduler(half of a cosine period)
        lf = lambda x: (math.cos(x * math.pi / 2 / args.epochs)) * (1 - args.lrf) + args.lrf
        scheduler = lr_scheduler.LambdaLR(optimizer, lr_lambda=lf)

        for epoch in range(args.epochs):
            # train
            train_one_epoch(model=model, optimizer=optimizer, data_loader=train_loader, epoch=epoch)

            scheduler.step()

            # validate
            evaluate(model=model, data_loader=val_loader, epoch=epoch)

    export_onnx(model, args.onnx_filename, args.onnx_bs)


if __name__ == '__main__':
    parser = argparse.ArgumentParser()
    parser.add_argument('--num_classes', type=int, default=5)
    parser.add_argument('--epochs', type=int, default=5)
    parser.add_argument('--batch-size', type=int, default=8)
    parser.add_argument('--lr', type=float, default=0.0001)
    parser.add_argument('--lrf', type=float, default=0.01)

    # 数据集所在根目录
    # https://storage.googleapis.com/download.tensorflow.org/example_images/flower_photos.tgz
    parser.add_argument('--data-path', type=str,
                        default="/data/flower_photos")

    # 训练好的权重路径
    parser.add_argument('--weights', type=str, default='./resNet(flower).pth',
                        help='trained weights path')

    parser.add_argument('--device', default='cuda:0', help='device id (i.e. 0 or 0,1 or cpu)')

    parser.add_argument('--onnx-filename', default='resnet34.onnx', help='save onnx model filename')
    parser.add_argument('--onnx-bs', default=1, help='save onnx model batch size')
    parser.add_argument('--qat', type=bool, default=True, help='whether use quantization aware training')

    opt = parser.parse_args()

    main(opt)


================================================
FILE: deploying_service/deploying_pytorch/convert_tensorrt/convert_resnet34/utils.py
================================================
import os
import sys
import json
import pickle
import random

import torch
from tqdm import tqdm


def read_split_data(root: str, val_rate: float = 0.2):
    random.seed(0)  # 保证随机结果可复现
    assert os.path.exists(root), "dataset root: {} does not exist.".format(root)

    # 遍历文件夹,一个文件夹对应一个类别
    flower_class = [cla for cla in os.listdir(root) if os.path.isdir(os.path.join(root, cla))]
    # 排序,保证顺序一致
    flower_class.sort()
    # 生成类别名称以及对应的数字索引
    class_indices = dict((k, v) for v, k in enumerate(flower_class))
    json_str = json.dumps(dict((val, key) for key, val in class_indices.items()), indent=4)
    with open('class_indices.json', 'w') as json_file:
        json_file.write(json_str)

    train_images_path = []  # 存储训练集的所有图片路径
    train_images_label = []  # 存储训练集图片对应索引信息
    val_images_path = []  # 存储验证集的所有图片路径
    val_images_label = []  # 存储验证集图片对应索引信息
    every_class_num = []  # 存储每个类别的样本总数
    supported = [".jpg", ".JPG", ".png", ".PNG"]  # 支持的文件后缀类型
    # 遍历每个文件夹下的文件
    for cla in flower_class:
        cla_path = os.path.join(root, cla)
        # 遍历获取supported支持的所有文件路径
        images = [os.path.join(root, cla, i) for i in os.listdir(cla_path)
                  if os.path.splitext(i)[-1] in supported]
        # 获取该类别对应的索引
        image_class = class_indices[cla]
        # 记录该类别的样本数量
        every_class_num.append(len(images))
        # 按比例随机采样验证样本
        val_path = random.sample(images, k=int(len(images) * val_rate))

        for img_path in images:
            if img_path in val_path:  # 如果该路径在采样的验证集样本中则存入验证集
                val_images_path.append(img_path)
                val_images_label.append(image_class)
            else:  # 否则存入训练集
                train_images_path.append(img_path)
                train_images_label.append(image_class)

    print("{} images were found in the dataset.".format(sum(every_class_num)))
    print("{} images for training.".format(len(train_images_path)))
    print("{} images for validation.".format(len(val_images_path)))

    return train_images_path, train_images_label, val_images_path, val_images_label


def write_pickle(list_info: list, file_name: str):
    with open(file_name, 'wb') as f:
        pickle.dump(list_info, f)


def read_pickle(file_name: str) -> list:
    with open(file_name, 'rb') as f:
        info_list = pickle.load(f)
        return info_list


def train_one_epoch(model, optimizer, data_loader, epoch):
    model.train()
    loss_function = torch.nn.CrossEntropyLoss()
    accu_loss = torch.zeros(1).cuda()  # 累计损失
    accu_num = torch.zeros(1).cuda()   # 累计预测正确的样本数
    optimizer.zero_grad()

    sample_num = 0
    data_loader = tqdm(data_loader, file=sys.stdout)
    for step, data in enumerate(data_loader):
        images, labels = data
        sample_num += images.shape[0]

        pred = model(images.cuda())
        pred_classes = torch.max(pred, dim=1)[1]
        accu_num += torch.eq(pred_classes, labels.cuda()).sum()

        loss = loss_function(pred, labels.cuda())
        loss.backward()
        accu_loss += loss.detach()

        data_loader.desc = "[train epoch {}] loss: {:.3f}, acc: {:.3f}".format(epoch,
                                                                               accu_loss.item() / (step + 1),
                                                                               accu_num.item() / sample_num)

        if not torch.isfinite(loss):
            print('WARNING: non-finite loss, ending training ', loss)
            sys.exit(1)

        optimizer.step()
        optimizer.zero_grad()

    return accu_loss.item() / (step + 1), accu_num.item() / sample_num


@torch.no_grad()
def evaluate(model, data_loader, epoch):
    loss_function = torch.nn.CrossEntropyLoss()

    model.eval()

    accu_num = torch.zeros(1).cuda()   # 累计预测正确的样本数
    accu_loss = torch.zeros(1).cuda()  # 累计损失

    sample_num = 0
    data_loader = tqdm(data_loader, file=sys.stdout)
    for step, data in enumerate(data_loader):
        images, labels = data
        sample_num += images.shape[0]

        pred = model(images.cuda())
        pred_classes = torch.max(pred, dim=1)[1]
        accu_num += torch.eq(pred_classes, labels.cuda()).sum()

        loss = loss_function(pred, labels.cuda())
        accu_loss += loss

        data_loader.desc = "[valid epoch {}] loss: {:.3f}, acc: {:.3f}".format(epoch,
                                                                               accu_loss.item() / (step + 1),
                                                                               accu_num.item() / sample_num)

    return accu_loss.item() / (step + 1), accu_num.item() / sample_num


================================================
FILE: deploying_service/deploying_pytorch/pytorch_flask_service/class_indices.json
================================================
{
    "0": "daisy",
    "1": "dandelion",
    "2": "roses",
    "3": "sunflowers",
    "4": "tulips"
}

================================================
FILE: deploying_service/deploying_pytorch/pytorch_flask_service/main.py
================================================
import os
import io
import json
import torch
import torchvision.transforms as transforms
from PIL import Image
from flask import Flask, jsonify, request, render_template
from flask_cors import CORS
from model import MobileNetV2

app = Flask(__name__)
CORS(app)  # 解决跨域问题

weights_path = "./MobileNetV2(flower).pth"
class_json_path = "./class_indices.json"
assert os.path.exists(weights_path), "weights path does not exist..."
assert os.path.exists(class_json_path), "class json path does not exist..."

# select device
device = torch.device("cuda:0" if torch.cuda.is_available() else "cpu")
print(device)
# create model
model = MobileNetV2(num_classes=5).to(device)
# load model weights
model.load_state_dict(torch.load(weights_path, map_location=device))

model.eval()

# load class info
json_file = open(class_json_path, 'rb')
class_indict = json.load(json_file)


def transform_image(image_bytes):
    my_transforms = transforms.Compose([transforms.Resize(255),
                                        transforms.CenterCrop(224),
                                        transforms.ToTensor(),
                                        transforms.Normalize(
                                            [0.485, 0.456, 0.406],
                                            [0.229, 0.224, 0.225])])
    image = Image.open(io.BytesIO(image_bytes))
    if image.mode != "RGB":
        raise ValueError("input file does not RGB image...")
    return my_transforms(image).unsqueeze(0).to(device)


def get_prediction(image_bytes):
    try:
        tensor = transform_image(image_bytes=image_bytes)
        outputs = torch.softmax(model.forward(tensor).squeeze(), dim=0)
        prediction = outputs.detach().cpu().numpy()
        template = "class:{:<15} probability:{:.3f}"
        index_pre = [(class_indict[str(index)], float(p)) for index, p in enumerate(prediction)]
        # sort probability
        index_pre.sort(key=lambda x: x[1], reverse=True)
        text = [template.format(k, v) for k, v in index_pre]
        return_info = {"result": text}
    except Exception as e:
        return_info = {"result": [str(e)]}
    return return_info


@app.route("/predict", methods=["POST"])
@torch.no_grad()
def predict():
    image = request.files["file"]
    img_bytes = image.read()
    info = get_prediction(image_bytes=img_bytes)
    return jsonify(info)


@app.route("/", methods=["GET", "POST"])
def root():
    return render_template("up.html")


if __name__ == '__main__':
    app.run(host="0.0.0.0", port=5000)






================================================
FILE: deploying_service/deploying_pytorch/pytorch_flask_service/model.py
================================================
from torch import nn
import torch


def _make_divisible(ch, divisor=8, min_ch=None):
    """
    This function is taken from the original tf repo.
    It ensures that all layers have a channel number that is divisible by 8
    It can be seen here:
    https://github.com/tensorflow/models/blob/master/research/slim/nets/mobilenet/mobilenet.py
    """
    if min_ch is None:
        min_ch = divisor
    new_ch = max(min_ch, int(ch + divisor / 2) // divisor * divisor)
    # Make sure that round down does not go down by more than 10%.
    if new_ch < 0.9 * ch:
        new_ch += divisor
    return new_ch


class ConvBNReLU(nn.Sequential):
    def __init__(self, in_channel, out_channel, kernel_size=3, stride=1, groups=1):
        padding = (kernel_size - 1) // 2
        super(ConvBNReLU, self).__init__(
            nn.Conv2d(in_channel, out_channel, kernel_size, stride, padding, groups=groups, bias=False),
            nn.BatchNorm2d(out_channel),
            nn.ReLU6(inplace=True)
        )


class InvertedResidual(nn.Module):
    def __init__(self, in_channel, out_channel, stride, expand_ratio):
        super(InvertedResidual, self).__init__()
        hidden_channel = in_channel * expand_ratio
        self.use_shortcut = stride == 1 and in_channel == out_channel

        layers = []
        if expand_ratio != 1:
            # 1x1 pointwise conv
            layers.append(ConvBNReLU(in_channel, hidden_channel, kernel_size=1))
        layers.extend([
            # 3x3 depthwise conv
            ConvBNReLU(hidden_channel, hidden_channel, stride=stride, groups=hidden_channel),
            # 1x1 pointwise conv(linear)
            nn.Conv2d(hidden_channel, out_channel, kernel_size=1, bias=False),
            nn.BatchNorm2d(out_channel),
        ])

        self.conv = nn.Sequential(*layers)

    def forward(self, x):
        if self.use_shortcut:
            return x + self.conv(x)
        else:
            return self.conv(x)


class MobileNetV2(nn.Module):
    def __init__(self, num_classes=1000, alpha=1.0, round_nearest=8):
        super(MobileNetV2, self).__init__()
        block = InvertedResidual
        input_channel = _make_divisible(32 * alpha, round_nearest)
        last_channel = _make_divisible(1280 * alpha, round_nearest)

        inverted_residual_setting = [
            # t, c, n, s
            [1, 16, 1, 1],
            [6, 24, 2, 2],
            [6, 32, 3, 2],
            [6, 64, 4, 2],
            [6, 96, 3, 1],
            [6, 160, 3, 2],
            [6, 320, 1, 1],
        ]

        features = []
        # conv1 layer
        features.append(ConvBNReLU(3, input_channel, stride=2))
        # building inverted residual residual blockes
        for t, c, n, s in inverted_residual_setting:
            output_channel = _make_divisible(c * alpha, round_nearest)
            for i in range(n):
                stride = s if i == 0 else 1
                features.append(block(input_channel, output_channel, stride, expand_ratio=t))
                input_channel = output_channel
        # building last several layers
        features.append(ConvBNReLU(input_channel, last_channel, 1))
        # combine feature layers
        self.features = nn.Sequential(*features)

        # building classifier
        self.avgpool = nn.AdaptiveAvgPool2d((1, 1))
        self.classifier = nn.Sequential(
            nn.Dropout(0.2),
            nn.Linear(last_channel, num_classes)
        )

        # weight initialization
        for m in self.modules():
            if isinstance(m, nn.Conv2d):
                nn.init.kaiming_normal_(m.weight, mode='fan_out')
                if m.bias is not None:
                    nn.init.zeros_(m.bias)
            elif isinstance(m, nn.BatchNorm2d):
                nn.init.ones_(m.weight)
                nn.init.zeros_(m.bias)
            elif isinstance(m, nn.Linear):
                nn.init.normal_(m.weight, 0, 0.01)
                nn.init.zeros_(m.bias)

    def forward(self, x):
        x = self.features(x)
        x = self.avgpool(x)
        x = torch.flatten(x, 1)
        x = self.classifier(x)
        return x


================================================
FILE: deploying_service/deploying_pytorch/pytorch_flask_service/requirements.txt
================================================
Flask==2.2.5
Flask_Cors==3.0.9
Pillow


================================================
FILE: deploying_service/deploying_pytorch/pytorch_flask_service/templates/up.html
================================================
<!DOCTYPE html>
<html>
<head>
    <title>HTML5上传图片并预览</title>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <script src="{{ url_for('static', filename='js/jquery.min.js') }}"></script>
</head>
<body>
<!--<h3>请选择图片文件:PNG/JPG/JPEG/SVG/GIF</h3>-->
<div style="text-align: left;margin-left:500px;margin-top:100px;" >
    <div style="float:left;">
        <a href="javascript:;" class="file">选择文件
            <input type="file" name="file" id="file0"><br>
        </a>
        <img src="" id="img0" style="margin-top:20px;width: 35rem;height: 30rem;">
    </div>
    <div style="float:left;margin-left:50px;">
        <input type="button" id="b0" onclick="test()" value="预测">
        <pre  id="out" style="width:320px;height:50px;line-height: 50px;margin-top:20px;"></pre>
    </div>
</div>

<script type="text/javascript">
    $("#file0").change(function(){
        var objUrl = getObjectURL(this.files[0]) ;//获取文件信息
        console.log("objUrl = "+objUrl);
        if (objUrl) {
            $("#img0").attr("src", objUrl);
        }
    });

    function test() {
        var fileobj = $("#file0")[0].files[0];
        console.log(fileobj);
        var form = new FormData();
        form.append("file", fileobj);
        var out='';
        var flower='';
        $.ajax({
            type: 'POST',
            url: "predict",
            data: form,
            async: false,       //同步执行
            processData: false, // 告诉jquery要传输data对象
            contentType: false, //告诉jquery不需要增加请求头对于contentType的设置
            success: function (arg) {
            console.log(arg)
            out = arg.result;
        },error:function(){
                console.log("后台处理错误");
            }
    });

        out.forEach(e=>{
            flower+=`<div style="border-bottom: 1px solid #CCCCCC;line-height: 60px;font-size:16px;">${e}</div>`
        });

        document.getElementById("out").innerHTML=flower;

    }

    function getObjectURL(file) {
        var url = null;
        if(window.createObjectURL!=undefined) {
            url = window.createObjectURL(file) ;
        }else if (window.URL!=undefined) { // mozilla(firefox)
            url = window.URL.createObjectURL(file) ;
        }else if (window.webkitURL!=undefined) { // webkit or chrome
            url = window.webkitURL.createObjectURL(file) ;
        }
        return url ;
    }
</script>
<style>
    .file {
        position: relative;
        /*display: inline-block;*/
        background: #CCC ;
        border: 1px solid #CCC;
        padding: 4px 4px;
        overflow: hidden;
        text-decoration: none;
        text-indent: 0;
        width:100px;
        height:30px;
        line-height: 30px;
        border-radius: 5px;
        color: #333;
        font-size: 13px;

    }
    .file input {
        position: absolute;
        font-size: 13px;
        right: 0;
        top: 0;
        opacity: 0;
        border: 1px solid #333;
        padding: 4px 4px;
        overflow: hidden;
        text-indent: 0;
        width:100px;
        height:30px;
        line-height: 30px;
        border-radius: 5px;
        color: #FFFFFF;

    }
    #b0{
        background: #1899FF;
        border: 1px solid #CCC;
        padding: 4px 10px;
        overflow: hidden;
        text-indent: 0;
        width:60px;
        height:28px;
        line-height: 20px;
        border-radius: 5px;
        color: #FFFFFF;
        font-size: 13px;
    }

    /*.gradient{*/

        /*filter:alpha(opacity=100 finishopacity=50 style=1 startx=0,starty=0,finishx=0,finishy=150) progid:DXImageTransform.Microsoft.gradient(startcolorstr=#fff,endcolorstr=#ccc,gradientType=0);*/
        /*-ms-filter:alpha(opacity=100 finishopacity=50 style=1 startx=0,starty=0,finishx=0,finishy=150) progid:DXImageTransform.Microsoft.gradient(startcolorstr=#fff,endcolorstr=#ccc,gradientType=0);!*IE8*!*/
        /*background:#1899FF; !* 一些不支持背景渐变的浏览器 *!*/
        /*background:-moz-linear-gradient(top, #fff, #1899FF);*/
        /*background:-webkit-gradient(linear, 0 0, 0 bottom, from(#fff), to(#ccc));*/
        /*background:-o-linear-gradient(top, #fff, #ccc);*/
    /*}*/
</style>
</body>
</html>




================================================
FILE: deploying_service/pruning_model_pytorch/class_indices.json
================================================
{
    "0": "daisy",
    "1": "dandelion",
    "2": "roses",
    "3": "sunflowers",
    "4": "tulips"
}

================================================
FILE: deploying_service/pruning_model_pytorch/main.py
================================================
import os
import torch
from torchvision import transforms, datasets
import torch.nn.utils.prune as prune
import torch.nn.functional as F
from tqdm import tqdm
import time
from model import resnet34

device = torch.device("cuda:0" if torch.cuda.is_available() else "cpu")

data_transform = transforms.Compose([transforms.Resize(256),
                                     transforms.CenterCrop(224),
                                     transforms.ToTensor(),
                                     transforms.Normalize([0.485, 0.456, 0.406], [0.229, 0.224, 0.225])])

data_root = os.path.abspath(os.path.join(os.getcwd(), "../.."))  # get data root path
image_path = data_root + "/data_set/flower_data/"  # flower data set path
batch_size = 16


def validate_model(model: torch.nn.Module):
    validate_dataset = datasets.ImageFolder(root=image_path + "val",
                                            transform=data_transform)
    val_num = len(validate_dataset)
    validate_loader = torch.utils.data.DataLoader(validate_dataset,
                                                  batch_size=batch_size, shuffle=False,
                                                  num_workers=2)

    model.eval()
    acc = 0.0  # accumulate accurate number / epoch
    with torch.no_grad():
        t1 = time.time()
        for val_data in tqdm(validate_loader, desc="validate model accuracy."):
            val_images, val_labels = val_data
            outputs = model(val_images.to(device))  # eval model only have last output layer
            predict_y = torch.max(outputs, dim=1)[1]
            acc += torch.sum(torch.eq(predict_y, val_labels.to(device))).item()
        val_accurate = acc / val_num
        print('test_accuracy: %.3f, time:%.3f' % (val_accurate, time.time() - t1))

    return val_accurate


def count_sparsity(model: torch.nn.Module, p=True):
    sum_zeros_num = 0
    sum_weights_num = 0
    for name, module in model.named_modules():
        if isinstance(module, torch.nn.Conv2d):
            zeros_elements = torch.sum(torch.eq(module.weight, 0)).item()
            weights_elements = module.weight.numel()

            sum_zeros_num += zeros_elements
            sum_weights_num += weights_elements
            if p is True:
                print("Sparsity in {}.weights {:.2f}%".format(name, 100 * zeros_elements / weights_elements))
    print("Global sparsity: {:.2f}%".format(100 * sum_zeros_num / sum_weights_num))


def main():
    weights_path = "./resNet34.pth"
    model = resnet34(num_classes=5)
    model.load_state_dict(torch.load(weights_path, map_location=device))
    model.to(device)
    # validate_model(model)
    # module = model.conv1
    # print(list(module.named_parameters()))
    # # print(list(module.named_buffers()))
    #
    # # 裁剪50%的卷积核
    # prune.ln_structured(module, name="weight", amount=0.5, n=2, dim=0)
    # print(list(module.weight))
    # print(module.weight.shape)
    # # print(list(module.named_buffers()))
    #
    # prune.remove(module, "weight")
    # print(module.weight.shape)

    # 收集所有需要裁剪的卷积核
    parameters_to_prune = []
    for name, module in model.named_modules():
        if isinstance(module, torch.nn.Conv2d):
            parameters_to_prune.append((module, "weight"))

    # 对卷积核进行剪枝处理
    prune.global_unstructured(parameters_to_prune,
                              pruning_method=prune.L1Unstructured,
                              amount=0.5)

    # 统计剪枝比例
    count_sparsity(model, p=False)

    # 验证剪枝后的模型
    validate_model(model)
    # print(model)

    # for name, module in model.named_modules():
    #     if isinstance(module, torch.nn.Conv2d):
    #         prune.remove(module, "weight")
    # validate_model(model)

    # torch.save(model.state_dict(), "pruning_model.pth")


if __name__ == '__main__':
    main()


================================================
FILE: deploying_service/pruning_model_pytorch/model.py
================================================
import torch.nn as nn
import torch


class BasicBlock(nn.Module):
    expansion = 1

    def __init__(self, in_channel, out_channel, stride=1, downsample=None):
        super(BasicBlock, self).__init__()
        self.conv1 = nn.Conv2d(in_channels=in_channel, out_channels=out_channel,
                               kernel_size=3, stride=stride, padding=1, bias=False)
        self.bn1 = nn.BatchNorm2d(out_channel)
        self.relu = nn.ReLU()
        self.conv2 = nn.Conv2d(in_channels=out_channel, out_channels=out_channel,
                               kernel_size=3, stride=1, padding=1, bias=False)
        self.bn2 = nn.BatchNorm2d(out_channel)
        self.downsample = downsample

    def forward(self, x):
        identity = x
        if self.downsample is not None:
            identity = self.downsample(x)

        out = self.conv1(x)
        out = self.bn1(out)
        out = self.relu(out)

        out = self.conv2(out)
        out = self.bn2(out)

        out += identity
        out = self.relu(out)

        return out


class Bottleneck(nn.Module):
    expansion = 4

    def __init__(self, in_channel, out_channel, stride=1, downsample=None):
        super(Bottleneck, self).__init__()
        self.conv1 = nn.Conv2d(in_channels=in_channel, out_channels=out_channel,
                               kernel_size=1, stride=1, bias=False)  # squeeze channels
        self.bn1 = nn.BatchNorm2d(out_channel)
        # -----------------------------------------
        self.conv2 = nn.Conv2d(in_channels=out_channel, out_channels=out_channel,
                               kernel_size=3, stride=stride, bias=False, padding=1)
        self.bn2 = nn.BatchNorm2d(out_channel)
        # -----------------------------------------
        self.conv3 = nn.Conv2d(in_channels=out_channel, out_channels=out_channel*self.expansion,
                               kernel_size=1, stride=1, bias=False)  # unsqueeze channels
        self.bn3 = nn.BatchNorm2d(out_channel*self.expansion)
        self.relu = nn.ReLU(inplace=True)
        self.downsample = downsample

    def forward(self, x):
        identity = x
        if self.downsample is not None:
            identity = self.downsample(x)

        out = self.conv1(x)
        out = self.bn1(out)
        out = self.relu(out)

        out = self.conv2(out)
        out = self.bn2(out)
        out = self.relu(out)

        out = self.conv3(out)
        out = self.bn3(out)

        out += identity
        out = self.relu(out)

        return out


class ResNet(nn.Module):

    def __init__(self, block, blocks_num, num_classes=1000, include_top=True):
        super(ResNet, self).__init__()
        self.include_top = include_top
        self.in_channel = 64

        self.conv1 = nn.Conv2d(3, self.in_channel, kernel_size=7, stride=2,
                               padding=3, bias=False)
        self.bn1 = nn.BatchNorm2d(self.in_channel)
        self.relu = nn.ReLU(inplace=True)
        self.maxpool = nn.MaxPool2d(kernel_size=3, stride=2, padding=1)
        self.layer1 = self._make_layer(block, 64, blocks_num[0])
        self.layer2 = self._make_layer(block, 128, blocks_num[1], stride=2)
        self.layer3 = self._make_layer(block, 256, blocks_num[2], stride=2)
        self.layer4 = self._make_layer(block, 512, blocks_num[3], stride=2)
        if self.include_top:
            self.avgpool = nn.AdaptiveAvgPool2d((1, 1))  # output size = (1, 1)
            self.fc = nn.Linear(512 * block.expansion, num_classes)

        for m in self.modules():
            if isinstance(m, nn.Conv2d):
                nn.init.kaiming_normal_(m.weight, mode='fan_out', nonlinearity='relu')

    def _make_layer(self, block, channel, block_num, stride=1):
        downsample = None
        if stride != 1 or self.in_channel != channel * block.expansion:
            downsample = nn.Sequential(
                nn.Conv2d(self.in_channel, channel * block.expansion, kernel_size=1, stride=stride, bias=False),
                nn.BatchNorm2d(channel * block.expansion))

        layers = []
        layers.append(block(self.in_channel, channel, downsample=downsample, stride=stride))
        self.in_channel = channel * block.expansion

        for _ in range(1, block_num):
            layers.append(block(self.in_channel, channel))

        return nn.Sequential(*layers)

    def forward(self, x):
        x = self.conv1(x)
        x = self.bn1(x)
        x = self.relu(x)
        x = self.maxpool(x)

        x = self.layer1(x)
        x = self.layer2(x)
        x = self.layer3(x)
        x = self.layer4(x)

        if self.include_top:
            x = self.avgpool(x)
            x = torch.flatten(x, 1)
            x = self.fc(x)

        return x


def resnet34(num_classes=1000, include_top=True):
    return ResNet(BasicBlock, [3, 4, 6, 3], num_classes=num_classes, include_top=include_top)


def resnet101(num_classes=1000, include_top=True):
    return ResNet(Bottleneck, [3, 4, 23, 3], num_classes=num_classes, include_top=include_top)


================================================
FILE: deploying_service/pruning_model_pytorch/predict.py
================================================
import torch
from model import resnet34
from PIL import Image
from torchvision import transforms
import matplotlib.pyplot as plt
import json

device = torch.device("cuda:0" if torch.cuda.is_available() else "cpu")

data_transform = transforms.Compose(
    [transforms.Resize(256),
     transforms.CenterCrop(224),
     transforms.ToTensor(),
     transforms.Normalize([0.485, 0.456, 0.406], [0.229, 0.224, 0.225])])

# load image
img = Image.open("../tulip.jpg")
plt.imshow(img)
# [N, C, H, W]
img = data_transform(img)
# expand batch dimension
img = torch.unsqueeze(img, dim=0)

# read class_indict
try:
    json_file = open('./class_indices.json', 'r')
    class_indict = json.load(json_file)
except Exception as e:
    print(e)
    exit(-1)

# create model
model = resnet34(num_classes=5)
# load model weights
model_weight_path = "./resNet34.pth"
model.load_state_dict(torch.load(model_weight_path, map_location=device))
model.eval()
with torch.no_grad():
    # predict class
    output = torch.squeeze(model(img))
    predict = torch.softmax(output, dim=0)
    predict_cla = torch.argmax(predict).numpy()
print(class_indict[str(predict_cla)], predict[predict_cla].numpy())
plt.show()


================================================
FILE: deploying_service/pruning_model_pytorch/train.py
================================================
import torch
import torch.nn as nn
from torchvision import transforms, datasets
import json
import matplotlib.pyplot as plt
import os
import torch.optim as optim
from model import resnet34, resnet101


device = torch.device("cuda:0" if torch.cuda.is_available() else "cpu")
print(device)

data_transform = {
    "train": transforms.Compose([transforms.RandomResizedCrop(224),
                                 transforms.RandomHorizontalFlip(),
                                 transforms.ToTensor(),
                                 transforms.Normalize([0.485, 0.456, 0.406], [0.229, 0.224, 0.225])]),
    "val": transforms.Compose([transforms.Resize(256),
                               transforms.CenterCrop(224),
                               transforms.ToTensor(),
                               transforms.Normalize([0.485, 0.456, 0.406], [0.229, 0.224, 0.225])])}


data_root = os.path.abspath(os.path.join(os.getcwd(), "../.."))  # get data root path
image_path = data_root + "/data_set/flower_data/"  # flower data set path

train_dataset = datasets.ImageFolder(root=image_path+"train",
                                     transform=data_transform["train"])
train_num = len(train_dataset)

# {'daisy':0, 'dandelion':1, 'roses':2, 'sunflower':3, 'tulips':4}
flower_list = train_dataset.class_to_idx
cla_dict = dict((val, key) for key, val in flower_list.items())
# write dict into json file
json_str = json.dumps(cla_dict, indent=4)
with open('class_indices.json', 'w') as json_file:
    json_file.write(json_str)

batch_size = 16
train_loader = torch.utils.data.DataLoader(train_dataset,
                                           batch_size=batch_size, shuffle=True,
                                           num_workers=0)

validate_dataset = datasets.ImageFolder(root=image_path + "val",
                                        transform=data_transform["val"])
val_num = len(validate_dataset)
validate_loader = torch.utils.data.DataLoader(validate_dataset,
                                              batch_size=batch_size, shuffle=False,
                                              num_workers=0)

net = resnet34()
# load pretrain weights
model_weight_path = "./resnet34-pre.pth"
missing_keys, unexpected_keys = net.load_state_dict(torch.load(model_weight_path), strict=False)
# for param in net.parameters():
#     param.requires_grad = False
# change fc layer structure
inchannel = net.fc.in_features
net.fc = nn.Linear(inchannel, 5)
net.to(device)

loss_function = nn.CrossEntropyLoss()
optimizer = optim.Adam(net.parameters(), lr=0.0001)

best_acc = 0.0
save_path = './resNet34.pth'
for epoch in range(3):
    # train
    net.train()
    running_loss = 0.0
    for step, data in enumerate(train_loader, start=0):
        images, labels = data
        optimizer.zero_grad()
        logits = net(images.to(device))
        loss = loss_function(logits, labels.to(device))
        loss.backward()
        optimizer.step()

        # print statistics
        running_loss += loss.item()
        # print train process
        rate = (step+1)/len(train_loader)
        a = "*" * int(rate * 50)
        b = "." * int((1 - rate) * 50)
        print("\rtrain loss: {:^3.0f}%[{}->{}]{:.4f}".format(int(rate*100), a, b, loss), end="")
    print()

    # validate
    net.eval()
    acc = 0.0  # accumulate accurate number / epoch
    with torch.no_grad():
        for val_data in validate_loader:
            val_images, val_labels = val_data
            outputs = net(val_images.to(device))  # eval model only have last output layer
            # loss = loss_function(outputs, test_labels)
            predict_y = torch.max(outputs, dim=1)[1]
            acc += (predict_y == val_labels.to(device)).sum().item()
        val_accurate = acc / val_num
        if val_accurate > best_acc:
            best_acc = val_accurate
            torch.save(net.state_dict(), save_path)
        print('[epoch %d] train_loss: %.3f  test_accuracy: %.3f' %
              (epoch + 1, running_loss / step, val_accurate))

print('Finished Training')




================================================
FILE: others_project/draw_dilated_conv/main.py
================================================
import numpy as np
import matplotlib.pyplot as plt
from matplotlib.colors import LinearSegmentedColormap


def dilated_conv_one_pixel(center: (int, int),
                           feature_map: np.ndarray,
                           k: int = 3,
                           r: int = 1,
                           v: int = 1):
    """
    膨胀卷积核中心在指定坐标center处时,统计哪些像素被利用到,
    并在利用到的像素位置处加上增量v
    Args:
        center: 膨胀卷积核中心的坐标
        feature_map: 记录每个像素使用次数的特征图
        k: 膨胀卷积核的kernel大小
        r: 膨胀卷积的dilation rate
        v: 使用次数增量
    """
    assert divmod(3, 2)[1] == 1

    # left-top: (x, y)
    left_top = (center[0] - ((k - 1) // 2) * r, center[1] - ((k - 1) // 2) * r)
    for i in range(k):
        for j in range(k):
            feature_map[left_top[1] + i * r][left_top[0] + j * r] += v


def dilated_conv_all_map(dilated_map: np.ndarray,
                         k: int = 3,
                         r: int = 1):
    """
    根据输出特征矩阵中哪些像素被使用以及使用次数,
    配合膨胀卷积k和r计算输入特征矩阵哪些像素被使用以及使用次数
    Args:
        dilated_map: 记录输出特征矩阵中每个像素被使用次数的特征图
        k: 膨胀卷积核的kernel大小
        r: 膨胀卷积的dilation rate
    """
    new_map = np.zeros_like(dilated_map)
    for i in range(dilated_map.shape[0]):
        for j in range(dilated_map.shape[1]):
            if dilated_map[i][j] > 0:
                dilated_conv_one_pixel((j, i), new_map, k=k, r=r, v=dilated_map[i][j])

    return new_map


def plot_map(matrix: np.ndarray):
    plt.figure()

    c_list = ['white', 'blue', 'red']
    new_cmp = LinearSegmentedColormap.from_list('chaos', c_list)
    plt.imshow(matrix, cmap=new_cmp)

    ax = plt.gca()
    ax.set_xticks(np.arange(-0.5, matrix.shape[1], 1), minor=True)
    ax.set_yticks(np.arange(-0.5, matrix.shape[0], 1), minor=True)

    # 显示color bar
    plt.colorbar()

    # 在图中标注数量
    thresh = 5
    for x in range(matrix.shape[1]):
        for y in range(matrix.shape[0]):
            # 注意这里的matrix[y, x]不是matrix[x, y]
            info = int(matrix[y, x])
            ax.text(x, y, info,
                    verticalalignment='center',
                    horizontalalignment='center',
                    color="white" if info > thresh else "black")
    ax.grid(which='minor', color='black', linestyle='-', linewidth=1.5)
    plt.show()
    plt.close()


def main():
    # bottom to top
    dilated_rates = [1, 2, 3]
    # init feature map
    size = 31
    m = np.zeros(shape=(size, size), dtype=np.int32)
    center = size // 2
    m[center][center] = 1
    # print(m)
    # plot_map(m)

    for index, dilated_r in enumerate(dilated_rates[::-1]):
        new_map = dilated_conv_all_map(m, r=dilated_r)
        m = new_map
    print(m)
    plot_map(m)


if __name__ == '__main__':
    main()


================================================
FILE: others_project/kmeans_anchors/main.py
================================================
import random
import numpy as np
from tqdm import tqdm
from scipy.cluster.vq import kmeans

from read_voc import VOCDataSet
from yolo_kmeans import k_means, wh_iou


def anchor_fitness(k: np.ndarray, wh: np.ndarray, thr: float):  # mutation fitness
    r = wh[:, None] / k[None]
    x = np.minimum(r, 1. / r).min(2)  # ratio metric
    # x = wh_iou(wh, k)  # iou metric
    best = x.max(1)
    f = (best * (best > thr).astype(np.float32)).mean()  # fitness
    bpr = (best > thr).astype(np.float32).mean()  # best possible recall
    return f, bpr


def main(img_size=512, n=9, thr=0.25, gen=1000):
    # 从数据集中读取所有图片的wh以及对应bboxes的wh
    dataset = VOCDataSet(voc_root="/data", year="2012", txt_name="train.txt")
    im_wh, boxes_wh = dataset.get_info()

    # 最大边缩放到img_size
    im_wh = np.array(im_wh, dtype=np.float32)
    shapes = img_size * im_wh / im_wh.max(1, keepdims=True)
    wh0 = np.concatenate([l * s for s, l in zip(shapes, boxes_wh)])  # wh

    # Filter 过滤掉小目标
    i = (wh0 < 3.0).any(1).sum()
    if i:
        print(f'WARNING: Extremely small objects found. {i} of {len(wh0)} labels are < 3 pixels in size.')
    wh = wh0[(wh0 >= 2.0).any(1)]  # 只保留wh都大于等于2个像素的box

    # Kmeans calculation
    # print(f'Running kmeans for {n} anchors on {len(wh)} points...')
    # s = wh.std(0)  # sigmas for whitening
    # k, dist = kmeans(wh / s, n, iter=30)  # points, mean distance
    # assert len(k) == n, print(f'ERROR: scipy.cluster.vq.kmeans requested {n} points but returned only {len(k)}')
    # k *= s
    k = k_means(wh, n)

    # 按面积排序
    k = k[np.argsort(k.prod(1))]  # sort small to large
    f, bpr = anchor_fitness(k, wh, thr)
    print("kmeans: " + " ".join([f"[{int(i[0])}, {int(i[1])}]" for i in k]))
    print(f"fitness: {f:.5f}, best possible recall: {bpr:.5f}")

    # Evolve
    # 遗传算法(在kmeans的结果基础上变异mutation)
    npr = np.random
    f, sh, mp, s = anchor_fitness(k, wh, thr)[0], k.shape, 0.9, 0.1  # fitness, generations, mutation prob, sigma
    pbar = tqdm(range(gen), desc=f'Evolving anchors with Genetic Algorithm:')  # progress bar
    for _ in pbar:
        v = np.ones(sh)
        while (v == 1).all():  # mutate until a change occurs (prevent duplicates)
            v = ((npr.random(sh) < mp) * random.random() * npr.randn(*sh) * s + 1).clip(0.3, 3.0)
        kg = (k.copy() * v).clip(min=2.0)
        fg, bpr = anchor_fitness(kg, wh, thr)
        if fg > f:
            f, k = fg, kg.copy()
            pbar.desc = f'Evolving anchors with Genetic Algorithm: fitness = {f:.4f}'

    # 按面积排序
    k = k[np.argsort(k.prod(1))]  # sort small to large
    print("genetic: " + " ".join([f"[{int(i[0])}, {int(i[1])}]" for i in k]))
    print(f"fitness: {f:.5f}, best possible recall: {bpr:.5f}")


if __name__ == "__main__":
    main()


================================================
FILE: others_project/kmeans_anchors/plot_kmeans.py
================================================
import numpy as np
from matplotlib import pyplot as plt
np.random.seed(0)

colors = np.array(['blue', 'black'])


def plot_clusters(data, cls, clusters, title=""):
    if cls is None:
        c = [colors[0]] * data.shape[0]
    else:
        c = colors[cls].tolist()

    plt.scatter(data[:, 0], data[:, 1], c=c)
    for i, clus in enumerate(clusters):
        plt.scatter(clus[0], clus[1], c='gold', marker='*', s=150)
    plt.title(title)
    plt.show()
    plt.close()


def distances(data, clusters):
    xy1 = data[:, None]  # [N,1,2]
    xy2 = clusters[None]  # [1,M,2]
    d = np.sum(np.power(xy2 - xy1, 2), axis=-1)
    return d


def k_means(data, k, dist=np.mean):
    """
    k-means methods
    Args:
        data: 需要聚类的data
        k: 簇数(聚成几类)
        dist: 更新簇坐标的方法
    """
    data_number = data.shape[0]
    last_nearest = np.zeros((data_number,))

    # init k clusters
    clusters = data[np.random.choice(data_number, k, replace=False)]
    print(f"random cluster: \n {clusters}")
    # plot
    plot_clusters(data, None, clusters, "random clusters")

    step = 0
    while True:
        d = distances(data, clusters)
        current_nearest = np.argmin(d, axis=1)

        # plot
        plot_clusters(data, current_nearest, clusters, f"step {step}")
        
        if (last_nearest == current_nearest).all():
            break  # clusters won't change
        for cluster in range(k):
            # update clusters
            clusters[cluster] = dist(data[current_nearest == cluster], axis=0)
        last_nearest = current_nearest
        step += 1

    return clusters


def main():
    x1, y1 = [np.random.normal(loc=1., size=150) for _ in range(2)]
    x2, y2 = [np.random.normal(loc=5., size=150) for _ in range(2)]

    x = np.concatenate([x1, x2])
    y = np.concatenate([y1, y2])

    plt.scatter(x, y, c='blue')
    plt.title("initial data")
    plt.show()
    plt.close()

    clusters = k_means(np.concatenate([x[:, None], y[:, None]], axis=-1), k=2)
    print(f"k-means fluster: \n {clusters}")


if __name__ == '__main__':
    main()


================================================
FILE: others_project/kmeans_anchors/read_voc.py
================================================
import os
from tqdm import tqdm
from lxml import etree


class VOCDataSet(object):
    def __init__(self, voc_root, year="2012", txt_name: str = "train.txt"):
        assert year in ["2007", "2012"], "year must be in ['2007', '2012']"
        self.root = os.path.join(voc_root, "VOCdevkit", f"VOC{year}")
        self.annotations_root = os.path.join(self.root, "Annotations")

        # read train.txt or val.txt file
        txt_path = os.path.join(self.root, "ImageSets", "Main", txt_name)
        assert os.path.exists(txt_path), "not found {} file.".format(txt_name)

        with open(txt_path) as read:
            self.xml_list = [os.path.join(self.annotations_root, line.strip() + ".xml")
                             for line in read.readlines() if len(line.strip()) > 0]

        # check file
        assert len(self.xml_list) > 0, "in '{}' file does not find any information.".format(txt_path)
        for xml_path in self.xml_list:
            assert os.path.exists(xml_path), "not found '{}' file.".format(xml_path)

    def __len__(self):
        return len(self.xml_list)

    def parse_xml_to_dict(self, xml):
        """
        将xml文件解析成字典形式,参考tensorflow的recursive_parse_xml_to_dict
        Args:
            xml: xml tree obtained by parsing XML file contents using lxml.etree

        Returns:
            Python dictionary holding XML contents.
        """

        if len(xml) == 0:  # 遍历到底层,直接返回tag对应的信息
            return {xml.tag: xml.text}

        result = {}
        for child in xml:
            child_result = self.parse_xml_to_dict(child)  # 递归遍历标签信息
            if child.tag != 'object':
                result[child.tag] = child_result[child.tag]
            else:
                if child.tag not in result:  # 因为object可能有多个,所以需要放入列表里
                    result[child.tag] = []
                result[child.tag].append(child_result[child.tag])
        return {xml.tag: result}

    def get_info(self):
        im_wh_list = []
        boxes_wh_list = []
        for xml_path in tqdm(self.xml_list, desc="read data info."):
            # read xml
            with open(xml_path) as fid:
                xml_str = fid.read()
            xml = etree.fromstring(xml_str)
            data = self.parse_xml_to_dict(xml)["annotation"]
            im_height = int(data["size"]["height"])
            im_width = int(data["size"]["width"])

            wh = []
            for obj in data["object"]:
                xmin = float(obj["bndbox"]["xmin"])
                xmax = float(obj["bndbox"]["xmax"])
                ymin = float(obj["bndbox"]["ymin"])
                ymax = float(obj["bndbox"]["ymax"])
                wh.append([(xmax - xmin) / im_width, (ymax - ymin) / im_height])

            if len(wh) == 0:
                continue

            im_wh_list.append([im_width, im_height])
            boxes_wh_list.append(wh)

        return im_wh_list, boxes_wh_list


================================================
FILE: others_project/kmeans_anchors/yolo_kmeans.py
================================================
import numpy as np


def wh_iou(wh1, wh2):
    # Returns the nxm IoU matrix. wh1 is nx2, wh2 is mx2
    wh1 = wh1[:, None]  # [N,1,2]
    wh2 = wh2[None]  # [1,M,2]
    inter = np.minimum(wh1, wh2).prod(2)  # [N,M]
    return inter / (wh1.prod(2) + wh2.prod(2) - inter)  # iou = inter / (area1 + area2 - inter)


def k_means(boxes, k, dist=np.median):
    """
    yolo k-means methods
    refer: https://github.com/qqwweee/keras-yolo3/blob/master/kmeans.py
    Args:
        boxes: 需要聚类的bboxes
        k: 簇数(聚成几类)
        dist: 更新簇坐标的方法(默认使用中位数,比均值效果略好)
    """
    box_number = boxes.shape[0]
    last_nearest = np.zeros((box_number,))
    # np.random.seed(0)  # 固定随机数种子

    # init k clusters
    clusters = boxes[np.random.choice(box_number, k, replace=False)]

    while True:
        distances = 1 - wh_iou(boxes, clusters)
        current_nearest = np.argmin(distances, axis=1)
        if (last_nearest == current_nearest).all():
            break  # clusters won't change
        for cluster in range(k):
            # update clusters
            clusters[cluster] = dist(boxes[current_nearest == cluster], axis=0)

        last_nearest = current_nearest

    return clusters


================================================
FILE: others_project/openvinotest/openvino_cls_test/class_indices.json
================================================
{
    "0": "daisy",
    "1": "dandelion",
    "2": "roses",
    "3": "sunflowers",
    "4": "tulips"
}

================================================
FILE: others_project/openvinotest/openvino_cls_test/create_imagenet_annotation.py
================================================
import os
import glob

image_dir = "/home/w180662/my_project/my_github/data_set/flower_data/train"
assert os.path.exists(image_dir), "image dir does not exist..."

img_list = glob.glob(os.path.join(image_dir, "*", "*.jpg"))
assert len(img_list) > 0, "No images(.jpg) were found in image dir..."

classes_info = os.listdir(image_dir)
classes_info.sort()
classes_dict = {}

# create label file
with open("my_labels.txt", "w") as lw:
    # 注意,没有背景时,index要从0开始
    for index, c in enumerate(classes_info, start=0):
        txt = "{}:{}".format(index, c)
        if index != len(classes_info):
            txt += "\n"
        lw.
Download .txt
gitextract_1s0rnibl/

├── .github/
│   └── ISSUE_TEMPLATE/
│       └── issue-template.md
├── .gitignore
├── LICENSE
├── README.md
├── article_link/
│   └── README.md
├── course_ppt/
│   └── README.md
├── data_set/
│   ├── README.md
│   └── split_data.py
├── deploying_service/
│   ├── deploying_pytorch/
│   │   ├── convert_onnx_cls/
│   │   │   ├── class_indices.json
│   │   │   ├── main.py
│   │   │   └── model.py
│   │   ├── convert_openvino/
│   │   │   ├── convert_resnet34/
│   │   │   │   ├── README.md
│   │   │   │   ├── compare_fps.py
│   │   │   │   ├── compare_onnx_and_ir.py
│   │   │   │   ├── convert_pytorch2onnx.py
│   │   │   │   ├── model.py
│   │   │   │   ├── quantization_int8.py
│   │   │   │   ├── requirements.txt
│   │   │   │   └── utils.py
│   │   │   └── convert_yolov5/
│   │   │       ├── README.md
│   │   │       ├── compare_fps.py
│   │   │       ├── compare_onnx_and_ir.py
│   │   │       ├── draw_box_utils.py
│   │   │       ├── evaluation.py
│   │   │       ├── predict.py
│   │   │       ├── quantization_int8.py
│   │   │       ├── requirements.txt
│   │   │       └── utils.py
│   │   ├── convert_tensorrt/
│   │   │   └── convert_resnet34/
│   │   │       ├── compare_onnx_and_trt.py
│   │   │       ├── convert_pytorch2onnx.py
│   │   │       ├── my_dataset.py
│   │   │       ├── quantization.py
│   │   │       └── utils.py
│   │   └── pytorch_flask_service/
│   │       ├── class_indices.json
│   │       ├── main.py
│   │       ├── model.py
│   │       ├── requirements.txt
│   │       └── templates/
│   │           └── up.html
│   └── pruning_model_pytorch/
│       ├── class_indices.json
│       ├── main.py
│       ├── model.py
│       ├── predict.py
│       └── train.py
├── others_project/
│   ├── draw_dilated_conv/
│   │   └── main.py
│   ├── kmeans_anchors/
│   │   ├── main.py
│   │   ├── plot_kmeans.py
│   │   ├── read_voc.py
│   │   └── yolo_kmeans.py
│   ├── openvinotest/
│   │   └── openvino_cls_test/
│   │       ├── class_indices.json
│   │       ├── create_imagenet_annotation.py
│   │       ├── float32vsint8.py
│   │       ├── main.py
│   │       ├── model.py
│   │       └── speed_test.py
│   ├── readPbFile/
│   │   ├── README.md
│   │   ├── pascal_label_map.pbtxt
│   │   ├── readPb.py
│   │   ├── test_images/
│   │   │   └── image_info.txt
│   │   └── using_function.py
│   ├── textcnnKeras/
│   │   ├── dataGenerator.py
│   │   ├── data_link.txt
│   │   ├── main.py
│   │   └── models.py
│   └── trans_widerface_to_xml/
│       ├── create_xml.py
│       └── main.py
├── pytorch_classification/
│   ├── ConfusionMatrix/
│   │   ├── class_indices.json
│   │   ├── main.py
│   │   └── model.py
│   ├── ConvNeXt/
│   │   ├── README.md
│   │   ├── model.py
│   │   ├── my_dataset.py
│   │   ├── predict.py
│   │   ├── train.py
│   │   └── utils.py
│   ├── MobileViT/
│   │   ├── README.md
│   │   ├── model.py
│   │   ├── model_config.py
│   │   ├── my_dataset.py
│   │   ├── predict.py
│   │   ├── train.py
│   │   ├── transformer.py
│   │   ├── unfold_test.py
│   │   └── utils.py
│   ├── README.md
│   ├── Test10_regnet/
│   │   ├── README.md
│   │   ├── model.py
│   │   ├── my_dataset.py
│   │   ├── predict.py
│   │   ├── pretrain_weights.py
│   │   ├── train.py
│   │   └── utils.py
│   ├── Test11_efficientnetV2/
│   │   ├── README.md
│   │   ├── class_indices.json
│   │   ├── model.py
│   │   ├── my_dataset.py
│   │   ├── predict.py
│   │   ├── train.py
│   │   ├── trans_effv2_weights.py
│   │   └── utils.py
│   ├── Test1_official_demo/
│   │   ├── model.py
│   │   ├── predict.py
│   │   └── train.py
│   ├── Test2_alexnet/
│   │   ├── class_indices.json
│   │   ├── model.py
│   │   ├── predict.py
│   │   └── train.py
│   ├── Test3_vggnet/
│   │   ├── class_indices.json
│   │   ├── model.py
│   │   ├── predict.py
│   │   └── train.py
│   ├── Test4_googlenet/
│   │   ├── class_indices.json
│   │   ├── model.py
│   │   ├── predict.py
│   │   └── train.py
│   ├── Test5_resnet/
│   │   ├── README.md
│   │   ├── batch_predict.py
│   │   ├── class_indices.json
│   │   ├── load_weights.py
│   │   ├── model.py
│   │   ├── predict.py
│   │   └── train.py
│   ├── Test6_mobilenet/
│   │   ├── class_indices.json
│   │   ├── model_v2.py
│   │   ├── model_v3.py
│   │   ├── predict.py
│   │   └── train.py
│   ├── Test7_shufflenet/
│   │   ├── README.md
│   │   ├── class_indices.json
│   │   ├── model.py
│   │   ├── my_dataset.py
│   │   ├── predict.py
│   │   ├── train.py
│   │   └── utils.py
│   ├── Test8_densenet/
│   │   ├── README.md
│   │   ├── model.py
│   │   ├── my_dataset.py
│   │   ├── predict.py
│   │   ├── train.py
│   │   └── utils.py
│   ├── Test9_efficientNet/
│   │   ├── README.md
│   │   ├── model.py
│   │   ├── my_dataset.py
│   │   ├── predict.py
│   │   ├── requirements.txt
│   │   ├── train.py
│   │   ├── trans_weights_to_pytorch.py
│   │   └── utils.py
│   ├── analyze_weights_featuremap/
│   │   ├── alexnet_model.py
│   │   ├── analyze_feature_map.py
│   │   ├── analyze_kernel_weight.py
│   │   └── resnet_model.py
│   ├── custom_dataset/
│   │   ├── main.py
│   │   ├── my_dataset.py
│   │   └── utils.py
│   ├── grad_cam/
│   │   ├── README.md
│   │   ├── imagenet1k_classes.txt
│   │   ├── imagenet21k_classes.txt
│   │   ├── main_cnn.py
│   │   ├── main_swin.py
│   │   ├── main_vit.py
│   │   ├── swin_model.py
│   │   ├── utils.py
│   │   └── vit_model.py
│   ├── mini_imagenet/
│   │   ├── README.md
│   │   ├── imagenet_class_index.json
│   │   ├── model.py
│   │   ├── multi_train_utils/
│   │   │   ├── __init__.py
│   │   │   ├── distributed_utils.py
│   │   │   └── train_eval_utils.py
│   │   ├── my_dataset.py
│   │   ├── restructure_csv.py
│   │   ├── train_multi_gpu_using_launch.py
│   │   └── train_single_gpu.py
│   ├── model_complexity/
│   │   ├── main.py
│   │   ├── model.py
│   │   └── utils.py
│   ├── swin_transformer/
│   │   ├── README.md
│   │   ├── create_confusion_matrix.py
│   │   ├── model.py
│   │   ├── my_dataset.py
│   │   ├── predict.py
│   │   ├── select_incorrect_samples.py
│   │   ├── train.py
│   │   └── utils.py
│   ├── tensorboard_test/
│   │   ├── data_utils.py
│   │   ├── model.py
│   │   ├── my_dataset.py
│   │   ├── requirements.txt
│   │   ├── train.py
│   │   └── train_eval_utils.py
│   ├── train_multi_GPU/
│   │   ├── README.md
│   │   ├── model.py
│   │   ├── multi_train_utils/
│   │   │   ├── distributed_utils.py
│   │   │   └── train_eval_utils.py
│   │   ├── my_dataset.py
│   │   ├── plot_results.py
│   │   ├── requirements.txt
│   │   ├── train_multi_gpu_using_launch.py
│   │   ├── train_multi_gpu_using_spawn.py
│   │   ├── train_single_gpu.py
│   │   └── utils.py
│   └── vision_transformer/
│       ├── README.md
│       ├── flops.py
│       ├── my_dataset.py
│       ├── predict.py
│       ├── train.py
│       ├── utils.py
│       └── vit_model.py
├── pytorch_keypoint/
│   ├── DeepPose/
│   │   ├── README.md
│   │   ├── datasets.py
│   │   ├── export_onnx.py
│   │   ├── model.py
│   │   ├── predict.py
│   │   ├── requirements.txt
│   │   ├── train.py
│   │   ├── train_multi_GPU.py
│   │   ├── train_utils/
│   │   │   ├── distributed_utils.py
│   │   │   ├── losses.py
│   │   │   ├── metrics.py
│   │   │   └── train_eval_utils.py
│   │   ├── transforms.py
│   │   ├── utils.py
│   │   └── wflw_horizontal_flip_indices.py
│   └── HRNet/
│       ├── README.md
│       ├── draw_utils.py
│       ├── model/
│       │   ├── __init__.py
│       │   └── hrnet.py
│       ├── my_dataset_coco.py
│       ├── person_keypoints.json
│       ├── plot_curve.py
│       ├── predict.py
│       ├── requirements.txt
│       ├── train.py
│       ├── train_multi_GPU.py
│       ├── train_utils/
│       │   ├── __init__.py
│       │   ├── coco_eval.py
│       │   ├── coco_utils.py
│       │   ├── distributed_utils.py
│       │   ├── group_by_aspect_ratio.py
│       │   ├── loss.py
│       │   └── train_eval_utils.py
│       ├── transforms.py
│       └── validation.py
├── pytorch_object_detection/
│   ├── faster_rcnn/
│   │   ├── README.md
│   │   ├── backbone/
│   │   │   ├── __init__.py
│   │   │   ├── feature_pyramid_network.py
│   │   │   ├── mobilenetv2_model.py
│   │   │   ├── resnet50_fpn_model.py
│   │   │   └── vgg_model.py
│   │   ├── change_backbone_with_fpn.py
│   │   ├── change_backbone_without_fpn.py
│   │   ├── draw_box_utils.py
│   │   ├── my_dataset.py
│   │   ├── network_files/
│   │   │   ├── __init__.py
│   │   │   ├── boxes.py
│   │   │   ├── det_utils.py
│   │   │   ├── faster_rcnn_framework.py
│   │   │   ├── image_list.py
│   │   │   ├── roi_head.py
│   │   │   ├── rpn_function.py
│   │   │   └── transform.py
│   │   ├── pascal_voc_classes.json
│   │   ├── plot_curve.py
│   │   ├── predict.py
│   │   ├── record_mAP.txt
│   │   ├── requirements.txt
│   │   ├── split_data.py
│   │   ├── train_mobilenetv2.py
│   │   ├── train_multi_GPU.py
│   │   ├── train_res50_fpn.py
│   │   ├── train_utils/
│   │   │   ├── __init__.py
│   │   │   ├── coco_eval.py
│   │   │   ├── coco_utils.py
│   │   │   ├── distributed_utils.py
│   │   │   ├── group_by_aspect_ratio.py
│   │   │   └── train_eval_utils.py
│   │   ├── transforms.py
│   │   └── validation.py
│   ├── mask_rcnn/
│   │   ├── README.md
│   │   ├── backbone/
│   │   │   ├── __init__.py
│   │   │   ├── feature_pyramid_network.py
│   │   │   └── resnet50_fpn_model.py
│   │   ├── coco91_indices.json
│   │   ├── det_results20220406-141544.txt
│   │   ├── draw_box_utils.py
│   │   ├── my_dataset_coco.py
│   │   ├── my_dataset_voc.py
│   │   ├── network_files/
│   │   │   ├── __init__.py
│   │   │   ├── boxes.py
│   │   │   ├── det_utils.py
│   │   │   ├── faster_rcnn_framework.py
│   │   │   ├── image_list.py
│   │   │   ├── mask_rcnn.py
│   │   │   ├── roi_head.py
│   │   │   ├── rpn_function.py
│   │   │   └── transform.py
│   │   ├── pascal_voc_indices.json
│   │   ├── plot_curve.py
│   │   ├── predict.py
│   │   ├── requirements.txt
│   │   ├── seg_results20220406-141544.txt
│   │   ├── train.py
│   │   ├── train_multi_GPU.py
│   │   ├── train_utils/
│   │   │   ├── __init__.py
│   │   │   ├── coco_eval.py
│   │   │   ├── coco_utils.py
│   │   │   ├── distributed_utils.py
│   │   │   ├── group_by_aspect_ratio.py
│   │   │   └── train_eval_utils.py
│   │   ├── transforms.py
│   │   └── validation.py
│   ├── retinaNet/
│   │   ├── README.md
│   │   ├── backbone/
│   │   │   ├── __init__.py
│   │   │   ├── feature_pyramid_network.py
│   │   │   └── resnet50_fpn_model.py
│   │   ├── draw_box_utils.py
│   │   ├── my_dataset.py
│   │   ├── network_files/
│   │   │   ├── __init__.py
│   │   │   ├── anchor_utils.py
│   │   │   ├── boxes.py
│   │   │   ├── det_utils.py
│   │   │   ├── image_list.py
│   │   │   ├── losses.py
│   │   │   ├── retinanet.py
│   │   │   └── transform.py
│   │   ├── pascal_voc_classes.json
│   │   ├── plot_curve.py
│   │   ├── predict.py
│   │   ├── requirements.txt
│   │   ├── results20210421-142632.txt
│   │   ├── train.py
│   │   ├── train_multi_GPU.py
│   │   ├── train_utils/
│   │   │   ├── __init__.py
│   │   │   ├── coco_eval.py
│   │   │   ├── coco_utils.py
│   │   │   ├── distributed_utils.py
│   │   │   ├── group_by_aspect_ratio.py
│   │   │   └── train_eval_utils.py
│   │   ├── transforms.py
│   │   └── validation.py
│   ├── ssd/
│   │   ├── README.md
│   │   ├── draw_box_utils.py
│   │   ├── my_dataset.py
│   │   ├── pascal_voc_classes.json
│   │   ├── plot_curve.py
│   │   ├── predict_test.py
│   │   ├── record_mAP.txt
│   │   ├── requirements.txt
│   │   ├── src/
│   │   │   ├── __init__.py
│   │   │   ├── res50_backbone.py
│   │   │   ├── ssd_model.py
│   │   │   └── utils.py
│   │   ├── train_multi_GPU.py
│   │   ├── train_ssd300.py
│   │   ├── train_utils/
│   │   │   ├── __init__.py
│   │   │   ├── coco_eval.py
│   │   │   ├── coco_utils.py
│   │   │   ├── distributed_utils.py
│   │   │   ├── group_by_aspect_ratio.py
│   │   │   └── train_eval_utils.py
│   │   ├── transforms.py
│   │   └── validation.py
│   ├── train_coco_dataset/
│   │   ├── README.md
│   │   ├── backbone/
│   │   │   ├── __init__.py
│   │   │   ├── feature_pyramid_network.py
│   │   │   ├── mobilenetv2_model.py
│   │   │   ├── resnet.py
│   │   │   ├── resnet50_fpn_model.py
│   │   │   └── vgg_model.py
│   │   ├── change_backbone_with_fpn.py
│   │   ├── coco91_indices.json
│   │   ├── compute_receptive_field.py
│   │   ├── draw_box_utils.py
│   │   ├── my_dataset.py
│   │   ├── network_files/
│   │   │   ├── __init__.py
│   │   │   ├── boxes.py
│   │   │   ├── det_utils.py
│   │   │   ├── faster_rcnn_framework.py
│   │   │   ├── image_list.py
│   │   │   ├── roi_head.py
│   │   │   ├── rpn_function.py
│   │   │   └── transform.py
│   │   ├── plot_curve.py
│   │   ├── predict.py
│   │   ├── requirements.txt
│   │   ├── results20220408-201436.txt
│   │   ├── train.py
│   │   ├── train_multi_GPU.py
│   │   ├── train_utils/
│   │   │   ├── __init__.py
│   │   │   ├── coco_eval.py
│   │   │   ├── distributed_utils.py
│   │   │   ├── group_by_aspect_ratio.py
│   │   │   └── train_eval_utils.py
│   │   ├── transforms.py
│   │   └── validation.py
│   └── yolov3_spp/
│       ├── README.md
│       ├── build_utils/
│       │   ├── __init__.py
│       │   ├── datasets.py
│       │   ├── img_utils.py
│       │   ├── layers.py
│       │   ├── parse_config.py
│       │   ├── torch_utils.py
│       │   └── utils.py
│       ├── calculate_dataset.py
│       ├── cfg/
│       │   ├── hyp.yaml
│       │   └── yolov3-spp.cfg
│       ├── draw_box_utils.py
│       ├── export_onnx.py
│       ├── load_onnx_test.py
│       ├── models.py
│       ├── predict_test.py
│       ├── requirements.txt
│       ├── results20210515-152935.txt
│       ├── train.py
│       ├── train_multi_GPU.py
│       ├── train_utils/
│       │   ├── __init__.py
│       │   ├── coco_eval.py
│       │   ├── coco_utils.py
│       │   ├── distributed_utils.py
│       │   ├── group_by_aspect_ratio.py
│       │   └── train_eval_utils.py
│       ├── trans_voc2yolo.py
│       └── validation.py
├── pytorch_segmentation/
│   ├── deeplab_v3/
│   │   ├── README.md
│   │   ├── get_palette.py
│   │   ├── my_dataset.py
│   │   ├── palette.json
│   │   ├── pascal_voc_classes.json
│   │   ├── predict.py
│   │   ├── requirements.txt
│   │   ├── results20211027-104607.txt
│   │   ├── src/
│   │   │   ├── __init__.py
│   │   │   ├── deeplabv3_model.py
│   │   │   ├── mobilenet_backbone.py
│   │   │   └── resnet_backbone.py
│   │   ├── train.py
│   │   ├── train_multi_GPU.py
│   │   ├── train_utils/
│   │   │   ├── __init__.py
│   │   │   ├── distributed_utils.py
│   │   │   └── train_and_eval.py
│   │   ├── transforms.py
│   │   └── validation.py
│   ├── fcn/
│   │   ├── README.md
│   │   ├── get_palette.py
│   │   ├── my_dataset.py
│   │   ├── palette.json
│   │   ├── pascal_voc_classes.json
│   │   ├── predict.py
│   │   ├── requirements.txt
│   │   ├── results20210918-122740.txt
│   │   ├── src/
│   │   │   ├── __init__.py
│   │   │   ├── backbone.py
│   │   │   └── fcn_model.py
│   │   ├── train.py
│   │   ├── train_multi_GPU.py
│   │   ├── train_utils/
│   │   │   ├── __init__.py
│   │   │   ├── distributed_utils.py
│   │   │   └── train_and_eval.py
│   │   ├── transforms.py
│   │   └── validation.py
│   ├── lraspp/
│   │   ├── README.md
│   │   ├── get_palette.py
│   │   ├── my_dataset.py
│   │   ├── palette.json
│   │   ├── pascal_voc_classes.json
│   │   ├── predict.py
│   │   ├── requirements.txt
│   │   ├── results20211028-105233.txt
│   │   ├── src/
│   │   │   ├── __init__.py
│   │   │   ├── lraspp_model.py
│   │   │   └── mobilenet_backbone.py
│   │   ├── train.py
│   │   ├── train_multi_GPU.py
│   │   ├── train_utils/
│   │   │   ├── __init__.py
│   │   │   ├── distributed_utils.py
│   │   │   └── train_and_eval.py
│   │   ├── transforms.py
│   │   └── validation.py
│   ├── u2net/
│   │   ├── README.md
│   │   ├── convert_weight.py
│   │   ├── my_dataset.py
│   │   ├── predict.py
│   │   ├── requirements.txt
│   │   ├── results20220723-123632.txt
│   │   ├── src/
│   │   │   ├── __init__.py
│   │   │   └── model.py
│   │   ├── train.py
│   │   ├── train_multi_GPU.py
│   │   ├── train_utils/
│   │   │   ├── __init__.py
│   │   │   ├── distributed_utils.py
│   │   │   └── train_and_eval.py
│   │   ├── transforms.py
│   │   └── validation.py
│   └── unet/
│       ├── README.md
│       ├── compute_mean_std.py
│       ├── my_dataset.py
│       ├── predict.py
│       ├── requirements.txt
│       ├── results20220109-165837.txt
│       ├── src/
│       │   ├── __init__.py
│       │   ├── mobilenet_unet.py
│       │   ├── unet.py
│       │   └── vgg_unet.py
│       ├── train.py
│       ├── train_multi_GPU.py
│       ├── train_utils/
│       │   ├── __init__.py
│       │   ├── dice_coefficient_loss.py
│       │   ├── distributed_utils.py
│       │   └── train_and_eval.py
│       └── transforms.py
├── summary_problem.md
└── tensorflow_classification/
    ├── ConfusionMatrix/
    │   ├── class_indices.json
    │   ├── main.py
    │   └── model.py
    ├── ConvNeXt/
    │   ├── model.py
    │   ├── predict.py
    │   ├── train.py
    │   ├── trans_weights.py
    │   └── utils.py
    ├── README.md
    ├── Test11_efficientnetV2/
    │   ├── model.py
    │   ├── predict.py
    │   ├── train.py
    │   ├── trans_weights.py
    │   └── utils.py
    ├── Test1_official_demo/
    │   ├── model.py
    │   └── train.py
    ├── Test2_alexnet/
    │   ├── class_indices.json
    │   ├── fine_train_alexnet.py
    │   ├── model.py
    │   ├── predict.py
    │   ├── read_pth.py
    │   ├── train.py
    │   └── trainGPU.py
    ├── Test3_vgg/
    │   ├── class_indices.json
    │   ├── fine_train_vgg16.py
    │   ├── model.py
    │   ├── predict.py
    │   ├── read_ckpt.py
    │   ├── train.py
    │   └── trainGPU.py
    ├── Test4_goolenet/
    │   ├── class_indices.json
    │   ├── model.py
    │   ├── model_add_bn.py
    │   ├── predict.py
    │   ├── read_pth.py
    │   ├── train.py
    │   ├── trainGPU.py
    │   └── train_add_bn.py
    ├── Test5_resnet/
    │   ├── batch_predict.py
    │   ├── class_indices.json
    │   ├── model.py
    │   ├── predict.py
    │   ├── read_ckpt.py
    │   ├── read_h5.py
    │   ├── subclassed_model.py
    │   ├── train.py
    │   └── trainGPU.py
    ├── Test6_mobilenet/
    │   ├── model_v2.py
    │   ├── model_v3.py
    │   ├── predict.py
    │   ├── read_ckpt.py
    │   ├── trainGPU_mobilenet_v2.py
    │   ├── train_mobilenet_v2.py
    │   ├── train_mobilenet_v3.py
    │   ├── trans_v3_weights.py
    │   └── utils.py
    ├── Test7_shuffleNet/
    │   ├── model.py
    │   ├── predict.py
    │   ├── train.py
    │   ├── trans_weights.py
    │   └── utils.py
    ├── Test9_efficientNet/
    │   ├── model.py
    │   ├── predict.py
    │   ├── train.py
    │   └── utils.py
    ├── analyze_weights_featuremap/
    │   ├── alexnet_model.py
    │   ├── analyze_feature_map.py
    │   └── analyze_kernel_weight.py
    ├── custom_dataset/
    │   ├── train_fit.py
    │   └── utils.py
    ├── swin_transformer/
    │   ├── model.py
    │   ├── predict.py
    │   ├── train.py
    │   ├── trans_weights.py
    │   └── utils.py
    ├── tensorboard_test/
    │   ├── train_fit.py
    │   └── train_not_fit.py
    └── vision_transformer/
        ├── predict.py
        ├── train.py
        ├── trans_weights.py
        ├── utils.py
        └── vit_model.py
Download .txt
Showing preview only (259K chars total). Download the full file or copy to clipboard to get everything.
SYMBOL INDEX (3150 symbols across 440 files)

FILE: data_set/split_data.py
  function mk_file (line 6) | def mk_file(file_path: str):
  function main (line 13) | def main():

FILE: deploying_service/deploying_pytorch/convert_onnx_cls/main.py
  function to_numpy (line 13) | def to_numpy(tensor):
  function main (line 17) | def main(save_path=None):

FILE: deploying_service/deploying_pytorch/convert_onnx_cls/model.py
  class BasicBlock (line 5) | class BasicBlock(nn.Module):
    method __init__ (line 8) | def __init__(self, in_channel, out_channel, stride=1, downsample=None):
    method forward (line 19) | def forward(self, x):
  class Bottleneck (line 37) | class Bottleneck(nn.Module):
    method __init__ (line 40) | def __init__(self, in_channel, out_channel, stride=1, downsample=None):
    method forward (line 56) | def forward(self, x):
  class ResNet (line 78) | class ResNet(nn.Module):
    method __init__ (line 80) | def __init__(self, block, blocks_num, num_classes=1000, include_top=Tr...
    method _make_layer (line 102) | def _make_layer(self, block, channel, block_num, stride=1):
    method forward (line 118) | def forward(self, x):
  function resnet34 (line 137) | def resnet34(num_classes=1000, include_top=True):
  function resnet101 (line 141) | def resnet101(num_classes=1000, include_top=True):

FILE: deploying_service/deploying_pytorch/convert_openvino/convert_resnet34/compare_fps.py
  function normalize (line 10) | def normalize(image: np.ndarray) -> np.ndarray:
  function onnx_inference (line 23) | def onnx_inference(onnx_path: str, image: np.ndarray, num_images: int = ...
  function ir_inference (line 43) | def ir_inference(ir_path: str, image: np.ndarray, num_images: int = 20):
  function pytorch_inference (line 67) | def pytorch_inference(image: np.ndarray, num_images: int = 20):
  function plot_fps (line 88) | def plot_fps(v: dict):
  function main (line 103) | def main():

FILE: deploying_service/deploying_pytorch/convert_openvino/convert_resnet34/compare_onnx_and_ir.py
  function normalize (line 6) | def normalize(image: np.ndarray) -> np.ndarray:
  function onnx_inference (line 19) | def onnx_inference(onnx_path: str, image: np.ndarray):
  function ir_inference (line 29) | def ir_inference(ir_path: str, image: np.ndarray):
  function main (line 44) | def main():

FILE: deploying_service/deploying_pytorch/convert_openvino/convert_resnet34/convert_pytorch2onnx.py
  function to_numpy (line 11) | def to_numpy(tensor):
  function main (line 15) | def main():

FILE: deploying_service/deploying_pytorch/convert_openvino/convert_resnet34/model.py
  function _make_divisible (line 9) | def _make_divisible(ch, divisor=8, min_ch=None):
  class ConvBNActivation (line 25) | class ConvBNActivation(nn.Sequential):
    method __init__ (line 26) | def __init__(self,
  class SqueezeExcitation (line 50) | class SqueezeExcitation(nn.Module):
    method __init__ (line 51) | def __init__(self, input_c: int, squeeze_factor: int = 4):
    method forward (line 57) | def forward(self, x: Tensor) -> Tensor:
  class InvertedResidualConfig (line 66) | class InvertedResidualConfig:
    method __init__ (line 67) | def __init__(self,
    method adjust_channels (line 85) | def adjust_channels(channels: int, width_multi: float):
  class InvertedResidual (line 89) | class InvertedResidual(nn.Module):
    method __init__ (line 90) | def __init__(self,
    method forward (line 134) | def forward(self, x: Tensor) -> Tensor:
  class MobileNetV3 (line 142) | class MobileNetV3(nn.Module):
    method __init__ (line 143) | def __init__(self,
    method _forward_impl (line 205) | def _forward_impl(self, x: Tensor) -> Tensor:
    method forward (line 213) | def forward(self, x: Tensor) -> Tensor:
  function mobilenet_v3_large (line 217) | def mobilenet_v3_large(num_classes: int = 1000,
  function mobilenet_v3_small (line 263) | def mobilenet_v3_small(num_classes: int = 1000,

FILE: deploying_service/deploying_pytorch/convert_openvino/convert_resnet34/quantization_int8.py
  function main (line 9) | def main():

FILE: deploying_service/deploying_pytorch/convert_openvino/convert_resnet34/utils.py
  function read_split_data (line 11) | def read_split_data(root: str, val_rate: float = 0.2):
  class Accuracy (line 60) | class Accuracy(Metric):
    method __init__ (line 62) | def __init__(self, top_k=1):
    method value (line 69) | def value(self):
    method avg_value (line 74) | def avg_value(self):
    method update (line 78) | def update(self, output, target):
    method reset (line 93) | def reset(self):
    method get_attributes (line 97) | def get_attributes(self):
  class MyDataLoader (line 107) | class MyDataLoader(DataLoader):
    method __init__ (line 108) | def __init__(self, cfg, images_path: list, images_label: list, img_w: ...
    method __len__ (line 119) | def __len__(self):
    method __getitem__ (line 122) | def __getitem__(self, index):

FILE: deploying_service/deploying_pytorch/convert_openvino/convert_yolov5/compare_fps.py
  function normalize (line 9) | def normalize(image: np.ndarray) -> np.ndarray:
  function onnx_inference (line 18) | def onnx_inference(onnx_path: str, image: np.ndarray, num_images: int = ...
  function ir_inference (line 38) | def ir_inference(ir_path: str, image: np.ndarray, num_images: int = 20):
  function pytorch_inference (line 62) | def pytorch_inference(image: np.ndarray, num_images: int = 20):
  function plot_fps (line 83) | def plot_fps(v: dict):
  function main (line 98) | def main():

FILE: deploying_service/deploying_pytorch/convert_openvino/convert_yolov5/compare_onnx_and_ir.py
  function normalize (line 6) | def normalize(image: np.ndarray) -> np.ndarray:
  function onnx_inference (line 15) | def onnx_inference(onnx_path: str, image: np.ndarray):
  function ir_inference (line 25) | def ir_inference(ir_path: str, image: np.ndarray):
  function main (line 40) | def main():

FILE: deploying_service/deploying_pytorch/convert_openvino/convert_yolov5/draw_box_utils.py
  function draw_text (line 34) | def draw_text(draw,
  function draw_masks (line 78) | def draw_masks(image, masks, colors, thresh: float = 0.7, alpha: float =...
  function draw_objs (line 92) | def draw_objs(image: Image,

FILE: deploying_service/deploying_pytorch/convert_openvino/convert_yolov5/evaluation.py
  function main (line 7) | def main():

FILE: deploying_service/deploying_pytorch/convert_openvino/convert_yolov5/predict.py
  function main (line 11) | def main():

FILE: deploying_service/deploying_pytorch/convert_openvino/convert_yolov5/quantization_int8.py
  function main (line 11) | def main():

FILE: deploying_service/deploying_pytorch/convert_openvino/convert_yolov5/utils.py
  function box_iou (line 27) | def box_iou(box1, box2):
  function xywh2xyxy (line 52) | def xywh2xyxy(x):
  function non_max_suppression (line 62) | def non_max_suppression(prediction, conf_thres=0.25, iou_thres=0.45, cla...
  class MAPMetric (line 156) | class MAPMetric(Metric):
    method __init__ (line 157) | def __init__(self, map_value="map", conf_thres=0.001, iou_thres=0.6):
    method value (line 176) | def value(self):
    method avg_value (line 184) | def avg_value(self):
    method update (line 191) | def update(self, output, target):
    method reset (line 239) | def reset(self):
    method get_attributes (line 245) | def get_attributes(self):
  function _coco_remove_images_without_annotations (line 254) | def _coco_remove_images_without_annotations(dataset, ids):
  function scale_coords (line 287) | def scale_coords(img1_shape, coords, img0_shape, ratio_pad=None):
  function clip_coords (line 304) | def clip_coords(boxes, shape):
  function letterbox (line 316) | def letterbox(im, new_shape=(640, 640), color=(114, 114, 114), auto=True...
  class MyDataLoader (line 349) | class MyDataLoader(DataLoader):
    method __init__ (line 357) | def __init__(self, root, dataset="train", size=(640, 640)):
    method parse_targets (line 382) | def parse_targets(self,
    method __getitem__ (line 433) | def __getitem__(self, index):
    method __len__ (line 470) | def __len__(self):
    method collate_fn (line 474) | def collate_fn(x):
  class EvalCOCOMetric (line 478) | class EvalCOCOMetric:
    method __init__ (line 479) | def __init__(self,
    method prepare_for_coco_detection (line 492) | def prepare_for_coco_detection(self, ann, output):
    method update (line 527) | def update(self, targets, outputs):
    method evaluate (line 533) | def evaluate(self):

FILE: deploying_service/deploying_pytorch/convert_tensorrt/convert_resnet34/compare_onnx_and_trt.py
  function normalize (line 8) | def normalize(image: np.ndarray) -> np.ndarray:
  function onnx_inference (line 21) | def onnx_inference(onnx_path: str, image: np.ndarray):
  function trt_inference (line 31) | def trt_inference(trt_path: str, image: np.ndarray):
  function main (line 70) | def main():

FILE: deploying_service/deploying_pytorch/convert_tensorrt/convert_resnet34/convert_pytorch2onnx.py
  function to_numpy (line 11) | def to_numpy(tensor):
  function main (line 15) | def main():

FILE: deploying_service/deploying_pytorch/convert_tensorrt/convert_resnet34/my_dataset.py
  class MyDataSet (line 6) | class MyDataSet(Dataset):
    method __init__ (line 9) | def __init__(self, images_path: list, images_class: list, transform=No...
    method __len__ (line 14) | def __len__(self):
    method __getitem__ (line 17) | def __getitem__(self, item):
    method collate_fn (line 30) | def collate_fn(batch):

FILE: deploying_service/deploying_pytorch/convert_tensorrt/convert_resnet34/quantization.py
  function export_onnx (line 26) | def export_onnx(model, onnx_filename, onnx_bs):
  function collect_stats (line 44) | def collect_stats(model, data_loader, num_batches):
  function compute_amax (line 71) | def compute_amax(model, **kwargs):
  function main (line 84) | def main(args):

FILE: deploying_service/deploying_pytorch/convert_tensorrt/convert_resnet34/utils.py
  function read_split_data (line 11) | def read_split_data(root: str, val_rate: float = 0.2):
  function write_pickle (line 59) | def write_pickle(list_info: list, file_name: str):
  function read_pickle (line 64) | def read_pickle(file_name: str) -> list:
  function train_one_epoch (line 70) | def train_one_epoch(model, optimizer, data_loader, epoch):
  function evaluate (line 106) | def evaluate(model, data_loader, epoch):

FILE: deploying_service/deploying_pytorch/pytorch_flask_service/main.py
  function transform_image (line 34) | def transform_image(image_bytes):
  function get_prediction (line 47) | def get_prediction(image_bytes):
  function predict (line 65) | def predict():
  function root (line 73) | def root():

FILE: deploying_service/deploying_pytorch/pytorch_flask_service/model.py
  function _make_divisible (line 5) | def _make_divisible(ch, divisor=8, min_ch=None):
  class ConvBNReLU (line 21) | class ConvBNReLU(nn.Sequential):
    method __init__ (line 22) | def __init__(self, in_channel, out_channel, kernel_size=3, stride=1, g...
  class InvertedResidual (line 31) | class InvertedResidual(nn.Module):
    method __init__ (line 32) | def __init__(self, in_channel, out_channel, stride, expand_ratio):
    method forward (line 51) | def forward(self, x):
  class MobileNetV2 (line 58) | class MobileNetV2(nn.Module):
    method __init__ (line 59) | def __init__(self, num_classes=1000, alpha=1.0, round_nearest=8):
    method forward (line 111) | def forward(self, x):

FILE: deploying_service/pruning_model_pytorch/main.py
  function validate_model (line 22) | def validate_model(model: torch.nn.Module):
  function count_sparsity (line 45) | def count_sparsity(model: torch.nn.Module, p=True):
  function main (line 60) | def main():

FILE: deploying_service/pruning_model_pytorch/model.py
  class BasicBlock (line 5) | class BasicBlock(nn.Module):
    method __init__ (line 8) | def __init__(self, in_channel, out_channel, stride=1, downsample=None):
    method forward (line 19) | def forward(self, x):
  class Bottleneck (line 37) | class Bottleneck(nn.Module):
    method __init__ (line 40) | def __init__(self, in_channel, out_channel, stride=1, downsample=None):
    method forward (line 56) | def forward(self, x):
  class ResNet (line 78) | class ResNet(nn.Module):
    method __init__ (line 80) | def __init__(self, block, blocks_num, num_classes=1000, include_top=Tr...
    method _make_layer (line 102) | def _make_layer(self, block, channel, block_num, stride=1):
    method forward (line 118) | def forward(self, x):
  function resnet34 (line 137) | def resnet34(num_classes=1000, include_top=True):
  function resnet101 (line 141) | def resnet101(num_classes=1000, include_top=True):

FILE: others_project/draw_dilated_conv/main.py
  function dilated_conv_one_pixel (line 6) | def dilated_conv_one_pixel(center: (int, int),
  function dilated_conv_all_map (line 30) | def dilated_conv_all_map(dilated_map: np.ndarray,
  function plot_map (line 50) | def plot_map(matrix: np.ndarray):
  function main (line 79) | def main():

FILE: others_project/kmeans_anchors/main.py
  function anchor_fitness (line 10) | def anchor_fitness(k: np.ndarray, wh: np.ndarray, thr: float):  # mutati...
  function main (line 20) | def main(img_size=512, n=9, thr=0.25, gen=1000):

FILE: others_project/kmeans_anchors/plot_kmeans.py
  function plot_clusters (line 8) | def plot_clusters(data, cls, clusters, title=""):
  function distances (line 22) | def distances(data, clusters):
  function k_means (line 29) | def k_means(data, k, dist=np.mean):
  function main (line 65) | def main():

FILE: others_project/kmeans_anchors/read_voc.py
  class VOCDataSet (line 6) | class VOCDataSet(object):
    method __init__ (line 7) | def __init__(self, voc_root, year="2012", txt_name: str = "train.txt"):
    method __len__ (line 25) | def __len__(self):
    method parse_xml_to_dict (line 28) | def parse_xml_to_dict(self, xml):
    method get_info (line 52) | def get_info(self):

FILE: others_project/kmeans_anchors/yolo_kmeans.py
  function wh_iou (line 4) | def wh_iou(wh1, wh2):
  function k_means (line 12) | def k_means(boxes, k, dist=np.median):

FILE: others_project/openvinotest/openvino_cls_test/float32vsint8.py
  function check_path_exist (line 12) | def check_path_exist(path):
  function to_numpy (line 16) | def to_numpy(tensor):
  function openvino_model_speed (line 20) | def openvino_model_speed(data_loader, val_num, xml_path, bin_path):
  function main (line 74) | def main():

FILE: others_project/openvinotest/openvino_cls_test/main.py
  function main (line 11) | def main():

FILE: others_project/openvinotest/openvino_cls_test/model.py
  class BasicBlock (line 5) | class BasicBlock(nn.Module):
    method __init__ (line 8) | def __init__(self, in_channel, out_channel, stride=1, downsample=None):
    method forward (line 19) | def forward(self, x):
  class Bottleneck (line 37) | class Bottleneck(nn.Module):
    method __init__ (line 40) | def __init__(self, in_channel, out_channel, stride=1, downsample=None):
    method forward (line 56) | def forward(self, x):
  class ResNet (line 78) | class ResNet(nn.Module):
    method __init__ (line 80) | def __init__(self, block, blocks_num, num_classes=1000, include_top=Tr...
    method _make_layer (line 102) | def _make_layer(self, block, channel, block_num, stride=1):
    method forward (line 118) | def forward(self, x):
  function resnet34 (line 137) | def resnet34(num_classes=1000, include_top=True):
  function resnet101 (line 141) | def resnet101(num_classes=1000, include_top=True):

FILE: others_project/openvinotest/openvino_cls_test/speed_test.py
  function check_path_exist (line 15) | def check_path_exist(path):
  function to_numpy (line 19) | def to_numpy(tensor):
  function pytorch_model_speed (line 23) | def pytorch_model_speed(data_loader, val_num):
  function onnx_model_speed (line 51) | def onnx_model_speed(data_loader, val_num):
  function openvino_model_speed (line 80) | def openvino_model_speed(data_loader, val_num):
  function main (line 134) | def main():

FILE: others_project/readPbFile/using_function.py
  function filter_low_thresh (line 37) | def filter_low_thresh(boxes, scores, classes, category_index, thresh, bo...
  function draw_text (line 54) | def draw_text(draw, box_to_display_str_map, box, left, right, top, botto...
  function draw_box (line 84) | def draw_box(image, boxes, classes, scores, category_index, thresh=0.5, ...
  function read_pbtxt (line 105) | def read_pbtxt(filename):
  function get_inAndout_tensor (line 117) | def get_inAndout_tensor():
  function convert_type (line 131) | def convert_type(output_dict):
  function read_image (line 139) | def read_image(image_path):

FILE: others_project/textcnnKeras/dataGenerator.py
  function content2idList (line 6) | def content2idList(content, word2id_dict):
  function generatorInfo (line 19) | def generatorInfo(batch_size, seq_length, num_classes, file_name):

FILE: others_project/textcnnKeras/main.py
  function lrSchedule (line 28) | def lrSchedule(epoch):

FILE: others_project/textcnnKeras/models.py
  function text_cnn (line 4) | def text_cnn(seq_length, vocab_size, embedding_dim, num_cla, kernelNum):
  function text_cnn_V2 (line 38) | def text_cnn_V2(seq_length, vocab_size, embedding_dim, num_cla, kernelNu...
  function simpleNet (line 71) | def simpleNet(seq_length, vocab_size, embedding_dim, num_cla, kernelNum=...

FILE: others_project/trans_widerface_to_xml/create_xml.py
  class XMLGenerator (line 6) | class XMLGenerator(object):
    method __init__ (line 7) | def __init__(self, xml_name: str):
    method create_append_node (line 11) | def create_append_node(self, node_name, root_node=None):
    method create_text_node (line 20) | def create_text_node(self, node_name, node_value, root_node):
    method create_object_node (line 30) | def create_object_node(self, info_dict: dict = None, root_node: str = ...
    method save_xml (line 44) | def save_xml(self):
  function create_pascal_voc_xml (line 50) | def create_pascal_voc_xml(filename: str = None,
  function create_xml_test (line 97) | def create_xml_test():

FILE: others_project/trans_widerface_to_xml/main.py
  function create_xml (line 8) | def create_xml(labels: list, img_root: str, img_path: str, save_root: st...
  function parse_wider_txt (line 64) | def parse_wider_txt(data_root: str, split: str, save_root: str):

FILE: pytorch_classification/ConfusionMatrix/main.py
  class ConfusionMatrix (line 14) | class ConfusionMatrix(object):
    method __init__ (line 20) | def __init__(self, num_classes: int, labels: list):
    method update (line 25) | def update(self, preds, labels):
    method summary (line 29) | def summary(self):
    method plot (line 51) | def plot(self):

FILE: pytorch_classification/ConfusionMatrix/model.py
  function _make_divisible (line 5) | def _make_divisible(ch, divisor=8, min_ch=None):
  class ConvBNReLU (line 21) | class ConvBNReLU(nn.Sequential):
    method __init__ (line 22) | def __init__(self, in_channel, out_channel, kernel_size=3, stride=1, g...
  class InvertedResidual (line 31) | class InvertedResidual(nn.Module):
    method __init__ (line 32) | def __init__(self, in_channel, out_channel, stride, expand_ratio):
    method forward (line 51) | def forward(self, x):
  class MobileNetV2 (line 58) | class MobileNetV2(nn.Module):
    method __init__ (line 59) | def __init__(self, num_classes=1000, alpha=1.0, round_nearest=8):
    method forward (line 111) | def forward(self, x):

FILE: pytorch_classification/ConvNeXt/model.py
  function drop_path (line 11) | def drop_path(x, drop_prob: float = 0., training: bool = False):
  class DropPath (line 31) | class DropPath(nn.Module):
    method __init__ (line 34) | def __init__(self, drop_prob=None):
    method forward (line 38) | def forward(self, x):
  class LayerNorm (line 42) | class LayerNorm(nn.Module):
    method __init__ (line 49) | def __init__(self, normalized_shape, eps=1e-6, data_format="channels_l...
    method forward (line 59) | def forward(self, x: torch.Tensor) -> torch.Tensor:
  class Block (line 71) | class Block(nn.Module):
    method __init__ (line 82) | def __init__(self, dim, drop_rate=0., layer_scale_init_value=1e-6):
    method forward (line 93) | def forward(self, x: torch.Tensor) -> torch.Tensor:
  class ConvNeXt (line 109) | class ConvNeXt(nn.Module):
    method __init__ (line 122) | def __init__(self, in_chans: int = 3, num_classes: int = 1000, depths:...
    method _init_weights (line 155) | def _init_weights(self, m):
    method forward_features (line 160) | def forward_features(self, x: torch.Tensor) -> torch.Tensor:
    method forward (line 167) | def forward(self, x: torch.Tensor) -> torch.Tensor:
  function convnext_tiny (line 173) | def convnext_tiny(num_classes: int):
  function convnext_small (line 181) | def convnext_small(num_classes: int):
  function convnext_base (line 189) | def convnext_base(num_classes: int):
  function convnext_large (line 198) | def convnext_large(num_classes: int):
  function convnext_xlarge (line 207) | def convnext_xlarge(num_classes: int):

FILE: pytorch_classification/ConvNeXt/my_dataset.py
  class MyDataSet (line 6) | class MyDataSet(Dataset):
    method __init__ (line 9) | def __init__(self, images_path: list, images_class: list, transform=No...
    method __len__ (line 14) | def __len__(self):
    method __getitem__ (line 17) | def __getitem__(self, item):
    method collate_fn (line 30) | def collate_fn(batch):

FILE: pytorch_classification/ConvNeXt/predict.py
  function main (line 12) | def main():

FILE: pytorch_classification/ConvNeXt/train.py
  function main (line 14) | def main(args):

FILE: pytorch_classification/ConvNeXt/utils.py
  function read_split_data (line 14) | def read_split_data(root: str, val_rate: float = 0.2):
  function plot_data_loader_image (line 83) | def plot_data_loader_image(data_loader):
  function write_pickle (line 108) | def write_pickle(list_info: list, file_name: str):
  function read_pickle (line 113) | def read_pickle(file_name: str) -> list:
  function train_one_epoch (line 119) | def train_one_epoch(model, optimizer, data_loader, device, epoch, lr_sch...
  function evaluate (line 160) | def evaluate(model, data_loader, device, epoch):
  function create_lr_scheduler (line 190) | def create_lr_scheduler(optimizer,
  function get_params_groups (line 219) | def get_params_groups(model: torch.nn.Module, weight_decay: float = 1e-5):

FILE: pytorch_classification/MobileViT/model.py
  function make_divisible (line 17) | def make_divisible(
  class ConvLayer (line 41) | class ConvLayer(nn.Module):
    method __init__ (line 64) | def __init__(
    method forward (line 115) | def forward(self, x: Tensor) -> Tensor:
  class InvertedResidual (line 119) | class InvertedResidual(nn.Module):
    method __init__ (line 139) | def __init__(
    method forward (line 194) | def forward(self, x: Tensor, *args, **kwargs) -> Tensor:
  class MobileViTBlock (line 201) | class MobileViTBlock(nn.Module):
    method __init__ (line 222) | def __init__(
    method unfolding (line 306) | def unfolding(self, x: Tensor) -> Tuple[Tensor, Dict]:
    method folding (line 347) | def folding(self, x: Tensor, info_dict: Dict) -> Tensor:
    method forward (line 378) | def forward(self, x: Tensor) -> Tensor:
  class MobileViT (line 399) | class MobileViT(nn.Module):
    method __init__ (line 403) | def __init__(self, model_cfg: Dict, num_classes: int = 1000):
    method _make_layer (line 439) | def _make_layer(self, input_channel, cfg: Dict) -> Tuple[nn.Sequential...
    method _make_mobilenet_layer (line 447) | def _make_mobilenet_layer(input_channel: int, cfg: Dict) -> Tuple[nn.S...
    method _make_mit_layer (line 468) | def _make_mit_layer(input_channel: int, cfg: Dict) -> [nn.Sequential, ...
    method init_parameters (line 509) | def init_parameters(m):
    method forward (line 528) | def forward(self, x: Tensor) -> Tensor:
  function mobile_vit_xx_small (line 541) | def mobile_vit_xx_small(num_classes: int = 1000):
  function mobile_vit_x_small (line 549) | def mobile_vit_x_small(num_classes: int = 1000):
  function mobile_vit_small (line 557) | def mobile_vit_small(num_classes: int = 1000):

FILE: pytorch_classification/MobileViT/model_config.py
  function get_config (line 1) | def get_config(mode: str = "xxs") -> dict:

FILE: pytorch_classification/MobileViT/my_dataset.py
  class MyDataSet (line 6) | class MyDataSet(Dataset):
    method __init__ (line 9) | def __init__(self, images_path: list, images_class: list, transform=No...
    method __len__ (line 14) | def __len__(self):
    method __getitem__ (line 17) | def __getitem__(self, item):
    method collate_fn (line 30) | def collate_fn(batch):

FILE: pytorch_classification/MobileViT/predict.py
  function main (line 12) | def main():

FILE: pytorch_classification/MobileViT/train.py
  function main (line 14) | def main(args):

FILE: pytorch_classification/MobileViT/transformer.py
  class MultiHeadAttention (line 8) | class MultiHeadAttention(nn.Module):
    method __init__ (line 26) | def __init__(
    method forward (line 54) | def forward(self, x_q: Tensor) -> Tensor:
  class TransformerEncoder (line 90) | class TransformerEncoder(nn.Module):
    method __init__ (line 107) | def __init__(
    method forward (line 147) | def forward(self, x: Tensor) -> Tensor:

FILE: pytorch_classification/MobileViT/unfold_test.py
  function official (line 14) | def official(x: torch.Tensor):
  function my_self (line 29) | def my_self(x: torch.Tensor):

FILE: pytorch_classification/MobileViT/utils.py
  function read_split_data (line 13) | def read_split_data(root: str, val_rate: float = 0.2):
  function plot_data_loader_image (line 82) | def plot_data_loader_image(data_loader):
  function write_pickle (line 107) | def write_pickle(list_info: list, file_name: str):
  function read_pickle (line 112) | def read_pickle(file_name: str) -> list:
  function train_one_epoch (line 118) | def train_one_epoch(model, optimizer, data_loader, device, epoch):
  function evaluate (line 154) | def evaluate(model, data_loader, device, epoch):

FILE: pytorch_classification/Test10_regnet/model.py
  function _make_divisible (line 9) | def _make_divisible(ch, divisor=8, min_ch=None):
  function _mcfg (line 25) | def _mcfg(**kwargs):
  function generate_width_depth (line 59) | def generate_width_depth(wa, w0, wm, depth, q=8):
  function adjust_width_groups_comp (line 73) | def adjust_width_groups_comp(widths: list, groups: list):
  class ConvBNAct (line 81) | class ConvBNAct(nn.Module):
    method __init__ (line 82) | def __init__(self,
    method forward (line 103) | def forward(self, x: Tensor) -> Tensor:
  class RegHead (line 110) | class RegHead(nn.Module):
    method __init__ (line 111) | def __init__(self,
    method forward (line 126) | def forward(self, x: Tensor) -> Tensor:
  class SqueezeExcitation (line 134) | class SqueezeExcitation(nn.Module):
    method __init__ (line 135) | def __init__(self, input_c: int, expand_c: int, se_ratio: float = 0.25):
    method forward (line 143) | def forward(self, x: Tensor) -> Tensor:
  class Bottleneck (line 152) | class Bottleneck(nn.Module):
    method __init__ (line 153) | def __init__(self,
    method zero_init_last_bn (line 188) | def zero_init_last_bn(self):
    method forward (line 191) | def forward(self, x: Tensor) -> Tensor:
  class RegStage (line 208) | class RegStage(nn.Module):
    method __init__ (line 209) | def __init__(self,
    method forward (line 228) | def forward(self, x: Tensor) -> Tensor:
  class RegNet (line 234) | class RegNet(nn.Module):
    method __init__ (line 242) | def __init__(self,
    method forward (line 280) | def forward(self, x: Tensor) -> Tensor:
    method _build_stage_info (line 286) | def _build_stage_info(cfg: dict):
  function create_regnet (line 304) | def create_regnet(model_name="RegNetX_200MF", num_classes=1000):

FILE: pytorch_classification/Test10_regnet/my_dataset.py
  class MyDataSet (line 6) | class MyDataSet(Dataset):
    method __init__ (line 9) | def __init__(self, images_path: list, images_class: list, transform=No...
    method __len__ (line 14) | def __len__(self):
    method __getitem__ (line 17) | def __getitem__(self, item):
    method collate_fn (line 30) | def collate_fn(batch):

FILE: pytorch_classification/Test10_regnet/predict.py
  function main (line 12) | def main():

FILE: pytorch_classification/Test10_regnet/pretrain_weights.py
  function main (line 32) | def main():

FILE: pytorch_classification/Test10_regnet/train.py
  function main (line 16) | def main(args):

FILE: pytorch_classification/Test10_regnet/utils.py
  function read_split_data (line 13) | def read_split_data(root: str, val_rate: float = 0.2):
  function plot_data_loader_image (line 82) | def plot_data_loader_image(data_loader):
  function write_pickle (line 107) | def write_pickle(list_info: list, file_name: str):
  function read_pickle (line 112) | def read_pickle(file_name: str) -> list:
  function train_one_epoch (line 118) | def train_one_epoch(model, optimizer, data_loader, device, epoch):
  function evaluate (line 148) | def evaluate(model, data_loader, device):

FILE: pytorch_classification/Test11_efficientnetV2/model.py
  function drop_path (line 10) | def drop_path(x, drop_prob: float = 0., training: bool = False):
  class DropPath (line 29) | class DropPath(nn.Module):
    method __init__ (line 34) | def __init__(self, drop_prob=None):
    method forward (line 38) | def forward(self, x):
  class ConvBNAct (line 42) | class ConvBNAct(nn.Module):
    method __init__ (line 43) | def __init__(self,
    method forward (line 70) | def forward(self, x):
  class SqueezeExcite (line 78) | class SqueezeExcite(nn.Module):
    method __init__ (line 79) | def __init__(self,
    method forward (line 90) | def forward(self, x: Tensor) -> Tensor:
  class MBConv (line 99) | class MBConv(nn.Module):
    method __init__ (line 100) | def __init__(self,
    method forward (line 153) | def forward(self, x: Tensor) -> Tensor:
  class FusedMBConv (line 167) | class FusedMBConv(nn.Module):
    method __init__ (line 168) | def __init__(self,
    method forward (line 221) | def forward(self, x: Tensor) -> Tensor:
  class EfficientNetV2 (line 237) | class EfficientNetV2(nn.Module):
    method __init__ (line 238) | def __init__(self,
    method forward (line 307) | def forward(self, x: Tensor) -> Tensor:
  function efficientnetv2_s (line 315) | def efficientnetv2_s(num_classes: int = 1000):
  function efficientnetv2_m (line 336) | def efficientnetv2_m(num_classes: int = 1000):
  function efficientnetv2_l (line 358) | def efficientnetv2_l(num_classes: int = 1000):

FILE: pytorch_classification/Test11_efficientnetV2/my_dataset.py
  class MyDataSet (line 6) | class MyDataSet(Dataset):
    method __init__ (line 9) | def __init__(self, images_path: list, images_class: list, transform=No...
    method __len__ (line 14) | def __len__(self):
    method __getitem__ (line 17) | def __getitem__(self, item):
    method collate_fn (line 30) | def collate_fn(batch):

FILE: pytorch_classification/Test11_efficientnetV2/predict.py
  function main (line 12) | def main():

FILE: pytorch_classification/Test11_efficientnetV2/train.py
  function main (line 16) | def main(args):

FILE: pytorch_classification/Test11_efficientnetV2/trans_effv2_weights.py
  function main (line 6) | def main(model_name: str = "efficientnetv2-s",

FILE: pytorch_classification/Test11_efficientnetV2/utils.py
  function read_split_data (line 13) | def read_split_data(root: str, val_rate: float = 0.2):
  function plot_data_loader_image (line 82) | def plot_data_loader_image(data_loader):
  function write_pickle (line 107) | def write_pickle(list_info: list, file_name: str):
  function read_pickle (line 112) | def read_pickle(file_name: str) -> list:
  function train_one_epoch (line 118) | def train_one_epoch(model, optimizer, data_loader, device, epoch):
  function evaluate (line 154) | def evaluate(model, data_loader, device, epoch):

FILE: pytorch_classification/Test1_official_demo/model.py
  class LeNet (line 5) | class LeNet(nn.Module):
    method __init__ (line 6) | def __init__(self):
    method forward (line 16) | def forward(self, x):

FILE: pytorch_classification/Test1_official_demo/predict.py
  function main (line 8) | def main():

FILE: pytorch_classification/Test1_official_demo/train.py
  function main (line 9) | def main():

FILE: pytorch_classification/Test2_alexnet/model.py
  class AlexNet (line 5) | class AlexNet(nn.Module):
    method __init__ (line 6) | def __init__(self, num_classes=1000, init_weights=False):
    method forward (line 35) | def forward(self, x):
    method _initialize_weights (line 41) | def _initialize_weights(self):

FILE: pytorch_classification/Test2_alexnet/predict.py
  function main (line 12) | def main():

FILE: pytorch_classification/Test2_alexnet/train.py
  function main (line 16) | def main():

FILE: pytorch_classification/Test3_vggnet/model.py
  class VGG (line 13) | class VGG(nn.Module):
    method __init__ (line 14) | def __init__(self, features, num_classes=1000, init_weights=False):
    method forward (line 29) | def forward(self, x):
    method _initialize_weights (line 38) | def _initialize_weights(self):
  function make_features (line 51) | def make_features(cfg: list):
  function vgg (line 72) | def vgg(model_name="vgg16", **kwargs):

FILE: pytorch_classification/Test3_vggnet/predict.py
  function main (line 12) | def main():

FILE: pytorch_classification/Test3_vggnet/train.py
  function main (line 14) | def main():

FILE: pytorch_classification/Test4_googlenet/model.py
  class GoogLeNet (line 6) | class GoogLeNet(nn.Module):
    method __init__ (line 7) | def __init__(self, num_classes=1000, aux_logits=True, init_weights=Fal...
    method forward (line 42) | def forward(self, x):
    method _initialize_weights (line 95) | def _initialize_weights(self):
  class Inception (line 106) | class Inception(nn.Module):
    method __init__ (line 107) | def __init__(self, in_channels, ch1x1, ch3x3red, ch3x3, ch5x5red, ch5x...
    method forward (line 129) | def forward(self, x):
  class InceptionAux (line 139) | class InceptionAux(nn.Module):
    method __init__ (line 140) | def __init__(self, in_channels, num_classes):
    method forward (line 148) | def forward(self, x):
  class BasicConv2d (line 165) | class BasicConv2d(nn.Module):
    method __init__ (line 166) | def __init__(self, in_channels, out_channels, **kwargs):
    method forward (line 171) | def forward(self, x):

FILE: pytorch_classification/Test4_googlenet/predict.py
  function main (line 12) | def main():

FILE: pytorch_classification/Test4_googlenet/train.py
  function main (line 14) | def main():

FILE: pytorch_classification/Test5_resnet/batch_predict.py
  function main (line 11) | def main():

FILE: pytorch_classification/Test5_resnet/load_weights.py
  function main (line 7) | def main():

FILE: pytorch_classification/Test5_resnet/model.py
  class BasicBlock (line 5) | class BasicBlock(nn.Module):
    method __init__ (line 8) | def __init__(self, in_channel, out_channel, stride=1, downsample=None,...
    method forward (line 19) | def forward(self, x):
  class Bottleneck (line 37) | class Bottleneck(nn.Module):
    method __init__ (line 46) | def __init__(self, in_channel, out_channel, stride=1, downsample=None,
    method forward (line 66) | def forward(self, x):
  class ResNet (line 88) | class ResNet(nn.Module):
    method __init__ (line 90) | def __init__(self,
    method _make_layer (line 121) | def _make_layer(self, block, channel, block_num, stride=1):
    method forward (line 145) | def forward(self, x):
  function resnet34 (line 164) | def resnet34(num_classes=1000, include_top=True):
  function resnet50 (line 169) | def resnet50(num_classes=1000, include_top=True):
  function resnet101 (line 174) | def resnet101(num_classes=1000, include_top=True):
  function resnext50_32x4d (line 179) | def resnext50_32x4d(num_classes=1000, include_top=True):
  function resnext101_32x8d (line 190) | def resnext101_32x8d(num_classes=1000, include_top=True):

FILE: pytorch_classification/Test5_resnet/predict.py
  function main (line 12) | def main():

FILE: pytorch_classification/Test5_resnet/train.py
  function main (line 14) | def main():

FILE: pytorch_classification/Test6_mobilenet/model_v2.py
  function _make_divisible (line 5) | def _make_divisible(ch, divisor=8, min_ch=None):
  class ConvBNReLU (line 21) | class ConvBNReLU(nn.Sequential):
    method __init__ (line 22) | def __init__(self, in_channel, out_channel, kernel_size=3, stride=1, g...
  class InvertedResidual (line 31) | class InvertedResidual(nn.Module):
    method __init__ (line 32) | def __init__(self, in_channel, out_channel, stride, expand_ratio):
    method forward (line 51) | def forward(self, x):
  class MobileNetV2 (line 58) | class MobileNetV2(nn.Module):
    method __init__ (line 59) | def __init__(self, num_classes=1000, alpha=1.0, round_nearest=8):
    method forward (line 111) | def forward(self, x):

FILE: pytorch_classification/Test6_mobilenet/model_v3.py
  function _make_divisible (line 9) | def _make_divisible(ch, divisor=8, min_ch=None):
  class ConvBNActivation (line 25) | class ConvBNActivation(nn.Sequential):
    method __init__ (line 26) | def __init__(self,
  class SqueezeExcitation (line 50) | class SqueezeExcitation(nn.Module):
    method __init__ (line 51) | def __init__(self, input_c: int, squeeze_factor: int = 4):
    method forward (line 57) | def forward(self, x: Tensor) -> Tensor:
  class InvertedResidualConfig (line 66) | class InvertedResidualConfig:
    method __init__ (line 67) | def __init__(self,
    method adjust_channels (line 85) | def adjust_channels(channels: int, width_multi: float):
  class InvertedResidual (line 89) | class InvertedResidual(nn.Module):
    method __init__ (line 90) | def __init__(self,
    method forward (line 134) | def forward(self, x: Tensor) -> Tensor:
  class MobileNetV3 (line 142) | class MobileNetV3(nn.Module):
    method __init__ (line 143) | def __init__(self,
    method _forward_impl (line 205) | def _forward_impl(self, x: Tensor) -> Tensor:
    method forward (line 213) | def forward(self, x: Tensor) -> Tensor:
  function mobilenet_v3_large (line 217) | def mobilenet_v3_large(num_classes: int = 1000,
  function mobilenet_v3_small (line 263) | def mobilenet_v3_small(num_classes: int = 1000,

FILE: pytorch_classification/Test6_mobilenet/predict.py
  function main (line 12) | def main():

FILE: pytorch_classification/Test6_mobilenet/train.py
  function main (line 14) | def main():

FILE: pytorch_classification/Test7_shufflenet/model.py
  function channel_shuffle (line 8) | def channel_shuffle(x: Tensor, groups: int) -> Tensor:
  class InvertedResidual (line 25) | class InvertedResidual(nn.Module):
    method __init__ (line 26) | def __init__(self, input_c: int, output_c: int, stride: int):
    method depthwise_conv (line 63) | def depthwise_conv(input_c: int,
    method forward (line 72) | def forward(self, x: Tensor) -> Tensor:
  class ShuffleNetV2 (line 84) | class ShuffleNetV2(nn.Module):
    method __init__ (line 85) | def __init__(self,
    method _forward_impl (line 134) | def _forward_impl(self, x: Tensor) -> Tensor:
    method forward (line 146) | def forward(self, x: Tensor) -> Tensor:
  function shufflenet_v2_x0_5 (line 150) | def shufflenet_v2_x0_5(num_classes=1000):
  function shufflenet_v2_x1_0 (line 167) | def shufflenet_v2_x1_0(num_classes=1000):
  function shufflenet_v2_x1_5 (line 184) | def shufflenet_v2_x1_5(num_classes=1000):
  function shufflenet_v2_x2_0 (line 201) | def shufflenet_v2_x2_0(num_classes=1000):

FILE: pytorch_classification/Test7_shufflenet/my_dataset.py
  class MyDataSet (line 6) | class MyDataSet(Dataset):
    method __init__ (line 9) | def __init__(self, images_path: list, images_class: list, transform=No...
    method __len__ (line 14) | def __len__(self):
    method __getitem__ (line 17) | def __getitem__(self, item):
    method collate_fn (line 30) | def collate_fn(batch):

FILE: pytorch_classification/Test7_shufflenet/predict.py
  function main (line 12) | def main():

FILE: pytorch_classification/Test7_shufflenet/train.py
  function main (line 16) | def main(args):

FILE: pytorch_classification/Test7_shufflenet/utils.py
  function read_split_data (line 13) | def read_split_data(root: str, val_rate: float = 0.2):
  function plot_data_loader_image (line 82) | def plot_data_loader_image(data_loader):
  function write_pickle (line 107) | def write_pickle(list_info: list, file_name: str):
  function read_pickle (line 112) | def read_pickle(file_name: str) -> list:
  function train_one_epoch (line 118) | def train_one_epoch(model, optimizer, data_loader, device, epoch):
  function evaluate (line 148) | def evaluate(model, data_loader, device):

FILE: pytorch_classification/Test8_densenet/model.py
  class _DenseLayer (line 12) | class _DenseLayer(nn.Module):
    method __init__ (line 13) | def __init__(self,
    method bn_function (line 39) | def bn_function(self, inputs: List[Tensor]) -> Tensor:
    method any_requires_grad (line 45) | def any_requires_grad(inputs: List[Tensor]) -> bool:
    method call_checkpoint_bottleneck (line 53) | def call_checkpoint_bottleneck(self, inputs: List[Tensor]) -> Tensor:
    method forward (line 59) | def forward(self, inputs: Tensor) -> Tensor:
  class _DenseBlock (line 82) | class _DenseBlock(nn.ModuleDict):
    method __init__ (line 85) | def __init__(self,
    method forward (line 101) | def forward(self, init_features: Tensor) -> Tensor:
  class _Transition (line 109) | class _Transition(nn.Sequential):
    method __init__ (line 110) | def __init__(self,
  class DenseNet (line 124) | class DenseNet(nn.Module):
    method __init__ (line 139) | def __init__(self,
    method forward (line 191) | def forward(self, x: Tensor) -> Tensor:
  function densenet121 (line 200) | def densenet121(**kwargs: Any) -> DenseNet:
  function densenet169 (line 209) | def densenet169(**kwargs: Any) -> DenseNet:
  function densenet201 (line 218) | def densenet201(**kwargs: Any) -> DenseNet:
  function densenet161 (line 227) | def densenet161(**kwargs: Any) -> DenseNet:
  function load_state_dict (line 236) | def load_state_dict(model: nn.Module, weights_path: str) -> None:

FILE: pytorch_classification/Test8_densenet/my_dataset.py
  class MyDataSet (line 6) | class MyDataSet(Dataset):
    method __init__ (line 9) | def __init__(self, images_path: list, images_class: list, transform=No...
    method __len__ (line 14) | def __len__(self):
    method __getitem__ (line 17) | def __getitem__(self, item):
    method collate_fn (line 30) | def collate_fn(batch):

FILE: pytorch_classification/Test8_densenet/predict.py
  function main (line 12) | def main():

FILE: pytorch_classification/Test8_densenet/train.py
  function main (line 16) | def main(args):

FILE: pytorch_classification/Test8_densenet/utils.py
  function read_split_data (line 13) | def read_split_data(root: str, val_rate: float = 0.2):
  function plot_data_loader_image (line 82) | def plot_data_loader_image(data_loader):
  function write_pickle (line 107) | def write_pickle(list_info: list, file_name: str):
  function read_pickle (line 112) | def read_pickle(file_name: str) -> list:
  function train_one_epoch (line 118) | def train_one_epoch(model, optimizer, data_loader, device, epoch):
  function evaluate (line 148) | def evaluate(model, data_loader, device):

FILE: pytorch_classification/Test9_efficientNet/model.py
  function _make_divisible (line 13) | def _make_divisible(ch, divisor=8, min_ch=None):
  function drop_path (line 29) | def drop_path(x, drop_prob: float = 0., training: bool = False):
  class DropPath (line 48) | class DropPath(nn.Module):
    method __init__ (line 53) | def __init__(self, drop_prob=None):
    method forward (line 57) | def forward(self, x):
  class ConvBNActivation (line 61) | class ConvBNActivation(nn.Sequential):
    method __init__ (line 62) | def __init__(self,
  class SqueezeExcitation (line 87) | class SqueezeExcitation(nn.Module):
    method __init__ (line 88) | def __init__(self,
    method forward (line 99) | def forward(self, x: Tensor) -> Tensor:
  class InvertedResidualConfig (line 108) | class InvertedResidualConfig:
    method __init__ (line 110) | def __init__(self,
    method adjust_channels (line 130) | def adjust_channels(channels: int, width_coefficient: float):
  class InvertedResidual (line 134) | class InvertedResidual(nn.Module):
    method __init__ (line 135) | def __init__(self,
    method forward (line 186) | def forward(self, x: Tensor) -> Tensor:
  class EfficientNet (line 195) | class EfficientNet(nn.Module):
    method __init__ (line 196) | def __init__(self,
    method _forward_impl (line 293) | def _forward_impl(self, x: Tensor) -> Tensor:
    method forward (line 301) | def forward(self, x: Tensor) -> Tensor:
  function efficientnet_b0 (line 305) | def efficientnet_b0(num_classes=1000):
  function efficientnet_b1 (line 313) | def efficientnet_b1(num_classes=1000):
  function efficientnet_b2 (line 321) | def efficientnet_b2(num_classes=1000):
  function efficientnet_b3 (line 329) | def efficientnet_b3(num_classes=1000):
  function efficientnet_b4 (line 337) | def efficientnet_b4(num_classes=1000):
  function efficientnet_b5 (line 345) | def efficientnet_b5(num_classes=1000):
  function efficientnet_b6 (line 353) | def efficientnet_b6(num_classes=1000):
  function efficientnet_b7 (line 361) | def efficientnet_b7(num_classes=1000):

FILE: pytorch_classification/Test9_efficientNet/my_dataset.py
  class MyDataSet (line 6) | class MyDataSet(Dataset):
    method __init__ (line 9) | def __init__(self, images_path: list, images_class: list, transform=No...
    method __len__ (line 14) | def __len__(self):
    method __getitem__ (line 17) | def __getitem__(self, item):
    method collate_fn (line 30) | def collate_fn(batch):

FILE: pytorch_classification/Test9_efficientNet/predict.py
  function main (line 12) | def main():

FILE: pytorch_classification/Test9_efficientNet/train.py
  function main (line 16) | def main(args):

FILE: pytorch_classification/Test9_efficientNet/trans_weights_to_pytorch.py
  function main (line 8) | def main():

FILE: pytorch_classification/Test9_efficientNet/utils.py
  function read_split_data (line 13) | def read_split_data(root: str, val_rate: float = 0.2):
  function plot_data_loader_image (line 82) | def plot_data_loader_image(data_loader):
  function write_pickle (line 107) | def write_pickle(list_info: list, file_name: str):
  function read_pickle (line 112) | def read_pickle(file_name: str) -> list:
  function train_one_epoch (line 118) | def train_one_epoch(model, optimizer, data_loader, device, epoch):
  function evaluate (line 148) | def evaluate(model, data_loader, device):

FILE: pytorch_classification/analyze_weights_featuremap/alexnet_model.py
  class AlexNet (line 5) | class AlexNet(nn.Module):
    method __init__ (line 6) | def __init__(self, num_classes=1000, init_weights=False):
    method forward (line 35) | def forward(self, x):
    method _initialize_weights (line 44) | def _initialize_weights(self):

FILE: pytorch_classification/analyze_weights_featuremap/resnet_model.py
  class BasicBlock (line 5) | class BasicBlock(nn.Module):
    method __init__ (line 8) | def __init__(self, in_channel, out_channel, stride=1, downsample=None):
    method forward (line 19) | def forward(self, x):
  class Bottleneck (line 37) | class Bottleneck(nn.Module):
    method __init__ (line 40) | def __init__(self, in_channel, out_channel, stride=1, downsample=None):
    method forward (line 56) | def forward(self, x):
  class ResNet (line 78) | class ResNet(nn.Module):
    method __init__ (line 80) | def __init__(self, block, blocks_num, num_classes=1000, include_top=Tr...
    method _make_layer (line 102) | def _make_layer(self, block, channel, block_num, stride=1):
    method forward (line 118) | def forward(self, x):
  function resnet34 (line 140) | def resnet34(num_classes=1000, include_top=True):
  function resnet101 (line 144) | def resnet101(num_classes=1000, include_top=True):

FILE: pytorch_classification/custom_dataset/main.py
  function main (line 13) | def main():

FILE: pytorch_classification/custom_dataset/my_dataset.py
  class MyDataSet (line 6) | class MyDataSet(Dataset):
    method __init__ (line 9) | def __init__(self, images_path: list, images_class: list, transform=No...
    method __len__ (line 14) | def __len__(self):
    method __getitem__ (line 17) | def __getitem__(self, item):
    method collate_fn (line 30) | def collate_fn(batch):

FILE: pytorch_classification/custom_dataset/utils.py
  function read_split_data (line 9) | def read_split_data(root: str, val_rate: float = 0.2):
  function plot_data_loader_image (line 74) | def plot_data_loader_image(data_loader):
  function write_pickle (line 99) | def write_pickle(list_info: list, file_name: str):
  function read_pickle (line 104) | def read_pickle(file_name: str) -> list:

FILE: pytorch_classification/grad_cam/main_cnn.py
  function main (line 11) | def main():

FILE: pytorch_classification/grad_cam/main_swin.py
  class ResizeTransform (line 12) | class ResizeTransform:
    method __init__ (line 13) | def __init__(self, im_h: int, im_w: int):
    method feature_size (line 18) | def feature_size(s):
    method __call__ (line 25) | def __call__(self, x):
  function main (line 39) | def main():

FILE: pytorch_classification/grad_cam/main_vit.py
  class ReshapeTransform (line 11) | class ReshapeTransform:
    method __init__ (line 12) | def __init__(self, model):
    method __call__ (line 18) | def __call__(self, x):
  function main (line 33) | def main():

FILE: pytorch_classification/grad_cam/swin_model.py
  function drop_path_f (line 17) | def drop_path_f(x, drop_prob: float = 0., training: bool = False):
  class DropPath (line 37) | class DropPath(nn.Module):
    method __init__ (line 40) | def __init__(self, drop_prob=None):
    method forward (line 44) | def forward(self, x):
  function window_partition (line 48) | def window_partition(x, window_size: int):
  function window_reverse (line 66) | def window_reverse(windows, window_size: int, H: int, W: int):
  class PatchEmbed (line 87) | class PatchEmbed(nn.Module):
    method __init__ (line 91) | def __init__(self, patch_size=4, in_c=3, embed_dim=96, norm_layer=None):
    method forward (line 100) | def forward(self, x):
  class PatchMerging (line 123) | class PatchMerging(nn.Module):
    method __init__ (line 131) | def __init__(self, dim, norm_layer=nn.LayerNorm):
    method forward (line 137) | def forward(self, x, H, W):
  class Mlp (line 168) | class Mlp(nn.Module):
    method __init__ (line 171) | def __init__(self, in_features, hidden_features=None, out_features=Non...
    method forward (line 182) | def forward(self, x):
  class WindowAttention (line 191) | class WindowAttention(nn.Module):
    method __init__ (line 204) | def __init__(self, dim, window_size, num_heads, qkv_bias=True, attn_dr...
    method forward (line 239) | def forward(self, x, mask: Optional[torch.Tensor] = None):
  class SwinTransformerBlock (line 287) | class SwinTransformerBlock(nn.Module):
    method __init__ (line 304) | def __init__(self, dim, num_heads, window_size=7, shift_size=0,
    method forward (line 325) | def forward(self, x, attn_mask):
  class BasicLayer (line 379) | class BasicLayer(nn.Module):
    method __init__ (line 398) | def __init__(self, dim, depth, num_heads, window_size,
    method create_mask (line 429) | def create_mask(self, x, H, W):
    method forward (line 455) | def forward(self, x, H, W):
  class SwinTransformer (line 470) | class SwinTransformer(nn.Module):
    method __init__ (line 493) | def __init__(self, patch_size=4, in_chans=3, num_classes=1000,
    method _init_weights (line 543) | def _init_weights(self, m):
    method forward (line 552) | def forward(self, x):
  function swin_tiny_patch4_window7_224 (line 567) | def swin_tiny_patch4_window7_224(num_classes: int = 1000, **kwargs):
  function swin_small_patch4_window7_224 (line 581) | def swin_small_patch4_window7_224(num_classes: int = 1000, **kwargs):
  function swin_base_patch4_window7_224 (line 595) | def swin_base_patch4_window7_224(num_classes: int = 1000, **kwargs):
  function swin_base_patch4_window12_384 (line 609) | def swin_base_patch4_window12_384(num_classes: int = 1000, **kwargs):
  function swin_base_patch4_window7_224_in22k (line 623) | def swin_base_patch4_window7_224_in22k(num_classes: int = 21841, **kwargs):
  function swin_base_patch4_window12_384_in22k (line 637) | def swin_base_patch4_window12_384_in22k(num_classes: int = 21841, **kwar...
  function swin_large_patch4_window7_224_in22k (line 651) | def swin_large_patch4_window7_224_in22k(num_classes: int = 21841, **kwar...
  function swin_large_patch4_window12_384_in22k (line 665) | def swin_large_patch4_window12_384_in22k(num_classes: int = 21841, **kwa...

FILE: pytorch_classification/grad_cam/utils.py
  class ActivationsAndGradients (line 5) | class ActivationsAndGradients:
    method __init__ (line 9) | def __init__(self, model, target_layers, reshape_transform):
    method save_activation (line 29) | def save_activation(self, module, input, output):
    method save_gradient (line 35) | def save_gradient(self, module, grad_input, grad_output):
    method __call__ (line 42) | def __call__(self, x):
    method release (line 47) | def release(self):
  class GradCAM (line 52) | class GradCAM:
    method __init__ (line 53) | def __init__(self,
    method get_cam_weights (line 72) | def get_cam_weights(grads):
    method get_loss (line 76) | def get_loss(output, target_category):
    method get_cam_image (line 82) | def get_cam_image(self, activations, grads):
    method get_target_width_height (line 90) | def get_target_width_height(input_tensor):
    method compute_cam_per_layer (line 94) | def compute_cam_per_layer(self, input_tensor):
    method aggregate_multi_layers (line 112) | def aggregate_multi_layers(self, cam_per_target_layer):
    method scale_cam_image (line 119) | def scale_cam_image(cam, target_size=None):
    method __call__ (line 131) | def __call__(self, input_tensor, target_category=None):
    method __del__ (line 163) | def __del__(self):
    method __enter__ (line 166) | def __enter__(self):
    method __exit__ (line 169) | def __exit__(self, exc_type, exc_value, exc_tb):
  function show_cam_on_image (line 178) | def show_cam_on_image(img: np.ndarray,
  function center_crop_img (line 206) | def center_crop_img(img: np.ndarray, size: int):

FILE: pytorch_classification/grad_cam/vit_model.py
  function drop_path (line 12) | def drop_path(x, drop_prob: float = 0., training: bool = False):
  class DropPath (line 31) | class DropPath(nn.Module):
    method __init__ (line 35) | def __init__(self, drop_prob=None):
    method forward (line 39) | def forward(self, x):
  class PatchEmbed (line 43) | class PatchEmbed(nn.Module):
    method __init__ (line 47) | def __init__(self, img_size=224, patch_size=16, in_c=3, embed_dim=768,...
    method forward (line 59) | def forward(self, x):
  class Attention (line 71) | class Attention(nn.Module):
    method __init__ (line 72) | def __init__(self,
    method forward (line 88) | def forward(self, x):
  class Mlp (line 114) | class Mlp(nn.Module):
    method __init__ (line 118) | def __init__(self, in_features, hidden_features=None, out_features=Non...
    method forward (line 127) | def forward(self, x):
  class Block (line 136) | class Block(nn.Module):
    method __init__ (line 137) | def __init__(self,
    method forward (line 158) | def forward(self, x):
  class VisionTransformer (line 164) | class VisionTransformer(nn.Module):
    method __init__ (line 165) | def __init__(self, img_size=224, patch_size=16, in_c=3, num_classes=1000,
    method forward_features (line 240) | def forward_features(self, x):
    method forward (line 258) | def forward(self, x):
  function _init_vit_weights (line 272) | def _init_vit_weights(m):
  function vit_base_patch16_224 (line 290) | def vit_base_patch16_224(num_classes: int = 1000):
  function vit_base_patch16_224_in21k (line 307) | def vit_base_patch16_224_in21k(num_classes: int = 21843, has_logits: boo...
  function vit_base_patch32_224 (line 324) | def vit_base_patch32_224(num_classes: int = 1000):
  function vit_base_patch32_224_in21k (line 341) | def vit_base_patch32_224_in21k(num_classes: int = 21843, has_logits: boo...
  function vit_large_patch16_224 (line 358) | def vit_large_patch16_224(num_classes: int = 1000):
  function vit_large_patch16_224_in21k (line 375) | def vit_large_patch16_224_in21k(num_classes: int = 21843, has_logits: bo...
  function vit_large_patch32_224_in21k (line 392) | def vit_large_patch32_224_in21k(num_classes: int = 21843, has_logits: bo...
  function vit_huge_patch14_224_in21k (line 409) | def vit_huge_patch14_224_in21k(num_classes: int = 21843, has_logits: boo...

FILE: pytorch_classification/mini_imagenet/model.py
  function channel_shuffle (line 8) | def channel_shuffle(x: Tensor, groups: int) -> Tensor:
  class InvertedResidual (line 25) | class InvertedResidual(nn.Module):
    method __init__ (line 26) | def __init__(self, input_c: int, output_c: int, stride: int):
    method depthwise_conv (line 63) | def depthwise_conv(input_c: int,
    method forward (line 72) | def forward(self, x: Tensor) -> Tensor:
  class ShuffleNetV2 (line 84) | class ShuffleNetV2(nn.Module):
    method __init__ (line 85) | def __init__(self,
    method _forward_impl (line 134) | def _forward_impl(self, x: Tensor) -> Tensor:
    method forward (line 146) | def forward(self, x: Tensor) -> Tensor:
  function shufflenet_v2_x1_0 (line 150) | def shufflenet_v2_x1_0(num_classes=1000):
  function shufflenet_v2_x0_5 (line 167) | def shufflenet_v2_x0_5(num_classes=1000):

FILE: pytorch_classification/mini_imagenet/multi_train_utils/distributed_utils.py
  function init_distributed_mode (line 7) | def init_distributed_mode(args):
  function cleanup (line 31) | def cleanup():
  function is_dist_avail_and_initialized (line 35) | def is_dist_avail_and_initialized():
  function get_world_size (line 44) | def get_world_size():
  function get_rank (line 50) | def get_rank():
  function is_main_process (line 56) | def is_main_process():
  function reduce_value (line 60) | def reduce_value(value, average=True):
  function warmup_lr_scheduler (line 73) | def warmup_lr_scheduler(optimizer, warmup_iters, warmup_factor):

FILE: pytorch_classification/mini_imagenet/multi_train_utils/train_eval_utils.py
  function train_one_epoch (line 9) | def train_one_epoch(model, optimizer, data_loader, device, epoch, use_am...
  function evaluate (line 74) | def evaluate(model, data_loader, device):

FILE: pytorch_classification/mini_imagenet/my_dataset.py
  class MyDataSet (line 9) | class MyDataSet(Dataset):
    method __init__ (line 12) | def __init__(self,
    method __len__ (line 33) | def __len__(self):
    method __getitem__ (line 36) | def __getitem__(self, item):
    method collate_fn (line 49) | def collate_fn(batch):

FILE: pytorch_classification/mini_imagenet/restructure_csv.py
  function read_csv_classes (line 9) | def read_csv_classes(csv_dir: str, csv_name: str):
  function calculate_split_info (line 21) | def calculate_split_info(path: str, label_dict: dict, rate: float = 0.2):
  function main (line 85) | def main():

FILE: pytorch_classification/mini_imagenet/train_multi_gpu_using_launch.py
  function main (line 17) | def main(args):

FILE: pytorch_classification/mini_imagenet/train_single_gpu.py
  function main (line 16) | def main(args):

FILE: pytorch_classification/model_complexity/main.py
  function main (line 7) | def main():

FILE: pytorch_classification/model_complexity/model.py
  function drop_path (line 12) | def drop_path(x, drop_prob: float = 0., training: bool = False):
  class DropPath (line 31) | class DropPath(nn.Module):
    method __init__ (line 36) | def __init__(self, drop_prob=None):
    method forward (line 40) | def forward(self, x):
  class ConvBNAct (line 44) | class ConvBNAct(nn.Module):
    method __init__ (line 45) | def __init__(self,
    method forward (line 72) | def forward(self, x):
    method complexity (line 79) | def complexity(self, cx):
  class SqueezeExcite (line 93) | class SqueezeExcite(nn.Module):
    method __init__ (line 94) | def __init__(self,
    method forward (line 105) | def forward(self, x: Tensor) -> Tensor:
    method complexity (line 113) | def complexity(self, cx):
  class MBConv (line 133) | class MBConv(nn.Module):
    method __init__ (line 134) | def __init__(self,
    method forward (line 187) | def forward(self, x: Tensor) -> Tensor:
    method complexity (line 200) | def complexity(self, cx):
  class FusedMBConv (line 209) | class FusedMBConv(nn.Module):
    method __init__ (line 210) | def __init__(self,
    method forward (line 263) | def forward(self, x: Tensor) -> Tensor:
    method complexity (line 278) | def complexity(self, cx):
  class EfficientNetV2 (line 288) | class EfficientNetV2(nn.Module):
    method __init__ (line 289) | def __init__(self,
    method forward (line 361) | def forward(self, x: Tensor) -> Tensor:
    method complexity (line 368) | def complexity(self, h, w, c):
  function efficientnetv2_s (line 390) | def efficientnetv2_s(num_classes: int = 1000):
  function efficientnetv2_m (line 411) | def efficientnetv2_m(num_classes: int = 1000):
  function efficientnetv2_l (line 433) | def efficientnetv2_l(num_classes: int = 1000):

FILE: pytorch_classification/model_complexity/utils.py
  function conv2d_cx (line 7) | def conv2d_cx(cx, in_c, out_c, k, *, stride=1, groups=1, bias=False, tra...
  function pool2d_cx (line 24) | def pool2d_cx(cx, in_c, k, *, stride=1):
  function norm2d_cx (line 36) | def norm2d_cx(cx, in_c, trainable=True):
  function gap2d_cx (line 47) | def gap2d_cx(cx):
  function linear_cx (line 54) | def linear_cx(cx, in_units, out_units, *, bias=False, trainable=True):

FILE: pytorch_classification/swin_transformer/create_confusion_matrix.py
  class ConfusionMatrix (line 18) | class ConfusionMatrix(object):
    method __init__ (line 24) | def __init__(self, num_classes: int, labels: list):
    method update (line 29) | def update(self, preds, labels):
    method summary (line 33) | def summary(self):
    method plot (line 55) | def plot(self):
  function main (line 84) | def main(args):

FILE: pytorch_classification/swin_transformer/model.py
  function drop_path_f (line 17) | def drop_path_f(x, drop_prob: float = 0., training: bool = False):
  class DropPath (line 37) | class DropPath(nn.Module):
    method __init__ (line 40) | def __init__(self, drop_prob=None):
    method forward (line 44) | def forward(self, x):
  function window_partition (line 48) | def window_partition(x, window_size: int):
  function window_reverse (line 66) | def window_reverse(windows, window_size: int, H: int, W: int):
  class PatchEmbed (line 87) | class PatchEmbed(nn.Module):
    method __init__ (line 91) | def __init__(self, patch_size=4, in_c=3, embed_dim=96, norm_layer=None):
    method forward (line 100) | def forward(self, x):
  class PatchMerging (line 123) | class PatchMerging(nn.Module):
    method __init__ (line 131) | def __init__(self, dim, norm_layer=nn.LayerNorm):
    method forward (line 137) | def forward(self, x, H, W):
  class Mlp (line 168) | class Mlp(nn.Module):
    method __init__ (line 171) | def __init__(self, in_features, hidden_features=None, out_features=Non...
    method forward (line 182) | def forward(self, x):
  class WindowAttention (line 191) | class WindowAttention(nn.Module):
    method __init__ (line 204) | def __init__(self, dim, window_size, num_heads, qkv_bias=True, attn_dr...
    method forward (line 239) | def forward(self, x, mask: Optional[torch.Tensor] = None):
  class SwinTransformerBlock (line 287) | class SwinTransformerBlock(nn.Module):
    method __init__ (line 304) | def __init__(self, dim, num_heads, window_size=7, shift_size=0,
    method forward (line 325) | def forward(self, x, attn_mask):
  class BasicLayer (line 379) | class BasicLayer(nn.Module):
    method __init__ (line 398) | def __init__(self, dim, depth, num_heads, window_size,
    method create_mask (line 429) | def create_mask(self, x, H, W):
    method forward (line 455) | def forward(self, x, H, W):
  class SwinTransformer (line 470) | class SwinTransformer(nn.Module):
    method __init__ (line 493) | def __init__(self, patch_size=4, in_chans=3, num_classes=1000,
    method _init_weights (line 543) | def _init_weights(self, m):
    method forward (line 552) | def forward(self, x):
  function swin_tiny_patch4_window7_224 (line 567) | def swin_tiny_patch4_window7_224(num_classes: int = 1000, **kwargs):
  function swin_small_patch4_window7_224 (line 581) | def swin_small_patch4_window7_224(num_classes: int = 1000, **kwargs):
  function swin_base_patch4_window7_224 (line 595) | def swin_base_patch4_window7_224(num_classes: int = 1000, **kwargs):
  function swin_base_patch4_window12_384 (line 609) | def swin_base_patch4_window12_384(num_classes: int = 1000, **kwargs):
  function swin_base_patch4_window7_224_in22k (line 623) | def swin_base_patch4_window7_224_in22k(num_classes: int = 21841, **kwargs):
  function swin_base_patch4_window12_384_in22k (line 637) | def swin_base_patch4_window12_384_in22k(num_classes: int = 21841, **kwar...
  function swin_large_patch4_window7_224_in22k (line 651) | def swin_large_patch4_window7_224_in22k(num_classes: int = 21841, **kwar...
  function swin_large_patch4_window12_384_in22k (line 665) | def swin_large_patch4_window12_384_in22k(num_classes: int = 21841, **kwa...

FILE: pytorch_classification/swin_transformer/my_dataset.py
  class MyDataSet (line 6) | class MyDataSet(Dataset):
    method __init__ (line 9) | def __init__(self, images_path: list, images_class: list, transform=No...
    method __len__ (line 14) | def __len__(self):
    method __getitem__ (line 17) | def __getitem__(self, item):
    method collate_fn (line 30) | def collate_fn(batch):

FILE: pytorch_classification/swin_transformer/predict.py
  function main (line 12) | def main():

FILE: pytorch_classification/swin_transformer/select_incorrect_samples.py
  function main (line 18) | def main(args):

FILE: pytorch_classification/swin_transformer/train.py
  function main (line 14) | def main(args):

FILE: pytorch_classification/swin_transformer/utils.py
  function read_split_data (line 13) | def read_split_data(root: str, val_rate: float = 0.2):
  function plot_data_loader_image (line 82) | def plot_data_loader_image(data_loader):
  function write_pickle (line 107) | def write_pickle(list_info: list, file_name: str):
  function read_pickle (line 112) | def read_pickle(file_name: str) -> list:
  function train_one_epoch (line 118) | def train_one_epoch(model, optimizer, data_loader, device, epoch):
  function evaluate (line 154) | def evaluate(model, data_loader, device, epoch):

FILE: pytorch_classification/tensorboard_test/data_utils.py
  function read_split_data (line 12) | def read_split_data(root: str, val_rate: float = 0.2):
  function plot_data_loader_image (line 77) | def plot_data_loader_image(data_loader):
  function write_pickle (line 102) | def write_pickle(list_info: list, file_name: str):
  function read_pickle (line 107) | def read_pickle(file_name: str) -> list:
  function plot_class_preds (line 113) | def plot_class_preds(net,

FILE: pytorch_classification/tensorboard_test/model.py
  class BasicBlock (line 5) | class BasicBlock(nn.Module):
    method __init__ (line 8) | def __init__(self, in_channel, out_channel, stride=1, downsample=None):
    method forward (line 19) | def forward(self, x):
  class Bottleneck (line 37) | class Bottleneck(nn.Module):
    method __init__ (line 40) | def __init__(self, in_channel, out_channel, stride=1, downsample=None):
    method forward (line 56) | def forward(self, x):
  class ResNet (line 78) | class ResNet(nn.Module):
    method __init__ (line 80) | def __init__(self, block, blocks_num, num_classes=1000, include_top=Tr...
    method _make_layer (line 102) | def _make_layer(self, block, channel, block_num, stride=1):
    method forward (line 118) | def forward(self, x):
  function resnet34 (line 137) | def resnet34(num_classes=1000, include_top=True):
  function resnet101 (line 141) | def resnet101(num_classes=1000, include_top=True):

FILE: pytorch_classification/tensorboard_test/my_dataset.py
  class MyDataSet (line 7) | class MyDataSet(Dataset):
    method __init__ (line 10) | def __init__(self, images_path: list, images_class: list, transform=No...
    method __len__ (line 28) | def __len__(self):
    method __getitem__ (line 31) | def __getitem__(self, item):
    method collate_fn (line 44) | def collate_fn(batch):

FILE: pytorch_classification/tensorboard_test/train.py
  function main (line 17) | def main(args):

FILE: pytorch_classification/tensorboard_test/train_eval_utils.py
  function train_one_epoch (line 7) | def train_one_epoch(model, optimizer, data_loader, device, epoch):
  function evaluate (line 36) | def evaluate(model, data_loader, device):

FILE: pytorch_classification/train_multi_GPU/model.py
  class BasicBlock (line 5) | class BasicBlock(nn.Module):
    method __init__ (line 8) | def __init__(self, in_channel, out_channel, stride=1, downsample=None):
    method forward (line 19) | def forward(self, x):
  class Bottleneck (line 37) | class Bottleneck(nn.Module):
    method __init__ (line 40) | def __init__(self, in_channel, out_channel, stride=1, downsample=None):
    method forward (line 56) | def forward(self, x):
  class ResNet (line 78) | class ResNet(nn.Module):
    method __init__ (line 80) | def __init__(self, block, blocks_num, num_classes=1000, include_top=Tr...
    method _make_layer (line 102) | def _make_layer(self, block, channel, block_num, stride=1):
    method forward (line 118) | def forward(self, x):
  function resnet34 (line 137) | def resnet34(num_classes=1000, include_top=True):
  function resnet101 (line 141) | def resnet101(num_classes=1000, include_top=True):

FILE: pytorch_classification/train_multi_GPU/multi_train_utils/distributed_utils.py
  function init_distributed_mode (line 7) | def init_distributed_mode(args):
  function cleanup (line 31) | def cleanup():
  function is_dist_avail_and_initialized (line 35) | def is_dist_avail_and_initialized():
  function get_world_size (line 44) | def get_world_size():
  function get_rank (line 50) | def get_rank():
  function is_main_process (line 56) | def is_main_process():
  function reduce_value (line 60) | def reduce_value(value, average=True):

FILE: pytorch_classification/train_multi_GPU/multi_train_utils/train_eval_utils.py
  function train_one_epoch (line 9) | def train_one_epoch(model, optimizer, data_loader, device, epoch):
  function evaluate (line 48) | def evaluate(model, data_loader, device):

FILE: pytorch_classification/train_multi_GPU/my_dataset.py
  class MyDataSet (line 6) | class MyDataSet(Dataset):
    method __init__ (line 9) | def __init__(self, images_path: list, images_class: list, transform=No...
    method __len__ (line 14) | def __len__(self):
    method __getitem__ (line 17) | def __getitem__(self, item):
    method collate_fn (line 30) | def collate_fn(batch):

FILE: pytorch_classification/train_multi_GPU/train_multi_gpu_using_launch.py
  function main (line 19) | def main(args):

FILE: pytorch_classification/train_multi_GPU/train_multi_gpu_using_spawn.py
  function main_fun (line 21) | def main_fun(rank, world_size, args):

FILE: pytorch_classification/train_multi_GPU/train_single_gpu.py
  function main (line 17) | def main(args):

FILE: pytorch_classification/train_multi_GPU/utils.py
  function read_split_data (line 9) | def read_split_data(root: str, val_rate: float = 0.2):
  function plot_data_loader_image (line 78) | def plot_data_loader_image(data_loader):
  function write_pickle (line 103) | def write_pickle(list_info: list, file_name: str):
  function read_pickle (line 108) | def read_pickle(file_name: str) -> list:

FILE: pytorch_classification/vision_transformer/flops.py
  function main (line 7) | def main():

FILE: pytorch_classification/vision_transformer/my_dataset.py
  class MyDataSet (line 6) | class MyDataSet(Dataset):
    method __init__ (line 9) | def __init__(self, images_path: list, images_class: list, transform=No...
    method __len__ (line 14) | def __len__(self):
    method __getitem__ (line 17) | def __getitem__(self, item):
    method collate_fn (line 30) | def collate_fn(batch):

FILE: pytorch_classification/vision_transformer/predict.py
  function main (line 12) | def main():

FILE: pytorch_classification/vision_transformer/train.py
  function main (line 17) | def main(args):

FILE: pytorch_classification/vision_transformer/utils.py
  function read_split_data (line 13) | def read_split_data(root: str, val_rate: float = 0.2):
  function plot_data_loader_image (line 82) | def plot_data_loader_image(data_loader):
  function write_pickle (line 107) | def write_pickle(list_info: list, file_name: str):
  function read_pickle (line 112) | def read_pickle(file_name: str) -> list:
  function train_one_epoch (line 118) | def train_one_epoch(model, optimizer, data_loader, device, epoch):
  function evaluate (line 154) | def evaluate(model, data_loader, device, epoch):

FILE: pytorch_classification/vision_transformer/vit_model.py
  function drop_path (line 12) | def drop_path(x, drop_prob: float = 0., training: bool = False):
  class DropPath (line 31) | class DropPath(nn.Module):
    method __init__ (line 35) | def __init__(self, drop_prob=None):
    method forward (line 39) | def forward(self, x):
  class PatchEmbed (line 43) | class PatchEmbed(nn.Module):
    method __init__ (line 47) | def __init__(self, img_size=224, patch_size=16, in_c=3, embed_dim=768,...
    method forward (line 59) | def forward(self, x):
  class Attention (line 71) | class Attention(nn.Module):
    method __init__ (line 72) | def __init__(self,
    method forward (line 88) | def forward(self, x):
  class Mlp (line 114) | class Mlp(nn.Module):
    method __init__ (line 118) | def __init__(self, in_features, hidden_features=None, out_features=Non...
    method forward (line 127) | def forward(self, x):
  class Block (line 136) | class Block(nn.Module):
    method __init__ (line 137) | def __init__(self,
    method forward (line 158) | def forward(self, x):
  class VisionTransformer (line 164) | class VisionTransformer(nn.Module):
    method __init__ (line 165) | def __init__(self, img_size=224, patch_size=16, in_c=3, num_classes=1000,
    method forward_features (line 240) | def forward_features(self, x):
    method forward (line 258) | def forward(self, x):
  function _init_vit_weights (line 272) | def _init_vit_weights(m):
  function vit_base_patch16_224 (line 290) | def vit_base_patch16_224(num_classes: int = 1000):
  function vit_base_patch16_224_in21k (line 307) | def vit_base_patch16_224_in21k(num_classes: int = 21843, has_logits: boo...
  function vit_base_patch32_224 (line 324) | def vit_base_patch32_224(num_classes: int = 1000):
  function vit_base_patch32_224_in21k (line 341) | def vit_base_patch32_224_in21k(num_classes: int = 21843, has_logits: boo...
  function vit_large_patch16_224 (line 358) | def vit_large_patch16_224(num_classes: int = 1000):
  function vit_large_patch16_224_in21k (line 375) | def vit_large_patch16_224_in21k(num_classes: int = 21843, has_logits: bo...
  function vit_large_patch32_224_in21k (line 392) | def vit_large_patch32_224_in21k(num_classes: int = 21843, has_logits: bo...
  function vit_huge_patch14_224_in21k (line 409) | def vit_huge_patch14_224_in21k(num_classes: int = 21843, has_logits: boo...

FILE: pytorch_keypoint/DeepPose/datasets.py
  class WFLWDataset (line 10) | class WFLWDataset(data.Dataset):
    method __init__ (line 27) | def __init__(self,
    method get_5_points (line 58) | def get_5_points(keypoints: List[str]) -> List[float]:
    method get_98_points (line 67) | def get_98_points(keypoints: List[str]) -> List[float]:
    method collate_fn (line 71) | def collate_fn(batch_infos: List[Tuple[torch.Tensor, dict]]):
    method __getitem__ (line 89) | def __getitem__(self, idx: int):
    method __len__ (line 104) | def __len__(self):

FILE: pytorch_keypoint/DeepPose/export_onnx.py
  function main (line 6) | def main():

FILE: pytorch_keypoint/DeepPose/model.py
  function create_deep_pose_model (line 6) | def create_deep_pose_model(num_keypoints: int) -> nn.Module:

FILE: pytorch_keypoint/DeepPose/predict.py
  function main (line 12) | def main():

FILE: pytorch_keypoint/DeepPose/train.py
  function get_args_parser (line 14) | def get_args_parser(add_help=True):
  function main (line 38) | def main(args):

FILE: pytorch_keypoint/DeepPose/train_multi_GPU.py
  function get_args_parser (line 15) | def get_args_parser(add_help=True):
  function main (line 40) | def main(args):

FILE: pytorch_keypoint/DeepPose/train_utils/distributed_utils.py
  function reduce_value (line 7) | def reduce_value(input_value: torch.Tensor, average=True) -> torch.Tensor:
  function setup_for_distributed (line 27) | def setup_for_distributed(is_master):
  function is_dist_avail_and_initialized (line 42) | def is_dist_avail_and_initialized():
  function get_world_size (line 51) | def get_world_size():
  function get_rank (line 57) | def get_rank():
  function is_main_process (line 63) | def is_main_process():
  function init_distributed_mode (line 67) | def init_distributed_mode(args):

FILE: pytorch_keypoint/DeepPose/train_utils/losses.py
  class L1Loss (line 8) | class L1Loss(nn.Module):
    method __init__ (line 9) | def __init__(self) -> None:
    method forward (line 12) | def forward(self, pred: torch.Tensor, label: torch.Tensor, mask: torch...
  class SmoothL1Loss (line 27) | class SmoothL1Loss(nn.Module):
    method __init__ (line 28) | def __init__(self) -> None:
    method forward (line 31) | def forward(self, pred: torch.Tensor, label: torch.Tensor, mask: torch...
  class L2Loss (line 46) | class L2Loss(nn.Module):
    method __init__ (line 47) | def __init__(self) -> None:
    method forward (line 50) | def forward(self, pred: torch.Tensor, label: torch.Tensor, mask: torch...
  class WingLoss (line 65) | class WingLoss(nn.Module):
    method __init__ (line 68) | def __init__(self, w: float = 10.0, epsilon: float = 2.0) -> None:
    method forward (line 74) | def forward(self,
  class SoftWingLoss (line 97) | class SoftWingLoss(nn.Module):
    method __init__ (line 100) | def __init__(self, omega1: float = 2.0, omega2: float = 20.0, epsilon:...
    method forward (line 107) | def forward(self,

FILE: pytorch_keypoint/DeepPose/train_utils/metrics.py
  class NMEMetric (line 6) | class NMEMetric:
    method __init__ (line 7) | def __init__(self, device: torch.device) -> None:
    method update (line 14) | def update(self, pred: torch.Tensor, gt: torch.Tensor, mask: torch.Ten...
    method evaluate (line 40) | def evaluate(self):
    method synchronize_results (line 43) | def synchronize_results(self):

FILE: pytorch_keypoint/DeepPose/train_utils/train_eval_utils.py
  function train_one_epoch (line 15) | def train_one_epoch(model: torch.nn.Module,
  function evaluate (line 61) | def evaluate(model: torch.nn.Module,

FILE: pytorch_keypoint/DeepPose/transforms.py
  function adjust_box (line 12) | def adjust_box(xmin: int, ymin: int, xmax: int, ymax: int, fixed_size: T...
  function affine_points_np (line 34) | def affine_points_np(keypoint: np.ndarray, m: np.ndarray) -> np.ndarray:
  function affine_points_torch (line 46) | def affine_points_torch(keypoint: torch.Tensor, m: torch.Tensor) -> torc...
  class Compose (line 62) | class Compose(object):
    method __init__ (line 64) | def __init__(self, transforms):
    method __call__ (line 67) | def __call__(self, image, target):
  class Resize (line 73) | class Resize(object):
    method __init__ (line 74) | def __init__(self, h: int, w: int):
    method __call__ (line 78) | def __call__(self, image: np.ndarray, target):
  class ToTensor (line 85) | class ToTensor(object):
    method __call__ (line 87) | def __call__(self, image, target):
  class Normalize (line 98) | class Normalize(object):
    method __init__ (line 99) | def __init__(self, mean=None, std=None):
    method __call__ (line 103) | def __call__(self, image: torch.Tensor, target: dict):
  class RandomHorizontalFlip (line 115) | class RandomHorizontalFlip(object):
    method __init__ (line 117) | def __init__(self, p: float = 0.5):
    method __call__ (line 121) | def __call__(self, image: np.ndarray, target: dict):
  class AffineTransform (line 137) | class AffineTransform(object):
    method __init__ (line 139) | def __init__(self,
    method __call__ (line 155) | def __call__(self, img: np.ndarray, target: dict):

FILE: pytorch_keypoint/DeepPose/utils.py
  function draw_keypoints (line 5) | def draw_keypoints(img: np.ndarray, coordinate: np.ndarray, save_path: s...

FILE: pytorch_keypoint/HRNet/draw_utils.py
  function draw_keypoints (line 29) | def draw_keypoints(img: Image,

FILE: pytorch_keypoint/HRNet/model/hrnet.py
  class BasicBlock (line 6) | class BasicBlock(nn.Module):
    method __init__ (line 9) | def __init__(self, inplanes, planes, stride=1, downsample=None):
    method forward (line 19) | def forward(self, x):
  class Bottleneck (line 38) | class Bottleneck(nn.Module):
    method __init__ (line 41) | def __init__(self, inplanes, planes, stride=1, downsample=None):
    method forward (line 56) | def forward(self, x):
  class StageModule (line 79) | class StageModule(nn.Module):
    method __init__ (line 80) | def __init__(self, input_branches, output_branches, c):
    method forward (line 144) | def forward(self, x):
  class HighResolutionNet (line 160) | class HighResolutionNet(nn.Module):
    method __init__ (line 161) | def __init__(self, base_channel: int = 32, num_joints: int = 17):
    method forward (line 248) | def forward(self, x):

FILE: pytorch_keypoint/HRNet/my_dataset_coco.py
  class CocoKeypoint (line 11) | class CocoKeypoint(data.Dataset):
    method __init__ (line 12) | def __init__(self,
    method __getitem__ (line 84) | def __getitem__(self, idx):
    method __len__ (line 94) | def __len__(self):
    method collate_fn (line 98) | def collate_fn(batch):

FILE: pytorch_keypoint/HRNet/plot_curve.py
  function plot_loss_and_lr (line 5) | def plot_loss_and_lr(train_loss, learning_rate):
  function plot_map (line 33) | def plot_map(mAP):

FILE: pytorch_keypoint/HRNet/predict.py
  function predict_all_person (line 14) | def predict_all_person():
  function predict_single_person (line 19) | def predict_single_person():

FILE: pytorch_keypoint/HRNet/train.py
  function create_model (line 15) | def create_model(num_joints, load_pretrain_weights=True):
  function main (line 40) | def main(args):

FILE: pytorch_keypoint/HRNet/train_multi_GPU.py
  function create_model (line 17) | def create_model(num_joints, load_pretrain_weights=True):
  function main (line 42) | def main(args):

FILE: pytorch_keypoint/HRNet/train_utils/coco_eval.py
  function merge (line 12) | def merge(img_ids, eval_results):
  class EvalCOCOMetric (line 35) | class EvalCOCOMetric:
    method __init__ (line 36) | def __init__(self,
    method plot_img (line 53) | def plot_img(self, img_path, keypoints, r=3):
    method prepare_for_coco_keypoints (line 61) | def prepare_for_coco_keypoints(self, targets, outputs):
    method update (line 95) | def update(self, targets, outputs):
    method synchronize_results (line 101) | def synchronize_results(self):
    method evaluate (line 115) | def evaluate(self):

FILE: pytorch_keypoint/HRNet/train_utils/coco_utils.py
  function coco_remove_images_without_annotations (line 7) | def coco_remove_images_without_annotations(dataset, ids):
  function convert_coco_poly_mask (line 40) | def convert_coco_poly_mask(segmentations, height, width):
  function convert_to_coco_api (line 58) | def convert_to_coco_api(self):

FILE: pytorch_keypoint/HRNet/train_utils/distributed_utils.py
  class SmoothedValue (line 12) | class SmoothedValue(object):
    method __init__ (line 16) | def __init__(self, window_size=20, fmt=None):
    method update (line 24) | def update(self, value, n=1):
    method synchronize_between_processes (line 29) | def synchronize_between_processes(self):
    method median (line 43) | def median(self):  # @property 是装饰器,这里可简单理解为增加median属性(只读)
    method avg (line 48) | def avg(self):
    method global_avg (line 53) | def global_avg(self):
    method max (line 57) | def max(self):
    method value (line 61) | def value(self):
    method __str__ (line 64) | def __str__(self):
  function all_gather (line 73) | def all_gather(data):
  function reduce_dict (line 92) | def reduce_dict(input_dict, average=True):
  class MetricLogger (line 120) | class MetricLogger(object):
    method __init__ (line 121) | def __init__(self, delimiter="\t"):
    method update (line 125) | def update(self, **kwargs):
    method __getattr__ (line 132) | def __getattr__(self, attr):
    method __str__ (line 140) | def __str__(self):
    method synchronize_between_processes (line 148) | def synchronize_between_processes(self):
    method add_meter (line 152) | def add_meter(self, name, meter):
    method log_every (line 155) | def log_every(self, iterable, print_freq, header=None):
  function warmup_lr_scheduler (line 209) | def warmup_lr_scheduler(optimizer, warmup_iters, warmup_factor):
  function mkdir (line 222) | def mkdir(path):
  function setup_for_distributed (line 230) | def setup_for_distributed(is_master):
  function is_dist_avail_and_initialized (line 245) | def is_dist_avail_and_initialized():
  function get_world_size (line 254) | def get_world_size():
  function get_rank (line 260) | def get_rank():
  function is_main_process (line 266) | def is_main_process():
  function save_on_master (line 270) | def save_on_master(*args, **kwargs):
  function init_distributed_mode (line 275) | def init_distributed_mode(args):

FILE: pytorch_keypoint/HRNet/train_utils/group_by_aspect_ratio.py
  function _repeat_to_at_least (line 17) | def _repeat_to_at_least(iterable, n):
  class GroupedBatchSampler (line 23) | class GroupedBatchSampler(BatchSampler):
    method __init__ (line 37) | def __init__(self, sampler, group_ids, batch_size):
    method __iter__ (line 47) | def __iter__(self):
    method __len__ (line 83) | def __len__(self):
  function _compute_aspect_ratios_slow (line 87) | def _compute_aspect_ratios_slow(dataset, indices=None):
  function _compute_aspect_ratios_custom_dataset (line 120) | def _compute_aspect_ratios_custom_dataset(dataset, indices=None):
  function _compute_aspect_ratios_coco_dataset (line 131) | def _compute_aspect_ratios_coco_dataset(dataset, indices=None):
  function _compute_aspect_ratios_voc_dataset (line 142) | def _compute_aspect_ratios_voc_dataset(dataset, indices=None):
  function _compute_aspect_ratios_subset_dataset (line 154) | def _compute_aspect_ratios_subset_dataset(dataset, indices=None):
  function compute_aspect_ratios (line 162) | def compute_aspect_ratios(dataset, indices=None):
  function _quantize (line 179) | def _quantize(x, bins):
  function create_aspect_ratio_groups (line 187) | def create_aspect_ratio_groups(dataset, k=0):

FILE: pytorch_keypoint/HRNet/train_utils/loss.py
  class KpLoss (line 4) | class KpLoss(object):
    method __init__ (line 5) | def __init__(self):
    method __call__ (line 8) | def __call__(self, logits, targets):

FILE: pytorch_keypoint/HRNet/train_utils/train_eval_utils.py
  function train_one_epoch (line 13) | def train_one_epoch(model, optimizer, data_loader, device, epoch,
  function evaluate (line 71) | def evaluate(model, data_loader, device, flip=False, flip_pairs=None):

FILE: pytorch_keypoint/HRNet/transforms.py
  function flip_images (line 12) | def flip_images(img):
  function flip_back (line 18) | def flip_back(output_flipped, matched_parts):
  function get_max_preds (line 30) | def get_max_preds(batch_heatmaps):
  function affine_points (line 56) | def affine_points(pt, t):
  function get_final_preds (line 63) | def get_final_preds(batch_heatmaps: torch.Tensor,
  function decode_keypoints (line 97) | def decode_keypoints(outputs, origin_hw, num_joints: int = 17):
  function resize_pad (line 119) | def resize_pad(img: np.ndarray, size: tuple):
  function adjust_box (line 157) | def adjust_box(xmin: float, ymin: float, w: float, h: float, fixed_size:...
  function scale_box (line 179) | def scale_box(xmin: float, ymin: float, w: float, h: float, scale_ratio:...
  function plot_heatmap (line 188) | def plot_heatmap(image, heatmap, kps, kps_weights):
  class Compose (line 202) | class Compose(object):
    method __init__ (line 204) | def __init__(self, transforms):
    method __call__ (line 207) | def __call__(self, image, target):
  class ToTensor (line 213) | class ToTensor(object):
    method __call__ (line 215) | def __call__(self, image, target):
  class Normalize (line 220) | class Normalize(object):
    method __init__ (line 221) | def __init__(self, mean=None, std=None):
    method __call__ (line 225) | def __call__(self, image, target):
  class HalfBody (line 230) | class HalfBody(object):
    method __init__ (line 231) | def __init__(self, p: float = 0.3, upper_body_ids=None, lower_body_ids...
    method __call__ (line 238) | def __call__(self, image, target):
  class AffineTransform (line 274) | class AffineTransform(object):
    method __init__ (line 276) | def __init__(self,
    method __call__ (line 284) | def __call__(self, img, target):
  class RandomHorizontalFlip (line 339) | class RandomHorizontalFlip(object):
    method __init__ (line 341) | def __init__(self, p: float = 0.5, matched_parts: list = None):
    method __call__ (line 346) | def __call__(self, image, target):
  class KeypointToHeatMap (line 371) | class KeypointToHeatMap(object):
    method __init__ (line 372) | def __init__(self,
    method __call__ (line 393) | def __call__(self, image, target):

FILE: pytorch_keypoint/HRNet/validation.py
  function summarize (line 18) | def summarize(self, catId=None):
  function save_info (line 88) | def save_info(coco_evaluator,
  function main (line 99) | def main(args):

FILE: pytorch_object_detection/faster_rcnn/backbone/feature_pyramid_network.py
  class IntermediateLayerGetter (line 11) | class IntermediateLayerGetter(nn.ModuleDict):
    method __init__ (line 32) | def __init__(self, model, return_layers):
    method forward (line 52) | def forward(self, x):
  class FeaturePyramidNetwork (line 64) | class FeaturePyramidNetwork(nn.Module):
    method __init__ (line 82) | def __init__(self, in_channels_list, out_channels, extra_blocks=None):
    method get_result_from_inner_blocks (line 104) | def get_result_from_inner_blocks(self, x: Tensor, idx: int) -> Tensor:
    method get_result_from_layer_blocks (line 120) | def get_result_from_layer_blocks(self, x: Tensor, idx: int) -> Tensor:
    method forward (line 136) | def forward(self, x: Dict[str, Tensor]) -> Dict[str, Tensor]:
  class LastLevelMaxPool (line 175) | class LastLevelMaxPool(torch.nn.Module):
    method forward (line 180) | def forward(self, x: List[Tensor], y: List[Tensor], names: List[str]) ...
  class BackboneWithFPN (line 186) | class BackboneWithFPN(nn.Module):
    method __init__ (line 206) | def __init__(self,
    method forward (line 232) | def forward(self, x):

FILE: pytorch_object_detection/faster_rcnn/backbone/mobilenetv2_model.py
  function _make_divisible (line 6) | def _make_divisible(ch, divisor=8, min_ch=None):
  class ConvBNReLU (line 22) | class ConvBNReLU(nn.Sequential):
    method __init__ (line 23) | def __init__(self, in_channel, out_channel, kernel_size=3, stride=1, g...
  class InvertedResidual (line 34) | class InvertedResidual(nn.Module):
    method __init__ (line 35) | def __init__(self, in_channel, out_channel, stride, expand_ratio, norm...
    method forward (line 56) | def forward(self, x):
  class MobileNetV2 (line 63) | class MobileNetV2(nn.Module):
    method __init__ (line 64) | def __init__(self, num_classes=1000, alpha=1.0, round_nearest=8, weigh...
    method forward (line 122) | def forward(self, x):

FILE: pytorch_object_detection/faster_rcnn/backbone/resnet50_fpn_model.py
  class Bottleneck (line 10) | class Bottleneck(nn.Module):
    method __init__ (line 13) | def __init__(self, in_channel, out_channel, stride=1, downsample=None,...
    method forward (line 32) | def forward(self, x):
  class ResNet (line 54) | class ResNet(nn.Module):
    method __init__ (line 56) | def __init__(self, block, blocks_num, num_classes=1000, include_top=Tr...
    method _make_layer (line 82) | def _make_layer(self, block, channel, block_num, stride=1):
    method forward (line 100) | def forward(self, x):
  function overwrite_eps (line 119) | def overwrite_eps(model, eps):
  function resnet50_fpn_backbone (line 137) | def resnet50_fpn_backbone(pretrain_path="",

FILE: pytorch_object_detection/faster_rcnn/backbone/vgg_model.py
  class VGG (line 5) | class VGG(nn.Module):
    method __init__ (line 6) | def __init__(self, features, class_num=1000, init_weights=False, weigh...
    method forward (line 24) | def forward(self, x):
    method _initialize_weights (line 33) | def _initialize_weights(self):
  function make_features (line 46) | def make_features(cfg: list):
  function vgg (line 67) | def vgg(model_name="vgg16", weights_path=None):

FILE: pytorch_object_detection/faster_rcnn/change_backbone_with_fpn.py
  function create_model (line 14) | def create_model(num_classes):
  function main (line 68) | def main(args):

FILE: pytorch_object_detection/faster_rcnn/change_backbone_without_fpn.py
  function create_model (line 13) | def create_model(num_classes):
  function main (line 56) | def main(args):

FILE: pytorch_object_detection/faster_rcnn/draw_box_utils.py
  function draw_text (line 34) | def draw_text(draw,
  function draw_masks (line 78) | def draw_masks(image, masks, colors, thresh: float = 0.7, alpha: float =...
  function draw_objs (line 92) | def draw_objs(image: Image,

FILE: pytorch_object_detection/faster_rcnn/my_dataset.py
  class VOCDataSet (line 10) | class VOCDataSet(Dataset):
    method __init__ (line 13) | def __init__(self, voc_root, year="2012", transforms=None, txt_name: s...
    method __len__ (line 59) | def __len__(self):
    method __getitem__ (line 62) | def __getitem__(self, idx):
    method get_height_and_width (line 115) | def get_height_and_width(self, idx):
    method parse_xml_to_dict (line 126) | def parse_xml_to_dict(self, xml):
    method coco_index (line 150) | def coco_index(self, idx):
    method collate_fn (line 199) | def collate_fn(batch):

FILE: pytorch_object_detection/faster_rcnn/network_files/boxes.py
  function nms (line 7) | def nms(boxes, scores, iou_threshold):
  function batched_nms (line 38) | def batched_nms(boxes, scores, idxs, iou_threshold):
  function remove_small_boxes (line 86) | def remove_small_boxes(boxes, min_size):
  function clip_boxes_to_image (line 108) | def clip_boxes_to_image(boxes, size):
  function box_area (line 139) | def box_area(boxes):
  function box_iou (line 154) | def box_iou(boxes1, boxes2):

FILE: pytorch_object_detection/faster_rcnn/network_files/det_utils.py
  class BalancedPositiveNegativeSampler (line 7) | class BalancedPositiveNegativeSampler(object):
    method __init__ (line 12) | def __init__(self, batch_size_per_image, positive_fraction):
    method __call__ (line 22) | def __call__(self, matched_idxs):
  function encode_boxes (line 88) | def encode_boxes(reference_boxes, proposals, weights):
  class BoxCoder (line 140) | class BoxCoder(object):
    method __init__ (line 146) | def __init__(self, weights, bbox_xform_clip=math.log(1000. / 16)):
    method encode (line 156) | def encode(self, reference_boxes, proposals):
    method encode_single (line 177) | def encode_single(self, reference_boxes, proposals):
    method decode (line 193) | def decode(self, rel_codes, boxes):
    method decode_single (line 224) | def decode_single(self, rel_codes, boxes):
  class Matcher (line 270) | class Matcher(object):
    method __init__ (line 279) | def __init__(self, high_threshold, low_threshold, allow_low_quality_ma...
    method __call__ (line 301) | def __call__(self, match_quality_matrix):
    method set_low_quality_matches_ (line 355) | def set_low_quality_matches_(self, matches, all_matches, match_quality...
  function smooth_l1_loss (line 397) | def smooth_l1_loss(input, target, beta: float = 1. / 9, size_average: bo...

FILE: pytorch_object_detection/faster_rcnn/network_files/faster_rcnn_framework.py
  class FasterRCNNBase (line 15) | class FasterRCNNBase(nn.Module):
    method __init__ (line 28) | def __init__(self, backbone, rpn, roi_heads, transform):
    method eager_outputs (line 38) | def eager_outputs(self, losses, detections):
    method forward (line 45) | def forward(self, images, targets=None):
  class TwoMLPHead (line 118) | class TwoMLPHead(nn.Module):
    method __init__ (line 127) | def __init__(self, in_channels, representation_size):
    method forward (line 133) | def forward(self, x):
  class FastRCNNPredictor (line 142) | class FastRCNNPredictor(nn.Module):
    method __init__ (line 152) | def __init__(self, in_channels, num_classes):
    method forward (line 157) | def forward(self, x):
  class FasterRCNN (line 167) | class FasterRCNN(FasterRCNNBase):
    method __init__ (line 247) | def __init__(self, backbone, num_classes=None,

FILE: pytorch_object_detection/faster_rcnn/network_files/image_list.py
  class ImageList (line 5) | class ImageList(object):
    method __init__ (line 13) | def __init__(self, tensors, image_sizes):
    method to (line 23) | def to(self, device):

FILE: pytorch_object_detection/faster_rcnn/network_files/roi_head.py
  function fastrcnn_loss (line 11) | def fastrcnn_loss(class_logits, box_regression, labels, regression_targe...
  class RoIHeads (line 59) | class RoIHeads(torch.nn.Module):
    method __init__ (line 66) | def __init__(self,
    method assign_targets_to_proposals (line 103) | def assign_targets_to_proposals(self, proposals, gt_boxes, gt_labels):
    method subsample (line 158) | def subsample(self, labels):
    method add_gt_proposals (line 171) | def add_gt_proposals(self, proposals, gt_boxes):
    method check_targets (line 188) | def check_targets(self, targets):
    method select_training_samples (line 194) | def select_training_samples(self,
    method postprocess_detections (line 256) | def postprocess_detections(self,
    method forward (line 349) | def forward(self,

FILE: pytorch_object_detection/faster_rcnn/network_files/rpn_function.py
  function _onnx_get_num_anchors_and_pre_nms_top_n (line 14) | def _onnx_get_num_anchors_and_pre_nms_top_n(ob, orig_pre_nms_top_n):
  class AnchorsGenerator (line 25) | class AnchorsGenerator(nn.Module):
    method __init__ (line 51) | def __init__(self, sizes=(128, 256, 512), aspect_ratios=(0.5, 1.0, 2.0)):
    method generate_anchors (line 67) | def generate_anchors(self, scales, aspect_ratios, dtype=torch.float32,...
    method set_cell_anchors (line 93) | def set_cell_anchors(self, dtype, device):
    method num_anchors_per_location (line 111) | def num_anchors_per_location(self):
    method grid_anchors (line 117) | def grid_anchors(self, grid_sizes, strides):
    method cached_grid_anchors (line 161) | def cached_grid_anchors(self, grid_sizes, strides):
    method forward (line 172) | def forward(self, image_list, feature_maps):
  class RPNHead (line 211) | class RPNHead(nn.Module):
    method __init__ (line 221) | def __init__(self, in_channels, num_anchors):
    method forward (line 235) | def forward(self, x):
  function permute_and_flatten (line 246) | def permute_and_flatten(layer, N, A, C, H, W):
  function concat_box_prediction_layers (line 272) | def concat_box_prediction_layers(box_cls, box_regression):
  class RegionProposalNetwork (line 312) | class RegionProposalNetwork(torch.nn.Module):
    method __init__ (line 345) | def __init__(self, anchor_generator, head,
    method pre_nms_top_n (line 375) | def pre_nms_top_n(self):
    method post_nms_top_n (line 380) | def post_nms_top_n(self):
    method assign_targets_to_anchors (line 385) | def assign_targets_to_anchors(self, anchors, targets):
    method _get_top_n_idx (line 439) | def _get_top_n_idx(self, objectness, num_anchors_per_level):
    method filter_proposals (line 465) | def filter_proposals(self, proposals, objectness, image_shapes, num_an...
    method compute_loss (line 536) | def compute_loss(self, objectness, pred_bbox_deltas, labels, regressio...
    method forward (line 580) | def forward(self,

FILE: pytorch_object_detection/faster_rcnn/network_files/transform.py
  function _resize_image_onnx (line 12) | def _resize_image_onnx(image, self_min_size, self_max_size):
  function _resize_image (line 27) | def _resize_image(image, self_min_size, self_max_size):
  class GeneralizedRCNNTransform (line 48) | class GeneralizedRCNNTransform(nn.Module):
    method __init__ (line 60) | def __init__(self, min_size, max_size, image_mean, image_std):
    method normalize (line 69) | def normalize(self, image):
    method torch_choice (line 77) | def torch_choice(self, k):
    method resize (line 87) | def resize(self, image, target):
    method _onnx_batch_images (line 126) | def _onnx_batch_images(self, images, size_divisible=32):
    method max_by_axis (line 148) | def max_by_axis(self, the_list):
    method batch_images (line 156) | def batch_images(self, images, size_divisible=32):
    method postprocess (line 196) | def postprocess(self,
    method __repr__ (line 222) | def __repr__(self):
    method forward (line 232) | def forward(self,
  function resize_boxes (line 264) | def resize_boxes(boxes, original_size, new_size):

FILE: pytorch_object_detection/faster_rcnn/plot_curve.py
  function plot_loss_and_lr (line 5) | def plot_loss_and_lr(train_loss, learning_rate):
  function plot_map (line 33) | def plot_map(mAP):

FILE: pytorch_object_detection/faster_rcnn/predict.py
  function create_model (line 16) | def create_model(num_classes):
  function time_synchronized (line 41) | def time_synchronized():
  function main (line 46) | def main():

FILE: pytorch_object_detection/faster_rcnn/split_data.py
  function main (line 5) | def main():

FILE: pytorch_object_detection/faster_rcnn/train_mobilenetv2.py
  function create_model (line 15) | def create_model(num_classes):
  function main (line 41) | def main():

FILE: pytorch_object_detection/faster_rcnn/train_multi_GPU.py
  function create_model (line 15) | def create_model(num_classes):
  function main (line 38) | def main(args):

FILE: pytorch_object_detection/faster_rcnn/train_res50_fpn.py
  function create_model (line 14) | def create_model(num_classes, load_pretrain_weights=True):
  function main (line 43) | def main(args):

FILE: pytorch_object_detection/faster_rcnn/train_utils/coco_eval.py
  class CocoEvaluator (line 15) | class CocoEvaluator(object):
    method __init__ (line 16) | def __init__(self, coco_gt, iou_types):
    method update (line 29) | def update(self, predictions):
    method synchronize_between_processes (line 44) | def synchronize_between_processes(self):
    method accumulate (line 49) | def accumulate(self):
    method summarize (line 53) | def summarize(self):
    method prepare (line 58) | def prepare(self, predictions, iou_type):
    method prepare_for_coco_detection (line 68) | def prepare_for_coco_detection(self, predictions):
    method prepare_for_coco_segmentation (line 92) | def prepare_for_coco_segmentation(self, predictions):
    method prepare_for_coco_keypoint (line 127) | def prepare_for_coco_keypoint(self, predictions):
  function convert_to_xywh (line 154) | def convert_to_xywh(boxes):
  function merge (line 159) | def merge(img_ids, eval_imgs):
  function create_common_coco_eval (line 181) | def create_common_coco_eval(coco_eval, img_ids, eval_imgs):
  function createIndex (line 199) | def createIndex(self):
  function loadRes (line 234) | def loadRes(self, resFile):
  function evaluate (line 296) | def evaluate(self):

FILE: pytorch_object_detection/faster_rcnn/train_utils/coco_utils.py
  function convert_to_coco_api (line 7) | def convert_to_coco_api(ds):
  function get_coco_api_from_dataset (line 46) | def get_coco_api_from_dataset(dataset):

FILE: pytorch_object_detection/faster_rcnn/train_utils/distributed_utils.py
  class SmoothedValue (line 12) | class SmoothedValue(object):
    method __init__ (line 16) | def __init__(self, window_size=20, fmt=None):
    method update (line 24) | def update(self, value, n=1):
    method synchronize_between_processes (line 29) | def synchronize_between_processes(self):
    method median (line 43) | def median(self):  # @property 是装饰器,这里可简单理解为增加median属性(只读)
    method avg (line 48) | def avg(self):
    method global_avg (line 53) | def global_avg(self):
    method max (line 57) | def max(self):
    method value (line 61) | def value(self):
    method __str__ (line 64) | def __str__(self):
  function all_gather (line 73) | def all_gather(data):
  function reduce_dict (line 116) | def reduce_dict(input_dict, average=True):
  class MetricLogger (line 144) | class MetricLogger(object):
    method __init__ (line 145) | def __init__(self, delimiter="\t"):
    method update (line 149) | def update(self, **kwargs):
    method __getattr__ (line 156) | def __getattr__(self, attr):
    method __str__ (line 164) | def __str__(self):
    method synchronize_between_processes (line 172) | def synchronize_between_processes(self):
    method add_meter (line 176) | def add_meter(self, name, meter):
    method log_every (line 179) | def log_every(self, iterable, print_freq, header=None):
  function warmup_lr_scheduler (line 234) | def warmup_lr_scheduler(optimizer, warmup_iters, warmup_factor):
  function mkdir (line 247) | def mkdir(path):
  function setup_for_distributed (line 255) | def setup_for_distributed(is_master):
  function is_dist_avail_and_initialized (line 270) | def is_dist_avail_and_initialized():
  function get_world_size (line 279) | def get_world_size():
  function get_rank (line 285) | def get_rank():
  function is_main_process (line 291) | def is_main_process():
  function save_on_master (line 295) | def save_on_master(*args, **kwargs):
  function init_distributed_mode (line 300) | def init_distributed_mode(args):

FILE: pytorch_object_detection/faster_rcnn/train_utils/group_by_aspect_ratio.py
  function _repeat_to_at_least (line 17) | def _repeat_to_at_least(iterable, n):
  class GroupedBatchSampler (line 23) | class GroupedBatchSampler(BatchSampler):
    method __init__ (line 37) | def __init__(self, sampler, group_ids, batch_size):
    method __iter__ (line 47) | def __iter__(self):
    method __len__ (line 83) | def __len__(self):
  function _compute_aspect_ratios_slow (line 87) | def _compute_aspect_ratios_slow(dataset, indices=None):
  function _compute_aspect_ratios_custom_dataset (line 120) | def _compute_aspect_ratios_custom_dataset(dataset, indices=None):
  function _compute_aspect_ratios_coco_dataset (line 131) | def _compute_aspect_ratios_coco_dataset(dataset, indices=None):
  function _compute_aspect_ratios_voc_dataset (line 142) | def _compute_aspect_ratios_voc_dataset(dataset, indices=None):
  function _compute_aspect_ratios_subset_dataset (line 154) | def _compute_aspect_ratios_subset_dataset(dataset, indices=None):
  function compute_aspect_ratios (line 162) | def compute_aspect_ratios(dataset, indices=None):
  function _quantize (line 179) | def _quantize(x, bins):
  function create_aspect_ratio_groups (line 187) | def create_aspect_ratio_groups(dataset, k=0):

FILE: pytorch_object_detection/faster_rcnn/train_utils/train_eval_utils.py
  function train_one_epoch (line 12) | def train_one_epoch(model, optimizer, data_loader, device, epoch,
  function evaluate (line 69) | def evaluate(model, data_loader, device):
  function _get_iou_types (line 114) | def _get_iou_types(model):

FILE: pytorch_object_detection/faster_rcnn/transforms.py
  class Compose (line 5) | class Compose(object):
    method __init__ (line 7) | def __init__(self, transforms):
    method __call__ (line 10) | def __call__(self, image, target):
  class ToTensor (line 16) | class ToTensor(object):
    method __call__ (line 18) | def __call__(self, image, target):
  class RandomHorizontalFlip (line 23) | class RandomHorizontalFlip(object):
    method __init__ (line 25) | def __init__(self, prob=0.5):
    method __call__ (line 28) | def __call__(self, image, target):

FILE: pytorch_object_detection/faster_rcnn/validation.py
  function summarize (line 20) | def summarize(self, catId=None):
  function main (line 92) | def main(parser_data):

FILE: pytorch_object_detection/mask_rcnn/backbone/feature_pyramid_network.py
  class IntermediateLayerGetter (line 11) | class IntermediateLayerGetter(nn.ModuleDict):
    method __init__ (line 32) | def __init__(self, model, return_layers):
    method forward (line 52) | def forward(self, x):
  class BackboneWithFPN (line 64) | class BackboneWithFPN(nn.Module):
    method __init__ (line 84) | def __init__(self,
    method forward (line 110) | def forward(self, x):
  class FeaturePyramidNetwork (line 116) | class FeaturePyramidNetwork(nn.Module):
    method __init__ (line 134) | def __init__(self, in_channels_list, out_channels, extra_blocks=None):
    method get_result_from_inner_blocks (line 156) | def get_result_from_inner_blocks(self, x: Tensor, idx: int) -> Tensor:
    method get_result_from_layer_blocks (line 172) | def get_result_from_layer_blocks(self, x: Tensor, idx: int) -> Tensor:
    method forward (line 188) | def forward(self, x: Dict[str, Tensor]) -> Dict[str, Tensor]:
  class LastLevelMaxPool (line 227) | class LastLevelMaxPool(torch.nn.Module):
    method forward (line 232) | def forward(self, x: List[Tensor], y: List[Tensor], names: List[str]) ...

FILE: pytorch_object_detection/mask_rcnn/backbone/resnet50_fpn_model.py
  class Bottleneck (line 10) | class Bottleneck(nn.Module):
    method __init__ (line 13) | def __init__(self, in_channel, out_channel, stride=1, downsample=None,...
    method forward (line 32) | def forward(self, x):
  class ResNet (line 54) | class ResNet(nn.Module):
    method __init__ (line 56) | def __init__(self, block, blocks_num, num_classes=1000, include_top=Tr...
    method _make_layer (line 82) | def _make_layer(self, block, channel, block_num, stride=1):
    method forward (line 100) | def forward(self, x):
  function overwrite_eps (line 119) | def overwrite_eps(model, eps):
  function resnet50_fpn_backbone (line 137) | def resnet50_fpn_backbone(pretrain_path="",

FILE: pytorch_object_detection/mask_rcnn/draw_box_utils.py
  function draw_text (line 34) | def draw_text(draw,
  function draw_masks (line 78) | def draw_masks(image, masks, colors, thresh: float = 0.7, alpha: float =...
  function draw_objs (line 92) | def draw_objs(image: Image,

FILE: pytorch_object_detection/mask_rcnn/my_dataset_coco.py
  class CocoDetection (line 11) | class CocoDetection(data.Dataset):
    method __init__ (line 21) | def __init__(self, root, dataset="train", transforms=None, years="2017"):
    method parse_targets (line 62) | def parse_targets(self,
    method __getitem__ (line 111) | def __getitem__(self, index):
    method __len__ (line 134) | def __len__(self):
    method get_height_and_width (line 137) | def get_height_and_width(self, index):
    method collate_fn (line 147) | def collate_fn(batch):

FILE: pytorch_object_detection/mask_rcnn/my_dataset_voc.py
  class VOCInstances (line 12) | class VOCInstances(Dataset):
    method __init__ (line 13) | def __init__(self, voc_root, year="2012", txt_name: str = "train.txt",...
    method parse_mask (line 85) | def parse_mask(self, idx: int):
    method __getitem__ (line 95) | def __getitem__(self, idx):
    method __len__ (line 113) | def __len__(self):
    method get_height_and_width (line 116) | def get_height_and_width(self, idx):
    method get_annotations (line 124) | def get_annotations(self, idx):
    method collate_fn (line 135) | def collate_fn(batch):
  function parse_xml_to_dict (line 139) | def parse_xml_to_dict(xml):
  function parse_objects (line 164) | def parse_objects(data: dict, xml_path: str, class_dict: dict, idx: int):

FILE: pytorch_object_detection/mask_rcnn/network_files/boxes.py
  function nms (line 7) | def nms(boxes, scores, iou_threshold):
  function batched_nms (line 38) | def batched_nms(boxes, scores, idxs, iou_threshold):
  function remove_small_boxes (line 86) | def remove_small_boxes(boxes, min_size):
  function clip_boxes_to_image (line 108) | def clip_boxes_to_image(boxes, size):
  function box_area (line 139) | def box_area(boxes):
  function box_iou (line 154) | def box_iou(boxes1, boxes2):

FILE: pytorch_object_detection/mask_rcnn/network_files/det_utils.py
  class BalancedPositiveNegativeSampler (line 7) | class BalancedPositiveNegativeSampler(object):
    method __init__ (line 12) | def __init__(self, batch_size_per_image, positive_fraction):
    method __call__ (line 22) | def __call__(self, matched_idxs):
  function encode_boxes (line 88) | def encode_boxes(reference_boxes, proposals, weights):
  class BoxCoder (line 140) | class BoxCoder(object):
    method __init__ (line 146) | def __init__(self, weights, bbox_xform_clip=math.log(1000. / 16)):
    method encode (line 156) | def encode(self, reference_boxes, proposals):
    method encode_single (line 177) | def encode_single(self, reference_boxes, proposals):
    method decode (line 193) | def decode(self, rel_codes, boxes):
    method decode_single (line 224) | def decode_single(self, rel_codes, boxes):
  class Matcher (line 270) | class Matcher(object):
    method __init__ (line 279) | def __init__(self, high_threshold, low_threshold, allow_low_quality_ma...
    method __call__ (line 301) | def __call__(self, match_quality_matrix):
    method set_low_quality_matches_ (line 355) | def set_low_quality_matches_(self, matches, all_matches, match_quality...
  function smooth_l1_loss (line 397) | def smooth_l1_loss(input, target, beta: float = 1. / 9, size_average: bo...

FILE: pytorch_object_detection/mask_rcnn/network_files/faster_rcnn_framework.py
  class FasterRCNNBase (line 15) | class FasterRCNNBase(nn.Module):
    method __init__ (line 28) | def __init__(self, backbone, rpn, roi_heads, transform):
    method eager_outputs (line 38) | def eager_outputs(self, losses, detections):
    method forward (line 45) | def forward(self, images, targets=None):
  class TwoMLPHead (line 117) | class TwoMLPHead(nn.Module):
    method __init__ (line 126) | def __init__(self, in_channels, representation_size):
    method forward (line 132) | def forward(self, x):
  class FastRCNNPredictor (line 141) | class FastRCNNPredictor(nn.Module):
    method __init__ (line 151) | def __init__(self, in_channels, num_classes):
    method forward (line 156) | def forward(self, x):
  class FasterRCNN (line 166) | class FasterRCNN(FasterRCNNBase):
    method __init__ (line 246) | def __init__(self, backbone, num_classes=None,

FILE: pytorch_object_detection/mask_rcnn/network_files/image_list.py
  class ImageList (line 5) | class ImageList(object):
    method __init__ (line 13) | def __init__(self, tensors, image_sizes):
    method to (line 23) | def to(self, device):

FILE: pytorch_object_detection/mask_rcnn/network_files/mask_rcnn.py
  class MaskRCNN (line 8) | class MaskRCNN(FasterRCNN):
    method __init__ (line 97) | def __init__(
  class MaskRCNNHeads (line 201) | class MaskRCNNHeads(nn.Sequential):
    method __init__ (line 202) | def __init__(self, in_channels, layers, dilation):
  class MaskRCNNPredictor (line 229) | class MaskRCNNPredictor(nn.Sequential):
    method __init__ (line 230) | def __init__(self, in_channels, dim_reduced, num_classes):

FILE: pytorch_object_detection/mask_rcnn/network_files/roi_head.py
  function fastrcnn_loss (line 12) | def fastrcnn_loss(class_logits, box_regression, labels, regression_targe...
  function maskrcnn_inference (line 60) | def maskrcnn_inference(x, labels):
  function project_masks_on_boxes (line 95) | def project_masks_on_boxes(gt_masks, boxes, matched_idxs, M):
  function maskrcnn_loss (line 110) | def maskrcnn_loss(mask_logits, proposals, gt_masks, gt_labels, mask_matc...
  class RoIHeads (line 150) | class RoIHeads(torch.nn.Module):
    method __init__ (line 157) | def __init__(self,
    method has_mask (line 203) | def has_mask(self):
    method assign_targets_to_proposals (line 212) | def assign_targets_to_proposals(self, proposals, gt_boxes, gt_labels):
    method subsample (line 267) | def subsample(self, labels):
    method add_gt_proposals (line 280) | def add_gt_proposals(self, proposals, gt_boxes):
    method check_targets (line 297) | def check_targets(self, targets):
    method select_training_samples (line 303) | def select_training_samples(self,
    method postprocess_detections (line 365) | def postprocess_detections(self,
    method forward (line 458) | def forward(self,

FILE: pytorch_object_detection/mask_rcnn/network_files/rpn_function.py
  function _onnx_get_num_anchors_and_pre_nms_top_n (line 14) | def _onnx_get_num_anchors_and_pre_nms_top_n(ob, orig_pre_nms_top_n):
  class AnchorsGenerator (line 25) | class AnchorsGenerator(nn.Module):
    method __init__ (line 51) | def __init__(self, sizes=(128, 256, 512), aspect_ratios=(0.5, 1.0, 2.0)):
    method generate_anchors (line 67) | def generate_anchors(self, scales, aspect_ratios, dtype=torch.float32,...
    method set_cell_anchors (line 93) | def set_cell_anchors(self, dtype, device):
    method num_anchors_per_location (line 111) | def num_anchors_per_location(self):
    method grid_anchors (line 117) | def grid_anchors(self, grid_sizes, strides):
    method cached_grid_anchors (line 161) | def cached_grid_anchors(self, grid_sizes, strides):
    method forward (line 172) | def forward(self, image_list, feature_maps):
  class RPNHead (line 211) | class RPNHead(nn.Module):
    method __init__ (line 221) | def __init__(self, in_channels, num_anchors):
    method forward (line 235) | def forward(self, x):
  function permute_and_flatten (line 246) | def permute_and_flatten(layer, N, A, C, H, W):
  function concat_box_prediction_layers (line 272) | def concat_box_prediction_layers(box_cls, box_regression):
  class RegionProposalNetwork (line 312) | class RegionProposalNetwork(torch.nn.Module):
    method __init__ (line 345) | def __init__(self, anchor_generator, head,
    method pre_nms_top_n (line 375) | def pre_nms_top_n(self):
    method post_nms_top_n (line 380) | def post_nms_top_n(self):
    method assign_targets_to_anchors (line 385) | def assign_targets_to_anchors(self, anchors, targets):
    method _get_top_n_idx (line 433) | def _get_top_n_idx(self, objectness, num_anchors_per_level):
    method filter_proposals (line 459) | def filter_proposals(self, proposals, objectness, image_shapes, num_an...
    method compute_loss (line 530) | def compute_loss(self, objectness, pred_bbox_deltas, labels, regressio...
    method forward (line 574) | def forward(self,

FILE: pytorch_object_detection/mask_rcnn/network_files/transform.py
  function _onnx_paste_mask_in_image (line 12) | def _onnx_paste_mask_in_image(mask, box, im_h, im_w):
  function _onnx_paste_mask_in_image_loop (line 49) | def _onnx_paste_mask_in_image_loop(masks, boxes, im_h, im_w):
  function _get_shape_onnx (line 60) | def _get_shape_onnx(image: Tensor) -> Tensor:
  function _fake_cast_onnx (line 67) | def _fake_cast_onnx(v: Tensor) -> float:
  function _resize_image_and_masks (line 72) | def _resize_image_and_masks(image: Tensor,
  function _onnx_expand_boxes (line 124) | def _onnx_expand_boxes(boxes, scale):
  function expand_boxes (line 145) | def expand_boxes(boxes, scale):
  function expand_masks_tracing_scale (line 166) | def expand_masks_tracing_scale(M, padding):
  function expand_masks (line 171) | def expand_masks(mask, padding):
  function paste_mask_in_image (line 182) | def paste_mask_in_image(mask, box, im_h, im_w):
  function paste_masks_in_image (line 212) | def paste_masks_in_image(masks, boxes, img_shape, padding=1):
  class GeneralizedRCNNTransform (line 233) | class GeneralizedRCNNTransform(nn.Module):
    method __init__ (line 245) | def __init__(self,
    method normalize (line 262) | def normalize(self, image):
    method torch_choice (line 270) | def torch_choice(self, k):
    method resize (line 280) | def resize(self, image, target):
    method _onnx_batch_images (line 316) | def _onnx_batch_images(self, images, size_divisible=32):
    method max_by_axis (line 338) | def max_by_axis(self, the_list):
    method batch_images (line 346) | def batch_images(self, images, size_divisible=32):
    method postprocess (line 386) | def postprocess(self,
    method __repr__ (line 418) | def __repr__(self):
    method forward (line 428) | def forward(self,
  function resize_boxes (line 460) | def resize_boxes(boxes, original_size, new_size):

FILE: pytorch_object_detection/mask_rcnn/plot_curve.py
  function plot_loss_and_lr (line 5) | def plot_loss_and_lr(train_loss, learning_rate):
  function plot_map (line 33) | def plot_map(mAP):

FILE: pytorch_object_detection/mask_rcnn/predict.py
  function create_model (line 16) | def create_model(num_classes, box_thresh=0.5):
  function time_synchronized (line 26) | def time_synchronized():
  function main (line 31) | def main():

FILE: pytorch_object_detection/mask_rcnn/train.py
  function create_model (line 16) | def create_model(num_classes, load_pretrain_weights=True):
  function main (line 39) | def main(args):

FILE: pytorch_object_detection/mask_rcnn/train_multi_GPU.py
  function create_model (line 17) | def create_model(num_classes, load_pretrain_weights=True):
  function main (line 39) | def main(args):

FILE: pytorch_object_detection/mask_rcnn/train_utils/coco_eval.py
  function merge (line 11) | def merge(img_ids, eval_results):
  class EvalCOCOMetric (line 34) | class EvalCOCOMetric:
    method __init__ (line 35) | def __init__(self,
    method prepare_for_coco_detection (line 50) | def prepare_for_coco_detection(self, targets, outputs):
    method prepare_for_coco_segmentation (line 88) | def prepare_for_coco_segmentation(self, targets, outputs):
    method update (line 124) | def update(self, targets, outputs):
    method synchronize_results (line 132) | def synchronize_results(self):
    method evaluate (line 146) | def evaluate(self):

FILE: pytorch_object_detection/mask_rcnn/train_utils/coco_utils.py
  function coco_remove_images_without_annotations (line 7) | def coco_remove_images_without_annotations(dataset, ids):
  function convert_coco_poly_mask (line 40) | def convert_coco_poly_mask(segmentations, height, width):
  function convert_to_coco_api (line 58) | def convert_to_coco_api(self):

FILE: pytorch_object_detection/mask_rcnn/train_utils/distributed_utils.py
  class SmoothedValue (line 12) | class SmoothedValue(object):
    method __init__ (line 16) | def __init__(self, window_size=20, fmt=None):
    method update (line 24) | def update(self, value, n=1):
    method synchronize_between_processes (line 29) | def synchronize_between_processes(self):
    method median (line 43) | def median(self):  # @property 是装饰器,这里可简单理解为增加median属性(只读)
    method avg (line 48) | def avg(self):
    method global_avg (line 53) | def global_avg(self):
    method max (line 57) | def max(self):
    method value (line 61) | def value(self):
    method __str__ (line 64) | def __str__(self):
  function all_gather (line 73) | def all_gather(data):
  function reduce_dict (line 92) | def reduce_dict(input_dict, average=True):
  class MetricLogger (line 120) | class MetricLogger(object):
    method __init__ (line 121) | def __init__(self, delimiter="\t"):
    method update (line 125) | def update(self, **kwargs):
    method __getattr__ (line 132) | def __getattr__(self, attr):
    method __str__ (line 140) | def __str__(self):
    method synchronize_between_processes (line 148) | def synchronize_between_processes(self):
    method add_meter (line 152) | def add_meter(self, name, meter):
    method log_every (line 155) | def log_every(self, iterable, print_freq, header=None):
  function warmup_lr_scheduler (line 210) | def warmup_lr_scheduler(optimizer, warmup_iters, warmup_factor):
  function mkdir (line 223) | def mkdir(path):
  function setup_for_distributed (line 231) | def setup_for_distributed(is_master):
  function is_dist_avail_and_initialized (line 246) | def is_dist_avail_and_initialized():
  function get_world_size (line 255) | def get_world_size():
  function get_rank (line 261) | def get_rank():
  function is_main_process (line 267) | def is_main_process():
  function save_on_master (line 271) | def save_on_master(*args, **kwargs):
  function init_distributed_mode (line 276) | def init_distributed_mode(args):

FILE: pytorch_object_detection/mask_rcnn/train_utils/group_by_aspect_ratio.py
  function _repeat_to_at_least (line 17) | def _repeat_to_at_least(iterable, n):
  class GroupedBatchSampler (line 23) | class GroupedBatchSampler(BatchSampler):
    method __init__ (line 37) | def __init__(self, sampler, group_ids, batch_size):
    method __iter__ (line 47) | def __iter__(self):
    method __len__ (line 83) | def __len__(self):
  function _compute_aspect_ratios_slow (line 87) | def _compute_aspect_ratios_slow(dataset, indices=None):
  function _compute_aspect_ratios_custom_dataset (line 120) | def _compute_aspect_ratios_custom_dataset(dataset, indices=None):
  function _compute_aspect_ratios_coco_dataset (line 131) | def _compute_aspect_ratios_coco_dataset(dataset, indices=None):
  function _compute_aspect_ratios_voc_dataset (line 142) | def _compute_aspect_ratios_voc_dataset(dataset, indices=None):
  function _compute_aspect_ratios_subset_dataset (line 154) | def _compute_aspect_ratios_subset_dataset(dataset, indices=None):
  function compute_aspect_ratios (line 162) | def compute_aspect_ratios(dataset, indices=None):
  function _quantize (line 179) | def _quantize(x, bins):
  function create_aspect_ratio_groups (line 187) | def create_aspect_ratio_groups(dataset, k=0):

FILE: pytorch_object_detection/mask_rcnn/train_utils/train_eval_utils.py
  function train_one_epoch (line 11) | def train_one_epoch(model, optimizer, data_loader, device, epoch,
  function evaluate (line 69) | def evaluate(model, data_loader, device):

FILE: pytorch_object_detection/mask_rcnn/transforms.py
  class Compose (line 5) | class Compose(object):
    method __init__ (line 7) | def __init__(self, transforms):
    method __call__ (line 10) | def __call__(self, image, target):
  class ToTensor (line 16) | class ToTensor(object):
    method __call__ (line 18) | def __call__(self, image, target):
  class RandomHorizontalFlip (line 23) | class RandomHorizontalFlip(object):
    method __init__ (line 25) | def __init__(self, prob=0.5):
    method __call__ (line 28) | def __call__(self, image, target):

FILE: pytorch_object_detection/mask_rcnn/validation.py
  function summarize (line 21) | def summarize(self, catId=None):
  function save_info (line 93) | def save_info(coco_evaluator,
  function main (line 121) | def main(parser_data):

FILE: pytorch_object_detection/retinaNet/backbone/feature_pyramid_network.py
  class IntermediateLayerGetter (line 11) | class IntermediateLayerGetter(nn.ModuleDict):
    method __init__ (line 32) | def __init__(self, model, return_layers):
    method forward (line 52) | def forward(self, x):
  class BackboneWithFPN (line 64) | class BackboneWithFPN(nn.Module):
    method __init__ (line 84) | def __init__(self,
    method forward (line 110) | def forward(self, x):
  class ExtraFPNBlock (line 116) | class ExtraFPNBlock(nn.Module):
    method forward (line 131) | def forward(self,
  class LastLevelMaxPool (line 138) | class LastLevelMaxPool(torch.nn.Module):
    method forward (line 143) | def forward(self, x: List[Tensor], y: List[Tensor], names: List[str]) ...
  class LastLevelP6P7 (line 149) | class LastLevelP6P7(ExtraFPNBlock):
    method __init__ (line 153) | def __init__(self, in_channels: int, out_channels: int):
    method forward (line 162) | def forward(self,
  class FeaturePyramidNetwork (line 175) | class FeaturePyramidNetwork(nn.Module):
    method __init__ (line 193) | def __init__(self, in_channels_list, out_channels, extra_blocks=None):
    method get_result_from_inner_blocks (line 215) | def get_result_from_inner_blocks(self, x: Tensor, idx: int) -> Tensor:
    method get_result_from_layer_blocks (line 231) | def get_result_from_layer_blocks(self, x: Tensor, idx: int) -> Tensor:
    method forward (line 247) | def forward(self, x: Dict[str, Tensor]) -> Dict[str, Tensor]:

FILE: pytorch_object_detection/retinaNet/backbone/resnet50_fpn_model.py
  class Bottleneck (line 10) | class Bottleneck(nn.Module):
    method __init__ (line 13) | def __init__(self, in_channel, out_channel, stride=1, downsample=None,...
    method forward (line 32) | def forward(self, x):
  class ResNet (line 54) | class ResNet(nn.Module):
    method __init__ (line 56) | def __init__(self, block, blocks_num, num_classes=1000, include_top=Tr...
    method _make_layer (line 82) | def _make_layer(self, block, channel, block_num, stride=1):
    method forward (line 100) | def forward(self, x):
  function overwrite_eps (line 119) | def overwrite_eps(model, eps):
  function resnet50_fpn_backbone (line 137) | def resnet50_fpn_backbone(pretrain_path="",

FILE: pytorch_object_detection/retinaNet/draw_box_utils.py
  function draw_text (line 34) | def draw_text(draw,
  function draw_masks (line 78) | def draw_masks(image, masks, colors, thresh: float = 0.7, alpha: float =...
  function draw_objs (line 92) | def draw_objs(image: Image,

FILE: pytorch_object_detection/retinaNet/my_dataset.py
  class VOCDataSet (line 9) | class VOCDataSet(Dataset):
    method __init__ (line 12) | def __init__(self, voc_root, year="2012", transforms=None, txt_name: s...
    method __len__ (line 43) | def __len__(self):
    method __getitem__ (line 46) | def __getitem__(self, idx):
    method get_height_and_width (line 93) | def get_height_and_width(self, idx):
    method parse_xml_to_dict (line 104) | def parse_xml_to_dict(self, xml):
    method coco_index (line 128) | def coco_index(self, idx):
    method collate_fn (line 183) | def collate_fn(batch):

FILE: pytorch_object_detection/retinaNet/network_files/anchor_utils.py
  class AnchorsGenerator (line 9) | class AnchorsGenerator(nn.Module):
    method __init__ (line 35) | def __init__(self, sizes=(128, 256, 512), aspect_ratios=(0.5, 1.0, 2.0)):
    method generate_anchors (line 51) | def generate_anchors(self, scales, aspect_ratios, dtype=torch.float32,...
    method set_cell_anchors (line 77) | def set_cell_anchors(self, dtype, device):
    method num_anchors_per_location (line 95) | def num_anchors_per_location(self):
    method grid_anchors (line 101) | def grid_anchors(self, grid_sizes, strides):
    method cached_grid_anchors (line 145) | def cached_grid_anchors(self, grid_sizes, strides):
    method forward (line 156) | def forward(self, image_list, feature_maps):

FILE: pytorch_object_detection/retinaNet/network_files/boxes.py
  function nms (line 7) | def nms(boxes, scores, iou_threshold):
  function batched_nms (line 38) | def batched_nms(boxes, scores, idxs, iou_threshold):
  function remove_small_boxes (line 86) | def remove_small_boxes(boxes, min_size):
  function clip_boxes_to_image (line 108) | def clip_boxes_to_image(boxes, size):
  function box_area (line 139) | def box_area(boxes):
  function box_iou (line 154) | def box_iou(boxes1, boxes2):

FILE: pytorch_object_detection/retinaNet/network_files/det_utils.py
  class BalancedPositiveNegativeSampler (line 7) | class BalancedPositiveNegativeSampler(object):
    method __init__ (line 12) | def __init__(self, batch_size_per_image, positive_fraction):
    method __call__ (line 22) | def __call__(self, matched_idxs):
  function encode_boxes (line 88) | def encode_boxes(reference_boxes, proposals, weights):
  class BoxCoder (line 140) | class BoxCoder(object):
    method __init__ (line 146) | def __init__(self, weights, bbox_xform_clip=math.log(1000. / 16)):
    method encode (line 156) | def encode(self, reference_boxes, proposals):
    method encode_single (line 177) | def encode_single(self, reference_boxes, proposals):
    method decode (line 193) | def decode(self, rel_codes, boxes):
    method decode_single (line 223) | def decode_single(self, rel_codes, boxes):
  class Matcher (line 269) | class Matcher(object):
    method __init__ (line 278) | def __init__(self, high_threshold, low_threshold, allow_low_quality_ma...
    method __call__ (line 300) | def __call__(self, match_quality_matrix):
    method set_low_quality_matches_ (line 354) | def set_low_quality_matches_(self, matches, all_matches, match_quality...
  function smooth_l1_loss (line 396) | def smooth_l1_loss(input, target, beta: float = 1. / 9, size_average: bo...

FILE: pytorch_object_detection/retinaNet/network_files/image_list.py
  class ImageList (line 5) | class ImageList(object):
    method __init__ (line 13) | def __init__(self, tensors, image_sizes):
    method to (line 23) | def to(self, device):

FILE: pytorch_object_detection/retinaNet/network_files/losses.py
  function sigmoid_focal_loss (line 5) | def sigmoid_focal_loss(

FILE: pytorch_object_detection/retinaNet/network_files/retinanet.py
  function _sum (line 16) | def _sum(x: List[Tensor]) -> Tensor:
  class RetinaNetClassificationHead (line 23) | class RetinaNetClassificationHead(nn.Module):
    method __init__ (line 33) | def __init__(self, in_channels, num_anchors, num_classes, prior_probab...
    method compute_loss (line 59) | def compute_loss(self,
    method forward (line 92) | def forward(self, x: Tensor) -> Tensor:
  class RetinaNetRegressionHead (line 113) | class RetinaNetRegressionHead(nn.Module):
    method __init__ (line 126) | def __init__(self, in_channels, num_anchors):
    method compute_loss (line 146) | def compute_loss(self,
    method forward (line 177) | def forward(self, x: List[Tensor]) -> Tensor:
  class RetinaNetHead (line 199) | class RetinaNetHead(nn.Module):
    method __init__ (line 209) | def __init__(self, in_channels, num_anchors, num_classes):
    method compute_loss (line 214) | def compute_loss(self,
    method forward (line 224) | def forward(self, x: List[Tensor]) -> Dict[str, Tensor]:
  class RetinaNet (line 231) | class RetinaNet(nn.Module):
    method __init__ (line 289) | def __init__(self, backbone, num_classes,
    method eager_outputs (line 358) | def eager_outputs(self, losses, detections):
    method compute_loss (line 365) | def compute_loss(self, targets, head_outputs, anchors):
    method postprocess_detections (line 378) | def postprocess_detections(self, head_output, anchors, image_shapes):
    method forward (line 440) | def forward(self, images, targets=None):

FILE: pytorch_object_detection/retinaNet/network_files/transform.py
  function _resize_image_onnx (line 12) | def _resize_image_onnx(image, self_min_size, self_max_size):
  function _resize_image (line 27) | def _resize_image(image, self_min_size, self_max_size):
  class GeneralizedRCNNTransform (line 48) | class GeneralizedRCNNTransform(nn.Module):
    method __init__ (line 60) | def __init__(self, min_size, max_size, image_mean, image_std):
    method normalize (line 69) | def normalize(self, image):
    method torch_choice (line 77) | def torch_choice(self, k):
    method resize (line 87) | def resize(self, image, target):
    method _onnx_batch_images (line 126) | def _onnx_batch_images(self, images, size_divisible=32):
    method max_by_axis (line 148) | def max_by_axis(self, the_list):
    method batch_images (line 156) | def batch_images(self, images, size_divisible=32):
    method postprocess (line 196) | def postprocess(self,
    method __repr__ (line 222) | def __repr__(self):
    method forward (line 232) | def forward(self,
  function resize_boxes (line 264) | def resize_boxes(boxes, original_size, new_size):

FILE: pytorch_object_detection/retinaNet/plot_curve.py
  function plot_loss_and_lr (line 5) | def plot_loss_and_lr(train_loss, learning_rate):
  function plot_map (line 33) | def plot_map(mAP):

FILE: pytorch_object_detection/retinaNet/predict.py
  function create_model (line 15) | def create_model(num_classes):
  function time_synchronized (line 26) | def time_synchronized():
  function main (line 31) | def main():

FILE: pytorch_object_detection/retinaNet/train.py
  function create_model (line 14) | def create_model(num_classes):
  function main (line 38) | def main(args):

FILE: pytorch_object_detection/retinaNet/train_multi_GPU.py
  function create_model (line 15) | def create_model(num_classes):
  function main (line 39) | def main(args):

FILE: pytorch_object_detection/retinaNet/train_utils/coco_eval.py
  class CocoEvaluator (line 15) | class CocoEvaluator(object):
    method __init__ (line 16) | def __init__(self, coco_gt, iou_types):
    method update (line 29) | def update(self, predictions):
    method synchronize_between_processes (line 44) | def synchronize_between_processes(self):
    method accumulate (line 49) | def accumulate(self):
    method summarize (line 53) | def summarize(self):
    method prepare (line 58) | def prepare(self, predictions, iou_type):
    method prepare_for_coco_detection (line 68) | def prepare_for_coco_detection(self, predictions):
    method prepare_for_coco_segmentation (line 92) | def prepare_for_coco_segmentation(self, predictions):
    method prepare_for_coco_keypoint (line 127) | def prepare_for_coco_keypoint(self, predictions):
  function convert_to_xywh (line 154) | def convert_to_xywh(boxes):
  function merge (line 159) | def merge(img_ids, eval_imgs):
  function create_common_coco_eval (line 181) | def create_common_coco_eval(coco_eval, img_ids, eval_imgs):
  function createIndex (line 199) | def createIndex(self):
  function loadRes (line 234) | def loadRes(self, resFile):
  function evaluate (line 296) | def evaluate(self):

FILE: pytorch_object_detection/retinaNet/train_utils/coco_utils.py
  function convert_to_coco_api (line 7) | def convert_to_coco_api(ds):
  function get_coco_api_from_dataset (line 46) | def get_coco_api_from_dataset(dataset):

FILE: pytorch_object_detection/retinaNet/train_utils/distributed_utils.py
  class SmoothedValue (line 12) | class SmoothedValue(object):
    method __init__ (line 16) | def __init__(self, window_size=20, fmt=None):
    method update (line 24) | def update(self, value, n=1):
    method synchronize_between_processes (line 29) | def synchronize_between_processes(self):
    method median (line 43) | def median(self):  # @property 是装饰器,这里可简单理解为增加median属性(只读)
    method avg (line 48) | def avg(self):
    method global_avg (line 53) | def global_avg(self):
    method max (line 57) | def max(self):
    method value (line 61) | def value(self):
    method __str__ (line 64) | def __str__(self):
  function all_gather (line 73) | def all_gather(data):
  function reduce_dict (line 116) | def reduce_dict(input_dict, average=True):
  class MetricLogger (line 144) | class MetricLogger(object):
    method __init__ (line 145) | def __init__(self, delimiter="\t"):
    method update (line 149) | def update(self, **kwargs):
    method __getattr__ (line 156) | def __getattr__(self, attr):
    method __str__ (line 164) | def __str__(self):
    method synchronize_between_processes (line 172) | def synchronize_between_processes(self):
    method add_meter (line 176) | def add_meter(self, name, meter):
    method log_every (line 179) | def log_every(self, iterable, print_freq, header=None):
  function warmup_lr_scheduler (line 234) | def warmup_lr_scheduler(optimizer, warmup_iters, warmup_factor):
  function mkdir (line 247) | def mkdir(path):
  function setup_for_distributed (line 255) | def setup_for_distributed(is_master):
  function is_dist_avail_and_initialized (line 270) | def is_dist_avail_and_initialized():
  function get_world_size (line 279) | def get_world_size():
  function get_rank (line 285) | def get_rank():
  function is_main_process (line 291) | def is_main_process():
  function save_on_master (line 295) | def save_on_master(*args, **kwargs):
  function init_distributed_mode (line 300) | def init_distributed_mode(args):

FILE: pytorch_object_detection/retinaNet/train_utils/group_by_aspect_ratio.py
  function _repeat_to_at_least (line 17) | def _repeat_to_at_least(iterable, n):
  class GroupedBatchSampler (line 23) | class GroupedBatchSampler(BatchSampler):
    method __init__ (line 37) | def __init__(self, sampler, group_ids, batch_size):
    method __iter__ (line 47) | def __iter__(self):
    method __len__ (line 83) | def __len__(self):
  function _compute_aspect_ratios_slow (line 87) | def _compute_aspect_ratios_slow(dataset, indices=None):
  function _compute_aspect_ratios_custom_dataset (line 120) | def _compute_aspect_ratios_custom_dataset(dataset, indices=None):
  function _compute_aspect_ratios_coco_dataset (line 131) | def _compute_aspect_ratios_coco_dataset(dataset, indices=None):
  function _compute_aspect_ratios_voc_dataset (line 142) | def _compute_aspect_ratios_voc_dataset(dataset, indices=None):
  function _compute_aspect_ratios_subset_dataset (line 154) | def _compute_aspect_ratios_subset_dataset(dataset, indices=None):
  function compute_aspect_ratios (line 162) | def compute_aspect_ratios(dataset, indices=None):
  function _quantize (line 179) | def _quantize(x, bins):
  function create_aspect_ratio_groups (line 187) | def create_aspect_ratio_groups(dataset, k=0):

FILE: pytorch_object_detection/retinaNet/train_utils/train_eval_utils.py
  function train_one_epoch (line 12) | def train_one_epoch(model, optimizer, data_loader, device, epoch,
  function evaluate (line 70) | def evaluate(model, data_loader, device):
  function _get_iou_types (line 115) | def _get_iou_types(model):

FILE: pytorch_object_detection/retinaNet/transforms.py
  class Compose (line 5) | class Compose(object):
    method __init__ (line 7) | def __init__(self, transforms):
    method __call__ (line 10) | def __call__(self, image, target):
  class ToTensor (line 16) | class ToTensor(object):
    method __call__ (line 18) | def __call__(self, image, target):
  class RandomHorizontalFlip (line 23) | class RandomHorizontalFlip(object):
    method __init__ (line 25) | def __init__(self, prob=0.5):
    method __call__ (line 28) | def __call__(self, image, target):

FILE: pytorch_object_detection/retinaNet/validation.py
  function summarize (line 20) | def summarize(self, catId=None):
  function main (line 92) | def main(parser_data):

FILE: pytorch_object_detection/ssd/draw_box_utils.py
  function draw_text (line 34) | def draw_text(draw,
  function draw_masks (line 78) | def draw_masks(image, masks, colors, thresh: float = 0.7, alpha: float =...
  function draw_objs (line 92) | def draw_objs(image: Image,

FILE: pytorch_object_detection/ssd/my_dataset.py
  class VOCDataSet (line 9) | class VOCDataSet(Dataset):
    method __init__ (line 12) | def __init__(self, voc_root, year="2012", transforms=None, train_set='...
    method __len__ (line 36) | def __len__(self):
    method __getitem__ (line 39) | def __getitem__(self, idx):
    method get_height_and_width (line 98) | def get_height_and_width(self, idx):
    method parse_xml_to_dict (line 109) | def parse_xml_to_dict(self, xml):
    method coco_index (line 133) | def coco_index(self, idx):
    method collate_fn (line 186) | def collate_fn(batch):

FILE: pytorch_object_detection/ssd/plot_curve.py
  function plot_loss_and_lr (line 5) | def plot_loss_and_lr(train_loss, learning_rate):
  function plot_map (line 33) | def plot_map(mAP):

FILE: pytorch_object_detection/ssd/predict_test.py
  function create_model (line 14) | def create_model(num_classes):
  function time_synchronized (line 21) | def time_synchronized():
  function main (line 26) | def main():

FILE: pytorch_object_detection/ssd/src/res50_backbone.py
  class Bottleneck (line 5) | class Bottleneck(nn.Module):
    method __init__ (line 8) | def __init__(self, in_channel, out_channel, stride=1, downsample=None):
    method forward (line 24) | def forward(self, x):
  class ResNet (line 46) | class ResNet(nn.Module):
    method __init__ (line 48) | def __init__(self, block, blocks_num, num_classes=1000, include_top=Tr...
    method _make_layer (line 70) | def _make_layer(self, block, channel, block_num, stride=1):
    method forward (line 86) | def forward(self, x):
  function resnet50 (line 105) | def resnet50(num_classes=1000, include_top=True):

FILE: pytorch_object_detection/ssd/src/ssd_model.py
  class Backbone (line 9) | class Backbone(nn.Module):
    method __init__ (line 10) | def __init__(self, pretrain_path=None):
    method forward (line 27) | def forward(self, x):
  class SSD300 (line 32) | class SSD300(nn.Module):
    method __init__ (line 33) | def __init__(self, backbone=None, num_classes=21):
    method _build_additional_features (line 63) | def _build_additional_features(self, input_size):
    method _init_weights (line 85) | def _init_weights(self):
    method bbox_view (line 93) | def bbox_view(self, features, loc_extractor, conf_extractor):
    method forward (line 105) | def forward(self, image, targets=None):
  class Loss (line 141) | class Loss(nn.Module):
    method __init__ (line 148) | def __init__(self, dboxes):
    method _location_vec (line 162) | def _location_vec(self, loc):
    method forward (line 174) | def forward(self, ploc, plabel, gloc, glabel):

FILE: pytorch_object_detection/ssd/src/utils.py
  function box_area (line 50) | def box_area(boxes):
  function calc_iou_tensor (line 65) | def calc_iou_tensor(boxes1, boxes2):
  class Encoder (line 95) | class Encoder(object):
    method __init__ (line 115) | def __init__(self, dboxes):
    method encode (line 122) | def encode(self, bboxes_in, labels_in, criteria=0.5):
    method scale_back_batch (line 164) | def scale_back_batch(self, bboxes_in, scores_in):
    method decode_batch (line 205) | def decode_batch(self, bboxes_in, scores_in, criteria=0.45, max_output...
    method decode_single_new (line 217) | def decode_single_new(self, bboxes_in, scores_in, criteria, num_output...
    method decode_single (line 272) | def decode_single(self, bboxes_in, scores_in, criteria, max_output, ma...
  class DefaultBoxes (line 341) | class DefaultBoxes(object):
    method __init__ (line 342) | def __init__(self, fig_size, feat_size, steps, scales, aspect_ratios, ...
    method scale_xy (line 399) | def scale_xy(self):
    method scale_wh (line 403) | def scale_wh(self):
    method __call__ (line 406) | def __call__(self, order='ltrb'):
  function dboxes300_coco (line 415) | def dboxes300_coco():
  function nms (line 426) | def nms(boxes, scores, iou_threshold):
  function batched_nms (line 457) | def batched_nms(boxes, scores, idxs, iou_threshold):
  class PostProcess (line 505) | class PostProcess(nn.Module):
    method __init__ (line 506) | def __init__(self, dboxes):
    method scale_back_batch (line 517) | def scale_back_batch(self, bboxes_in, scores_in):
    method decode_single_new (line 558) | def decode_single_new(self, bboxes_in, scores_in, criteria, num_output):
    method forward (line 616) | def forward(self, bboxes_in, scores_in):

FILE: pytorch_object_detection/ssd/train_multi_GPU.py
  function create_model (line 14) | def create_model(num_classes):
  function main (line 40) | def main(args):

FILE: pytorch_object_detection/ssd/train_ssd300.py
  function create_model (line 13) | def create_model(num_classes=21):
  function main (line 42) | def main(parser_data):

FILE: pytorch_object_detection/ssd/train_utils/coco_eval.py
  class CocoEvaluator (line 16) | class CocoEvaluator(object):
    method __init__ (line 17) | def __init__(self, coco_gt, iou_types):
    method update (line 30) | def update(self, predictions):
    method synchronize_between_processes (line 45) | def synchronize_between_processes(self):
    method accumulate (line 50) | def accumulate(self):
    method summarize (line 54) | def summarize(self):
    method prepare (line 59) | def prepare(self, predictions, iou_type):
    method prepare_for_coco_detection (line 69) | def prepare_for_coco_detection(self, predictions):
    method prepare_for_coco_segmentation (line 95) | def prepare_for_coco_segmentation(self, predictions):
    method prepare_for_coco_keypoint (line 130) | def prepare_for_coco_keypoint(self, predictions):
  function convert_to_xywh (line 157) | def convert_to_xywh(boxes):
  function merge (line 162) | def merge(img_ids, eval_imgs):
  function create_common_coco_eval (line 184) | def create_common_coco_eval(coco_eval, img_ids, eval_imgs):
  function createIndex (line 202) | def createIndex(self):
  function loadRes (line 237) | def loadRes(self, resFile):
  function evaluate (line 299) | def evaluate(self):

FILE: pytorch_object_detection/ssd/train_utils/coco_utils.py
  function convert_to_coco_api (line 9) | def convert_to_coco_api(ds):
  function get_coco_api_from_dataset (line 58) | def get_coco_api_from_dataset(dataset):

FILE: pytorch_object_detection/ssd/train_utils/distributed_utils.py
  class SmoothedValue (line 12) | class SmoothedValue(object):
    method __init__ (line 16) | def __init__(self, window_size=20, fmt=None):
    method update (line 24) | def update(self, value, n=1):
    method synchronize_between_processes (line 29) | def synchronize_between_processes(self):
    method median (line 43) | def median(self):  # @property 是装饰器,这里可简单理解为增加median属性(只读)
    method avg (line 48) | def avg(self):
    method global_avg (line 53) | def global_avg(self):
    method max (line 57) | def max(self):
    method value (line 61) | def value(self):
    method __str__ (line 64) | def __str__(self):
  function all_gather (line 73) | def all_gather(data):
  function reduce_dict (line 116) | def reduce_dict(input_dict, average=True):
  class MetricLogger (line 144) | class MetricLogger(object):
    method __init__ (line 145) | def __init__(self, delimiter="\t"):
    method update (line 149) | def update(self, **kwargs):
    method __getattr__ (line 156) | def __getattr__(self, attr):
    method __str__ (line 164) | def __str__(self):
    method synchronize_between_processes (line 172) | def synchronize_between_processes(self):
    method add_meter (line 176) | def add_meter(self, name, meter):
    method log_every (line 179) | def log_every(self, iterable, print_freq, header=None):
  function warmup_lr_scheduler (line 234) | def warmup_lr_scheduler(optimizer, warmup_iters, warmup_factor):
  function mkdir (line 247) | def mkdir(path):
  function setup_for_distributed (line 255) | def setup_for_distributed(is_master):
  function is_dist_avail_and_initialized (line 270) | def is_dist_avail_and_initialized():
  function get_world_size (line 279) | def get_world_size():
  function get_rank (line 285) | def get_rank():
  function is_main_process (line 291) | def is_main_process():
  function save_on_master (line 295) | def save_on_master(*args, **kwargs):
  function init_distributed_mode (line 300) | def init_distributed_mode(args):

FILE: pytorch_object_detection/ssd/train_utils/group_by_aspect_ratio.py
  function _repeat_to_at_least (line 17) | def _repeat_to_at_least(iterable, n):
  class GroupedBatchSampler (line 23) | class GroupedBatchSampler(BatchSampler):
    method __init__ (line 37) | def __init__(self, sampler, group_ids, batch_size):
    method __iter__ (line 47) | def __iter__(self):
    method __len__ (line 83) | def __len__(self):
  function _compute_aspect_ratios_slow (line 87) | def _compute_aspect_ratios_slow(dataset, indices=None):
  function _compute_aspect_ratios_custom_dataset (line 120) | def _compute_aspect_ratios_custom_dataset(dataset, indices=None):
  function _compute_aspect_ratios_coco_dataset (line 131) | def _compute_aspect_ratios_coco_dataset(dataset, indices=None):
  function _compute_aspect_ratios_voc_dataset (line 142) | def _compute_aspect_ratios_voc_dataset(dataset, indices=None):
  function _compute_aspect_ratios_subset_dataset (line 154) | def _compute_aspect_ratios_subset_dataset(dataset, indices=None):
  function compute_aspect_ratios (line 162) | def compute_aspect_ratios(dataset, indices=None):
  function _quantize (line 179) | def _quantize(x, bins):
  function create_aspect_ratio_groups (line 187) | def create_aspect_ratio_groups(dataset, k=0):

FILE: pytorch_object_detection/ssd/train_utils/train_eval_utils.py
  function train_one_epoch (line 11) | def train_one_epoch(model, optimizer, data_loader, device, epoch,
  function evaluate (line 76) | def evaluate(model, data_loader, device, data_set=None):
  function _get_iou_types (line 133) | def _get_iou_types(model):

FILE: pytorch_object_detection/ssd/transforms.py
  class Compose (line 10) | class Compose(object):
    method __init__ (line 12) | def __init__(self, transforms):
    method __call__ (line 15) | def __call__(self, image, target=None):
  class ToTensor (line 21) | class ToTensor(object):
    method __call__ (line 23) | def __call__(self, image, target):
  class RandomHorizontalFlip (line 28) | class RandomHorizontalFlip(object):
    method __init__ (line 30) | def __init__(self, prob=0.5):
    method __call__ (line 33) | def __call__(self, image, target):
  class SSDCropping (line 46) | class SSDCropping(object):
    method __init__ (line 56) | def __init__(self):
    method __call__ (line 71) | def __call__(self, image, target):
  class Resize (line 153) | class Resize(object):
    method __init__ (line 155) | def __init__(self, size=(300, 300)):
    method __call__ (line 158) | def __call__(self, image, target):
  class ColorJitter (line 163) | class ColorJitter(object):
    method __init__ (line 165) | def __init__(self, brightness=0.125, contrast=0.5, saturation=0.5, hue...
    method __call__ (line 168) | def __call__(self, image, target):
  class Normalization (line 173) | class Normalization(object):
    method __init__ (line 175) | def __init__(self, mean=None, std=None):
    method __call__ (line 182) | def __call__(self, image, target):
  class AssignGTtoDefaultBox (line 187) | class AssignGTtoDefaultBox(object):
    method __init__ (line 189) | def __init__(self):
    method __call__ (line 193) | def __call__(self, image, target):

FILE: pytorch_object_detection/ssd/validation.py
  function summarize (line 19) | def summarize(self, catId=None):
  function main (line 91) | def main(parser_data):

FILE: pytorch_object_detection/train_coco_dataset/backbone/feature_pyramid_network.py
  class IntermediateLayerGetter (line 11) | class IntermediateLayerGetter(nn.ModuleDict):
    method __init__ (line 32) | def __init__(self, model, return_layers):
    method forward (line 52) | def forward(self, x):
  class BackboneWithFPN (line 64) | class BackboneWithFPN(nn.Module):
    method __init__ (line 84) | def __init__(self,
    method forward (line 110) | def forward(self, x):
  class FeaturePyramidNetwork (line 116) | class FeaturePyramidNetwork(nn.Module):
    method __init__ (line 134) | def __init__(self, in_channels_list, out_channels, extra_blocks=None):
    method get_result_from_inner_blocks (line 156) | def get_result_from_inner_blocks(self, x: Tensor, idx: int) -> Tensor:
    method get_result_from_layer_blocks (line 172) | def get_result_from_layer_blocks(self, x: Tensor, idx: int) -> Tensor:
    method forward (line 188) | def forward(self, x: Dict[str, Tensor]) -> Dict[str, Tensor]:
  class LastLevelMaxPool (line 227) | class LastLevelMaxPool(torch.nn.Module):
    method forward (line 232) | def forward(self, x: List[Tensor], y: List[Tensor], names: List[str]) ...

FILE: pytorch_object_detection/train_coco_dataset/backbone/mobilenetv2_model.py
  function _make_divisible (line 5) | def _make_divisible(ch, divisor=8, min_ch=None):
  class ConvBNReLU (line 21) | class ConvBNReLU(nn.Sequential):
    method __init__ (line 22) | def __init__(self, in_channel, out_channel, kernel_size=3, stride=1, g...
  class InvertedResidual (line 33) | class InvertedResidual(nn.Module):
    method __init__ (line 34) | def __init__(self, in_channel, out_channel, stride, expand_ratio, norm...
    method forward (line 55) | def forward(self, x):
  class MobileNetV2 (line 62) | class MobileNetV2(nn.Module):
    method __init__ (line 63) | def __init__(self, num_classes=1000, alpha=1.0, round_nearest=8, weigh...
    method forward (line 121) | def forward(self, x):

FILE: pytorch_object_detection/train_coco_dataset/backbone/resnet.py
  class BasicBlock (line 5) | class BasicBlock(nn.Module):
    method __init__ (line 8) | def __init__(self, in_channel, out_channel, stride=1, downsample=None,...
    method forward (line 19) | def forward(self, x):
  class Bottleneck (line 37) | class Bottleneck(nn.Module):
    method __init__ (line 46) | def __init__(self, in_channel, out_channel, stride=1, downsample=None,
    method forward (line 66) | def forward(self, x):
  class ResNet (line 88) | class ResNet(nn.Module):
    method __init__ (line 90) | def __init__(self,
    method _make_layer (line 121) | def _make_layer(self, block, channel, block_num, stride=1):
    method forward (line 145) | def forward(self, x):
  function resnet34 (line 164) | def resnet34(num_classes=1000, include_top=True):
  function resnet50 (line 169) | def resnet50(num_classes=1000, include_top=True):
  function resnet101 (line 174) | def resnet101(num_classes=1000, include_top=True):
  function resnext50_32x4d (line 179) | def resnext50_32x4d(num_classes=1000, include_top=True):
  function resnext101_32x8d (line 190) | def resnext101_32x8d(num_classes=1000, include_top=True):

FILE: pytorch_object_detection/train_coco_dataset/backbone/resnet50_fpn_model.py
  class Bottleneck (line 10) | class Bottleneck(nn.Module):
    method __init__ (line 13) | def __init__(self, in_channel, out_channel, stride=1, downsample=None,...
    method forward (line 32) | def forward(self, x):
  class ResNet (line 54) | class ResNet(nn.Module):
    method __init__ (line 56) | def __init__(self, block, blocks_num, num_classes=1000, include_top=Tr...
    method _make_layer (line 82) | def _make_layer(self, block, channel, block_num, stride=1):
    method forward (line 100) | def forward(self, x):
  function overwrite_eps (line 119) | def overwrite_eps(model, eps):
  function resnet50_fpn_backbone (line 137) | def resnet50_fpn_backbone(pretrain_path="",

FILE: pytorch_object_detection/train_coco_dataset/backbone/vgg_model.py
  class VGG (line 5) | class VGG(nn.Module):
    method __init__ (line 6) | def __init__(self, features, class_num=1000, init_weights=False, weigh...
    method forward (line 24) | def forward(self, x):
    method _initialize_weights (line 33) | def _initialize_weights(self):
  function make_features (line 46) | def make_features(cfg: list):
  function vgg (line 67) | def vgg(model_name="vgg16", weights_path=None):

FILE: pytorch_object_detection/train_coco_dataset/change_backbone_with_fpn.py
  function create_model (line 14) | def create_model(num_classes):
  function main (line 68) | def main(args):

FILE: pytorch_object_detection/train_coco_dataset/draw_box_utils.py
  function draw_text (line 34) | def draw_text(draw,
  function draw_masks (line 78) | def draw_masks(image, masks, colors, thresh: float = 0.7, alpha: float =...
  function draw_objs (line 92) | def draw_objs(image: Image,

FILE: pytorch_object_detection/train_coco_dataset/my_dataset.py
  function _coco_remove_images_without_annotations (line 10) | def _coco_remove_images_without_annotations(dataset, ids):
  class CocoDetection (line 43) | class CocoDetection(data.Dataset):
    method __init__ (line 53) | def __init__(self, root, dataset="train", transforms=None):
    method parse_targets (line 94) | def parse_targets(self,
    method __getitem__ (line 138) | def __getitem__(self, index):
    method __len__ (line 161) | def __len__(self):
    method get_height_and_width (line 164) | def get_height_and_width(self, index):
    method collate_fn (line 174) | def collate_fn(batch):

FILE: pytorch_object_detection/train_coco_dataset/network_files/boxes.py
  function nms (line 7) | def nms(boxes, scores, iou_threshold):
  function batched_nms (line 38) | def batched_nms(boxes, scores, idxs, iou_threshold):
  function remove_small_boxes (line 86) | def remove_small_boxes(boxes, min_size):
  function clip_boxes_to_image (line 108) | def clip_boxes_to_image(boxes, size):
  function box_area (line 139) | def box_area(boxes):
  function box_iou (line 154) | def box_iou(boxes1, boxes2):

FILE: pytorch_object_detection/train_coco_dataset/network_files/det_utils.py
  class BalancedPositiveNegativeSampler (line 7) | class BalancedPositiveNegativeSampler(object):
    method __init__ (line 12) | def __init__(self, batch_size_per_image, positive_fraction):
    method __call__ (line 22) | def __call__(self, matched_idxs):
  function encode_boxes (line 88) | def encode_boxes(reference_boxes, proposals, weights):
  class BoxCoder (line 140) | class BoxCoder(object):
    method __init__ (line 146) | def __init__(self, weights, bbox_xform_clip=math.log(1000. / 16)):
    method encode (line 156) | def encode(self, reference_boxes, proposals):
    method encode_single (line 177) | def encode_single(self, reference_boxes, proposals):
    method decode (line 193) | def decode(self, rel_codes, boxes):
    method decode_single (line 224) | def decode_single(self, rel_codes, boxes):
  class Matcher (line 270) | class Matcher(object):
    method __init__ (line 279) | def __init__(self, high_threshold, low_threshold, allow_low_quality_ma...
    method __call__ (line 301) | def __call__(self, match_quality_matrix):
    method set_low_quality_matches_ (line 355) | def set_low_quality_matches_(self, matches, all_matches, match_quality...
  function smooth_l1_loss (line 397) | def smooth_l1_loss(input, target, beta: float = 1. / 9, size_average: bo...

FILE: pytorch_object_detection/train_coco_dataset/network_files/faster_rcnn_framework.py
  class FasterRCNNBase (line 15) | class FasterRCNNBase(nn.Module):
    method __init__ (line 28) | def __init__(self, backbone, rpn, roi_heads, transform):
    method eager_outputs (line 38) | def eager_outputs(self, losses, detections):
    method forward (line 45) | def forward(self, images, targets=None):
  class TwoMLPHead (line 117) | class TwoMLPHead(nn.Module):
    method __init__ (line 126) | def __init__(self, in_channels, representation_size):
    method forward (line 132) | def forward(self, x):
  class FastRCNNPredictor (line 141) | class FastRCNNPredictor(nn.Module):
    method __init__ (line 151) | def __init__(self, in_channels, num_classes):
    method forward (line 156) | def forward(self, x):
  class FasterRCNN (line 166) | class FasterRCNN(FasterRCNNBase):
    method __init__ (line 246) | def __init__(self, backbone, num_classes=None,

FILE: pytorch_object_detection/train_coco_dataset/network_files/image_list.py
  class ImageList (line 5) | class ImageList(object):
    method __init__ (line 13) | def __init__(self, tensors, image_sizes):
    method to (line 23) | def to(self, device):

FILE: pytorch_object_detection/train_coco_dataset/network_files/roi_head.py
  function fastrcnn_loss (line 11) | def fastrcnn_loss(class_logits, box_regression, labels, regression_targe...
  class RoIHeads (line 59) | class RoIHeads(torch.nn.Module):
    method __init__ (line 66) | def __init__(self,
    method assign_targets_to_proposals (line 103) | def assign_targets_to_proposals(self, proposals, gt_boxes, gt_labels):
    method subsample (line 158) | def subsample(self, labels):
    method add_gt_proposals (line 171) | def add_gt_proposals(self, proposals, gt_boxes):
    method check_targets (line 188) | def check_targets(self, targets):
    method select_training_samples (line 194) | def select_training_samples(self,
    method postprocess_detections (line 256) | def postprocess_detections(self,
    method forward (line 349) | def forward(self,

FILE: pytorch_object_detection/train_coco_dataset/network_files/rpn_function.py
  function _onnx_get_num_anchors_and_pre_nms_top_n (line 14) | def _onnx_get_num_anchors_and_pre_nms_top_n(ob, orig_pre_nms_top_n):
  class AnchorsGenerator (line 25) | class AnchorsGenerator(nn.Module):
    method __init__ (line 51) | def __init__(self, sizes=(128, 256, 512), aspect_ratios=(0.5, 1.0, 2.0)):
    method generate_anchors (line 67) | def generate_anchors(self, scales, aspect_ratios, dtype=torch.float32,...
    method set_cell_anchors (line 93) | def set_cell_anchors(self, dtype, device):
    method num_anchors_per_location (line 111) | def num_anchors_per_location(self):
    method grid_anchors (line 117) | def grid_anchors(self, grid_sizes, strides):
    method cached_grid_anchors (line 161) | def cached_grid_anchors(self, grid_sizes, strides):
    method forward (line 172) | def forward(self, image_list, feature_maps):
  class RPNHead (line 211) | class RPNHead(nn.Module):
    method __init__ (line 221) | def __init__(self, in_channels, num_anchors):
    method forward (line 235) | def forward(self, x):
  function permute_and_flatten (line 246) | def permute_and_flatten(layer, N, A, C, H, W):
  function concat_box_prediction_layers (line 272) | def concat_box_prediction_layers(box_cls, box_regression):
  class RegionProposalNetwork (line 312) | class RegionProposalNetwork(torch.nn.Module):
    method __init__ (line 345) | def __init__(self, anchor_generator, head,
    method pre_nms_top_n (line 375) | def pre_nms_top_n(self):
    method post_nms_top_n (line 380) | def post_nms_top_n(self):
    method assign_targets_to_anchors (line 385) | def assign_targets_to_anchors(self, anchors, targets):
    method _get_top_n_idx (line 433) | def _get_top_n_idx(self, objectness, num_anchors_per_level):
    method filter_proposals (line 459) | def filter_proposals(self, proposals, objectness, image_shapes, num_an...
    method compute_loss (line 530) | def compute_loss(self, objectness, pred_bbox_deltas, labels, regressio...
    method forward (line 574) | def forward(self,

FILE: pytorch_object_detection/train_coco_dataset/network_files/transform.py
  function _resize_image_onnx (line 12) | def _resize_image_onnx(image, self_min_size, self_max_size):
  function _resize_image (line 27) | def _resize_image(image, self_min_size, self_max_size):
  class GeneralizedRCNNTransform (line 48) | class GeneralizedRCNNTransform(nn.Module):
    method __init__ (line 60) | def __init__(self, min_size, max_size, image_mean, image_std):
    method normalize (line 69) | def normalize(self, image):
    method torch_choice (line 77) | def torch_choice(self, k):
    method resize (line 87) | def resize(self, image, target):
    method _onnx_batch_images (line 126) | def _onnx_batch_images(self, images, size_divisible=32):
    method max_by_axis (line 148) | def max_by_axis(self, the_list):
    method batch_images (line 156) | def batch_images(self, images, size_divisible=32):
    method postprocess (line 196) | def postprocess(self,
    method __repr__ (line 222) | def __repr__(self):
    method forward (line 232) | def forward(self,
  function resize_boxes (line 264) | def resize_boxes(boxes, original_size, new_size):

FILE: pytorch_object_detection/train_coco_dataset/plot_curve.py
  function plot_loss_and_lr (line 5) | def plot_loss_and_lr(train_loss, learning_rate):
  function plot_map (line 33) | def plot_map(mAP):

FILE: pytorch_object_detection/train_coco_dataset/predict.py
  function create_model (line 17) | def create_model(num_classes):
  function time_synchronized (line 37) | def time_synchronized():
  function main (line 42) | def main():

FILE: pytorch_object_detection/train_coco_dataset/train.py
  function create_model (line 16) | def create_model(num_classes):
  function main (line 50) | def main(args):

FILE: pytorch_object_detection/train_coco_dataset/train_multi_GPU.py
  function create_model (line 17) | def create_model(num_classes):
  function main (line 40) | def main(args):

FILE: pytorch_object_detection/train_coco_dataset/train_utils/coco_eval.py
  function merge (line 11) | def merge(img_ids, eval_results):
  class EvalCOCOMetric (line 34) | class EvalCOCOMetric:
    method __init__ (line 35) | def __init__(self,
    method prepare_for_coco_detection (line 50) | def prepare_for_coco_detection(self, targets, outputs):
    method prepare_for_coco_segmentation (line 88) | def prepare_for_coco_segmentation(self, targets, outputs):
    method update (line 124) | def update(self, targets, outputs):
    method synchronize_results (line 132) | def synchronize_results(self):
    method evaluate (line 146) | def evaluate(self):

FILE: pytorch_object_detection/train_coco_dataset/train_utils/distributed_utils.py
  class SmoothedValue (line 12) | class SmoothedValue(object):
    method __init__ (line 16) | def __init__(self, window_size=20, fmt=None):
    method update (line 24) | def update(self, value, n=1):
    method synchronize_between_processes (line 29) | def synchronize_between_processes(self):
    method median (line 43) | def median(self):  # @property 是装饰器,这里可简单理解为增加median属性(只读)
    method avg (line 48) | def avg(self):
    method global_avg (line 53) | def global_avg(self):
    method max (line 57) | def max(self):
    method value (line 61) | def value(self):
    method __str__ (line 64) | def __str__(self):
  function all_gather (line 73) | def all_gather(data):
  function reduce_dict (line 92) | def reduce_dict(input_dict, average=True):
  class MetricLogger (line 120) | class MetricLogger(object):
    method __init__ (line 121) | def __init__(self, delimiter="\t"):
    method update (line 125) | def update(self, **kwargs):
    method __getattr__ (line 132) | def __getattr__(self, attr):
    method __str__ (line 140) | def __str__(self):
    method synchronize_between_processes (line 148) | def synchronize_between_processes(self):
    method add_meter (line 152) | def add_meter(self, name, meter):
    method log_every (line 155) | def log_every(self, iterable, print_freq, header=None):
  function warmup_lr_scheduler (line 210) | def warmup_lr_scheduler(optimizer, warmup_iters, warmup_factor):
  function mkdir (line 223) | def mkdir(path):
  function setup_for_distributed (line 231) | def setup_for_distributed(is_master):
  function is_dist_avail_and_initialized (line 246) | def is_dist_avail_and_initialized():
  function get_world_size (line 255) | def get_world_size():
  function get_rank (line 261) | def get_rank():
  function is_main_process (line 267) | def is_main_process():
  function save_on_master (line 271) | def save_on_master(*args, **kwargs):
  function init_distributed_mode (line 276) | def init_distributed_mode(args):

FILE: pytorch_object_detection/train_coco_dataset/train_utils/group_by_aspect_ratio.py
  function _repeat_to_at_least (line 17) | def _repeat_to_at_least(iterable, n):
  class GroupedBatchSampler (line 23) | class GroupedBatchSampler(BatchSampler):
    method __init__ (line 37) | def __init__(self, sampler, group_ids, batch_size):
    method __iter__ (line 47) | def __iter__(self):
    method __len__ (line 83) | def __len__(self):
  function _compute_aspect_ratios_slow (line 87) | def _compute_aspect_ratios_slow(dataset, indices=None):
  function _compute_aspect_ratios_custom_dataset (line 120) | def _compute_aspect_ratios_custom_dataset(dataset, indices=None):
  function _compute_aspect_ratios_coco_dataset (line 131) | def _compute_aspect_ratios_coco_dataset(dataset, indices=None):
  function _compute_aspect_ratios_voc_dataset (line 142) | def _compute_aspect_ratios_voc_dataset(dataset, indices=None):
  function _compute_aspect_ratios_subset_dataset (line 154) | def _compute_aspect_ratios_subset_dataset(dataset, indices=None):
  function compute_aspect_ratios (line 162) | def compute_aspect_ratios(dataset, indices=None):
  function _quantize (line 179) | def _quantize(x, bins):
  function create_aspect_ratio_groups (line 187) | def create_aspect_ratio_groups(dataset, k=0):

FILE: pytorch_object_detection/train_coco_dataset/train_utils/train_eval_utils.py
  function train_one_epoch (line 11) | def train_one_epoch(model, optimizer, data_loader, device, epoch,
  function evaluate (line 69) | def evaluate(model, data_loader, device):

FILE: pytorch_object_detection/train_coco_dataset/transforms.py
  class Compose (line 5) | class Compose(object):
    method __init__ (line 7) | def __init__(self, transforms):
    method __call__ (line 10) | def __call__(self, image, target):
  class ToTensor (line 16) | class ToTensor(object):
    method __call__ (line 18) | def __call__(self, image, target):
  class RandomHorizontalFlip (line 23) | class RandomHorizontalFlip(object):
    method __init__ (line 25) | def __init__(self, prob=0.5):
    method __call__ (line 28) | def __call__(self, image, target):

FILE: pytorch_object_detection/train_coco_dataset/validation.py
  function summarize (line 22) | def summarize(self, catId=None):
  function main (line 94) | def main(parser_data):

FILE: pytorch_object_detection/yolov3_spp/build_utils/datasets.py
  function exif_size (line 27) | def exif_size(img):
  class LoadImagesAndLabels (line 49) | class LoadImagesAndLabels(Dataset):  # for training/testing
    method __init__ (line 50) | def __init__(self,
    method __len__ (line 285) | def __len__(self):
    method __getitem__ (line 288) | def __getitem__(self, index):
    method coco_index (line 360) | def coco_index(self, index):
    method collate_fn (line 370) | def collate_fn(batch):
  function load_image (line 377) | def load_image(self, index):
  function load_mosaic (line 395) | def load_mosaic(self, index):
  function random_affine (line 475) | def random_affine(img, targets=(), degrees=10, translate=.1, scale=.1, s...
  function augment_hsv (line 548) | def augment_hsv(img, h_gain=0.5, s_gain=0.5, v_gain=0.5):
  function letterbox (line 563) | def letterbox(img: np.ndarray,
  function create_folder (line 614) | def create_folder(path="./new_folder"):

FILE: pytorch_object_detection/yolov3_spp/build_utils/img_utils.py
  function letterbox (line 5) | def letterbox(img: np.ndarray,

FILE: pytorch_object_detection/yolov3_spp/build_utils/layers.py
  function make_divisible (line 5) | def make_divisible(v, divisor):
  class Flatten (line 11) | class Flatten(nn.Module):
    method forward (line 13) | def forward(self, x):
  class Concat (line 17) | class Concat(nn.Module):
    method __init__ (line 19) | def __init__(self, dimension=1):
    method forward (line 23) | def forward(self, x):
  class FeatureConcat (line 27) | class FeatureConcat(nn.Module):
    method __init__ (line 31) | def __init__(self, layers):
    method forward (line 36) | def forward(self, x, outputs):
  class WeightedFeatureFusion (line 40) | class WeightedFeatureFusion(nn.Module):  # weighted sum of 2 or more lay...
    method __init__ (line 44) | def __init__(self, layers, weight=False):
    method forward (line 52) | def forward(self, x, outputs):
  class MixConv2d (line 76) | class MixConv2d(nn.Module):  # MixConv: Mixed Depthwise Convolutional Ke...
    method __init__ (line 77) | def __init__(self, in_ch, out_ch, k=(3, 5, 7), stride=1, dilation=1, b...
    method forward (line 100) | def forward(self, x):
  class SwishImplementation (line 105) | class SwishImplementation(torch.autograd.Function):
    method forward (line 107) | def forward(ctx, x):
    method backward (line 112) | def backward(ctx, grad_output):
  class MishImplementation (line 118) | class MishImplementation(torch.autograd.Function):
    method forward (line 120) | def forward(ctx, x):
    method backward (line 125) | def backward(ctx, grad_output):
  class MemoryEfficientSwish (line 132) | class MemoryEfficientSwish(nn.Module):
    method forward (line 133) | def forward(self, x):
  class MemoryEfficientMish (line 137) | class MemoryEfficientMish(nn.Module):
    method forward (line 138) | def forward(self, x):
  class Swish (line 142) | class Swish(nn.Module):
    method forward (line 143) | def forward(self, x):
  class HardSwish (line 147) | class HardSwish(nn.Module):  # https://arxiv.org/pdf/1905.02244.pdf
    method forward (line 148) | def forward(self, x):
  class Mish (line 152) | class Mish(nn.Module):  # https://github.com/digantamisra98/Mish
    method forward (line 153) | def forward(self, x):

FILE: pytorch_object_detection/yolov3_spp/build_utils/parse_config.py
  function parse_model_cfg (line 5) | def parse_model_cfg(path: str):
  function parse_data_cfg (line 61) | def parse_data_cfg(path):

FILE: pytorch_object_detection/yolov3_spp/build_utils/torch_utils.py
  function init_seeds (line 10) | def init_seeds(seed=0):
  function time_synchronized (line 19) | def time_synchronized():
  function initialize_weights (line 24) | def initialize_weights(model):
  function model_info (line 36) | def model_info(model, verbose=False):
  class ModelEMA (line 57) | class ModelEMA:
    method __init__ (line 75) | def __init__(self, model, decay=0.9999, device=''):
    method update (line 87) | def update(self, model):
    method update_attr (line 101) | def update_attr(self, model):

FILE: pytorch_object_detection/yolov3_spp/build_utils/utils.py
  function init_seeds (line 26) | def init_seeds(seed=0):
  function check_file (line 32) | def check_file(file):
  function xyxy2xywh (line 42) | def xyxy2xywh(x):
  function xywh2xyxy (line 52) | def xywh2xyxy(x):
  function scale_coords (line 62) | def scale_coords(img1_shape, coords, img0_shape, ratio_pad=None):
  function clip_coords (line 86) | def clip_coords(boxes, img_shape):
  function bbox_iou (line 94) | def bbox_iou(box1, box2, x1y1x2y2=True, GIoU=False, DIoU=False, CIoU=Fal...
  function box_iou (line 140) | def box_iou(box1, box2):
  function wh_iou (line 165) | def wh_iou(wh1, wh2):
  class FocalLoss (line 173) | class FocalLoss(nn.Module):
    method __init__ (line 175) | def __init__(self, loss_fcn, gamma=1.5, alpha=0.25):
    method forward (line 183) | def forward(self, pred, true):
  function smooth_BCE (line 203) | def smooth_BCE(eps=0.1):  # https://github.com/ultralytics/yolov3/issues...
  function compute_loss (line 208) | def compute_loss(p, targets, model):  # predictions, targets, model
  function build_targets (line 272) | def build_targets(p, targets, model):
  function non_max_suppression (line 323) | def non_max_suppression(prediction, conf_thres=0.1, iou_thres=0.6,
  function get_yolo_layers (line 403) | def get_yolo_layers(model):
  function kmean_anchors (line 408) | def kmean_anchors(path='./data/coco64.txt', n=9, img_size=(640, 640), th...

FILE: pytorch_object_detection/yolov3_spp/calculate_dataset.py
  function calculate_data_txt (line 20) | def calculate_data_txt(txt_path, dataset_dir):
  function create_data_data (line 34) | def create_data_data(create_data_path, label_path, train_path, val_path,...
  function change_and_create_cfg_file (line 44) | def change_and_create_cfg_file(classes_info, save_cfg_path="./cfg/my_yol...
  function main (line 64) | def main():

FILE: pytorch_object_detection/yolov3_spp/draw_box_utils.py
  function draw_text (line 34) | def draw_text(draw,
  function draw_masks (line 78) | def draw_masks(image, masks, colors, thresh: float = 0.7, alpha: float =...
  function draw_objs (line 92) | def draw_objs(image: Image,

FILE: pytorch_object_detection/yolov3_spp/export_onnx.py
  function to_numpy (line 15) | def to_numpy(tensor):
  function main (line 19) | def main():

FILE: pytorch_object_detection/yolov3_spp/load_onnx_test.py
  function to_numpy (line 10) | def to_numpy(tensor):
  function scale_img (line 14) | def scale_img(img: np.ndarray,
  function clip_coords (line 65) | def clip_coords(boxes: np.ndarray, img_shape: tuple):
  function turn_back_coords (line 73) | def turn_back_coords(img1_shape, coords, img0_shape, ratio_pad=None):
  function xywh2xyxy (line 97) | def xywh2xyxy(x: np.ndarray):
  function bboxes_iou (line 107) | def bboxes_iou(boxes1: np.ndarray, boxes2: np.ndarray) -> np.ndarray:
  function nms (line 122) | def nms(bboxes: np.ndarray, iou_threshold=0.5, soft_threshold=0.3, sigma...
  function post_process (line 156) | def post_process(pred: np.ndarray, multi_label=False, conf_thres=0.3):
  function main (line 201) | def main():

FILE: pytorch_object_detection/yolov3_spp/models.py
  function create_modules (line 7) | def create_modules(modules_defs: list, img_size):
  class YOLOLayer (line 115) | class YOLOLayer(nn.Module):
    method __init__ (line 119) | def __init__(self, anchors, nc, img_size, stride):
    method create_grids (line 138) | def create_grids(self, ng=(13, 13), device="cpu"):
    method forward (line 159) | def forward(self, p):
  class Darknet (line 201) | class Darknet(nn.Module):
    method __init__ (line 205) | def __init__(self, cfg, img_size=(416, 416), verbose=False):
    method forward (line 219) | def forward(self, x, verbose=False):
    method forward_once (line 222) | def forward_once(self, x, verbose=False):
    method info (line 277) | def info(self, verbose=False):
  function get_yolo_layers (line 286) | def get_yolo_layers(self):

FILE: pytorch_object_detection/yolov3_spp/predict_test.py
  function main (line 16) | def main():

FILE: pytorch_object_detection/yolov3_spp/train.py
  function train (line 16) | def train(hyp):

FILE: pytorch_object_detection/yolov3_spp/train_multi_GPU.py
  function main (line 18) | def main(opt, hyp):

FILE: pytorch_object_detection/yolov3_spp/train_utils/coco_eval.py
  class CocoEvaluator (line 15) | class CocoEvaluator(object):
    method __init__ (line 16) | def __init__(self, coco_gt, iou_types):
    method update (line 29) | def update(self, predictions):
    method synchronize_between_processes (line 44) | def synchronize_between_processes(self):
    method accumulate (line 49) | def accumulate(self):
    method summarize (line 53) | def summarize(self):
    method prepare (line 58) | def prepare(self, predictions, iou_type):
    method prepare_for_coco_detection (line 68) | def prepare_for_coco_detection(self, predictions):
    method prepare_for_coco_segmentation (line 92) | def prepare_for_coco_segmentation(self, predictions):
    method prepare_for_coco_keypoint (line 127) | def prepare_for_coco_keypoint(self, predictions):
  function convert_to_xywh (line 154) | def convert_to_xywh(boxes):
  function merge (line 159) | def merge(img_ids, eval_imgs):
  function create_common_coco_eval (line 181) | def create_common_coco_eval(coco_eval, img_ids, eval_imgs):
  function createIndex (line 199) | def createIndex(self):
  function loadRes (line 234) | def loadRes(self, resFile):
  function evaluate (line 296) | def evaluate(self):

FILE: pytorch_object_detection/yolov3_spp/train_utils/coco_utils.py
  function convert_to_coco_api (line 9) | def convert_to_coco_api(ds):
  function get_coco_api_from_dataset (line 53) | def get_coco_api_from_dataset(dataset):

FILE: pytorch_object_detection/yolov3_spp/train_utils/distributed_utils.py
  class SmoothedValue (line 13) | class SmoothedValue(object):
    method __init__ (line 17) | def __init__(self, window_size=20, fmt=None):
    method update (line 25) | def update(self, value, n=1):
    method synchronize_between_processes (line 30) | def synchronize_between_processes(self):
    method median (line 44) | def median(self):  # @property 是装饰器,这里可简单理解为增加median属性(只读)
    method avg (line 49) | def avg(self):
    method global_avg (line 54) | def global_avg(self):
    method max (line 58) | def max(self):
    method value (line 62) | def value(self):
    method __str__ (line 65) | def __str__(self):
  function all_gather (line 74) | def all_gather(data):
  function reduce_dict (line 117) | def reduce_dict(input_dict, average=True):
  class MetricLogger (line 145) | class MetricLogger(object):
    method __init__ (line 146) | def __init__(self, delimiter="\t"):
    method update (line 150) | def update(self, **kwargs):
    method __getattr__ (line 157) | def __getattr__(self, attr):
    method __str__ (line 165) | def __str__(self):
    method synchronize_between_processes (line 173) | def synchronize_between_processes(self):
    method add_meter (line 177) | def add_meter(self, name, meter):
    method log_every (line 180) | def log_every(self, iterable, print_freq, header=None):
  function warmup_lr_scheduler (line 235) | def warmup_lr_scheduler(optimizer, warmup_iters, warmup_factor):
  function mkdir (line 248) | def mkdir(path):
  function setup_for_distributed (line 256) | def setup_for_distributed(is_master):
  function is_dist_avail_and_initialized (line 271) | def is_dist_avail_and_initialized():
  function get_world_size (line 280) | def get_world_size():
  function get_rank (line 286) | def get_rank():
  function is_main_process (line 292) | def is_main_process():
  function save_on_master (line 296) | def save_on_master(*args, **kwargs):
  function init_distributed_mode (line 301) | def init_distributed_mode(args):
  function torch_distributed_zero_first (line 327) | def torch_distributed_zero_first(local_rank: int):

FILE: pytorch_object_detection/yolov3_spp/train_utils/group_by_aspect_ratio.py
  function _repeat_to_at_least (line 17) | def _repeat_to_at_least(iterable, n):
  class GroupedBatchSampler (line 23) | class GroupedBatchSampler(BatchSampler):
    method __init__ (line 37) | def __init__(self, sampler, group_ids, batch_size):
    method __iter__ (line 47) | def __iter__(self):
    method __len__ (line 83) | def __len__(self):
  function _compute_aspect_ratios_slow (line 87) | def _compute_aspect_ratios_slow(dataset, indices=None):
  function _compute_aspect_ratios_custom_dataset (line 120) | def _compute_aspect_ratios_custom_dataset(dataset, indices=None):
  function _compute_aspect_ratios_coco_dataset (line 131) | def _compute_aspect_ratios_coco_dataset(dataset, indices=None):
  function _compute_aspect_ratios_voc_dataset (line 142) | def _compute_aspect_ratios_voc_dataset(dataset, indices=None):
  function _compute_aspect_ratios_subset_dataset (line 154) | def _compute_aspect_ratios_subset_dataset(dataset, indices=None):
  function compute_aspect_ratios (line 162) | def compute_aspect_ratios(dataset, indices=None):
  function _quantize (line 179) | def _quantize(x, bins):
  function create_aspect_ratio_groups (line 187) | def create_aspect_ratio_groups(dataset, k=0):

FILE: pytorch_object_detection/yolov3_spp/train_utils/train_eval_utils.py
  function train_one_epoch (line 12) | def train_one_epoch(model, optimizer, data_loader, device, epoch,
  function evaluate (line 107) | def evaluate(model, data_loader, coco=None, device=None):
  function _get_iou_types (line 170) | def _get_iou_types(model):

FILE: pytorch_object_detection/yolov3_spp/trans_voc2yolo.py
  function parse_xml_to_dict (line 43) | def parse_xml_to_dict(xml):
  function translate_info (line 68) | def translate_info(file_names: list, save_root: str, class_dict: dict, t...
  function create_class_names (line 148) | def create_class_names(class_dict: dict):
  function main (line 158) | def main():

FILE: pytorch_object_detection/yolov3_spp/validation.py
  function summarize (line 13) | def summarize(self, catId=None):
  function main (line 85) | def main(parser_data):

FILE: pytorch_segmentation/deeplab_v3/my_dataset.py
  class VOCSegmentation (line 7) | class VOCSegmentation(data.Dataset):
    method __init__ (line 8) | def __init__(self, voc_root, year="2012", transforms=None, txt_name: s...
    method __getitem__ (line 26) | def __getitem__(self, index):
    method __len__ (line 42) | def __len__(self):
    method collate_fn (line 46) | def collate_fn(batch):
  function cat_list (line 53) | def cat_list(images, fill_value=0):

FILE: pytorch_segmentation/deeplab_v3/predict.py
  function time_synchronized (line 13) | def time_synchronized():
  function main (line 18) | def main():

FILE: pytorch_segmentation/deeplab_v3/src/deeplabv3_model.py
  class IntermediateLayerGetter (line 12) | class IntermediateLayerGetter(nn.ModuleDict):
    method __init__ (line 37) | def __init__(self, model: nn.Module, return_layers: Dict[str, str]) ->...
    method forward (line 55) | def forward(self, x: Tensor) -> Dict[str, Tensor]:
  class DeepLabV3 (line 65) | class DeepLabV3(nn.Module):
    method __init__ (line 82) | def __init__(self, backbone, classifier, aux_classifier=None):
    method forward (line 88) | def forward(self, x: Tensor) -> Dict[str, Tensor]:
  class FCNHead (line 110) | class FCNHead(nn.Sequential):
    method __init__ (line 111) | def __init__(self, in_channels, channels):
  class ASPPConv (line 122) | class ASPPConv(nn.Sequential):
    method __init__ (line 123) | def __init__(self, in_channels: int, out_channels: int, dilation: int)...
  class ASPPPooling (line 131) | class ASPPPooling(nn.Sequential):
    method __init__ (line 132) | def __init__(self, in_channels: int, out_channels: int) -> None:
    method forward (line 140) | def forward(self, x: torch.Tensor) -> torch.Tensor:
  class ASPP (line 147) | class ASPP(nn.Module):
    method __init__ (line 148) | def __init__(self, in_channels: int, atrous_rates: List[int], out_chan...
    method forward (line 171) | def forward(self, x: torch.Tensor) -> torch.Tensor:
  class DeepLabHead (line 179) | class DeepLabHead(nn.Sequential):
    method __init__ (line 180) | def __init__(self, in_channels: int, num_classes: int) -> None:
  function deeplabv3_resnet50 (line 190) | def deeplabv3_resnet50(aux, num_classes=21, pretrain_backbone=False):
  function deeplabv3_resnet101 (line 219) | def deeplabv3_resnet101(aux, num_classes=21, pretrain_backbone=False):
  function deeplabv3_mobilenetv3_large (line 248) | def deeplabv3_mobilenetv3_large(aux, num_classes=21, pretrain_backbone=F...

FILE: pytorch_segmentation/deeplab_v3/src/mobilenet_backbone.py
  function _make_divisible (line 9) | def _make_divisible(ch, divisor=8, min_ch=None):
  class ConvBNActivation (line 25) | class ConvBNActivation(nn.Sequential):
    method __init__ (line 26) | def __init__(self,
  class SqueezeExcitation (line 53) | class SqueezeExcitation(nn.Module):
    method __init__ (line 54) | def __init__(self, input_c: int, squeeze_factor: int = 4):
    method forward (line 60) | def forward(self, x: Tensor) -> Tensor:
  class InvertedResidualConfig (line 69) | class InvertedResidualConfig:
    method __init__ (line 70) | def __init__(self,
    method adjust_channels (line 90) | def adjust_channels(channels: int, width_multi: float):
  class InvertedResidual (line 94) | class InvertedResidual(nn.Module):
    method __init__ (line 95) | def __init__(self,
    method forward (line 141) | def forward(self, x: Tensor) -> Tensor:
  class MobileNetV3 (line 149) | class MobileNetV3(nn.Module):
    method __init__ (line 150) | def __init__(self,
    method _forward_impl (line 212) | def _forward_impl(self, x: Tensor) -> Tensor:
    method forward (line 220) | def forward(self, x: Tensor) -> Tensor:
  function mobilenet_v3_large (line 224) | def mobilenet_v3_large(num_classes: int = 1000,
  function mobilenet_v3_small (line 273) | def mobilenet_v3_small(num_classes: int = 1000,

FILE: pytorch_segmentation/deeplab_v3/src/resnet_backbone.py
  function conv3x3 (line 5) | def conv3x3(in_planes, out_planes, stride=1, groups=1, dilation=1):
  function conv1x1 (line 11) | def conv1x1(in_planes, out_planes, stride=1):
  class Bottleneck (line 16) | class Bottleneck(nn.Module):
    method __init__ (line 25) | def __init__(self, inplanes, planes, stride=1, downsample=None, groups=1,
    method forward (line 42) | def forward(self, x):
  class ResNet (line 65) | class ResNet(nn.Module):
    method __init__ (line 67) | def __init__(self, block, layers, num_classes=1000, zero_init_residual...
    method _make_layer (line 116) | def _make_layer(self, block, planes, blocks, stride=1, dilate=False):
    method _forward_impl (line 140) | def _forward_impl(self, x):
    method forward (line 158) | def forward(self, x):
  function _resnet (line 162) | def _resnet(block, layers, **kwargs):
  function resnet50 (line 167) | def resnet50(**kwargs):
  function resnet101 (line 178) | def resnet101(**kwargs):

FILE: pytorch_segmentation/deeplab_v3/train.py
  class SegmentationPresetTrain (line 13) | class SegmentationPresetTrain:
    method __init__ (line 14) | def __init__(self, base_size, crop_size, hflip_prob=0.5, mean=(0.485, ...
    method __call__ (line 28) | def __call__(self, img, target):
  class SegmentationPresetEval (line 32) | class SegmentationPresetEval:
    method __init__ (line 33) | def __init__(self, base_size, mean=(0.485, 0.456, 0.406), std=(0.229, ...
    method __call__ (line 40) | def __call__(self, img, target):
  function get_transform (line 44) | def get_transform(train):
  function create_model (line 51) | def create_model(aux, num_classes, pretrain=True):
  function main (line 72) | def main(args):
  function parse_args (line 178) | def parse_args():

FILE: pytorch_segmentation/deeplab_v3/train_multi_GPU.py
  class SegmentationPresetTrain (line 13) | class SegmentationPresetTrain:
    method __init__ (line 14) | def __init__(self, base_size, crop_size, hflip_prob=0.5, mean=(0.485, ...
    method __call__ (line 28) | def __call__(self, img, target):
  class SegmentationPresetEval (line 32) | class SegmentationPresetEval:
    method __init__ (line 33) | def __init__(self, base_size, mean=(0.485, 0.456, 0.406), std=(0.229, ...
    method __call__ (line 40) | def __call__(self, img, target):
  function get_transform (line 44) | def get_transform(train):
  function create_model (line 51) | def create_model(aux, num_classes):
  function main (line 70) | def main(args):

FILE: pytorch_segmentation/deeplab_v3/train_utils/distributed_utils.py
  class SmoothedValue (line 11) | class SmoothedValue(object):
    method __init__ (line 16) | def __init__(self, window_size=20, fmt=None):
    method update (line 24) | def update(self, value, n=1):
    method synchronize_between_processes (line 29) | def synchronize_between_processes(self):
    method median (line 43) | def median(self):
    method avg (line 48) | def avg(self):
    method global_avg (line 53) | def global_avg(self):
    method max (line 57) | def max(self):
    method value (line 61) | def value(self):
    method __str__ (line 64) | def __str__(self):
  class ConfusionMatrix (line 73) | class ConfusionMatrix(object):
    method __init__ (line 74) | def __init__(self, num_classes):
    method update (line 78) | def update(self, a, b):
    method reset (line 90) | def reset(self):
    method compute (line 94) | def compute(self):
    method reduce_from_all_processes (line 104) | def reduce_from_all_processes(self):
    method __str__ (line 112) | def __str__(self):
  class MetricLogger (line 125) | class MetricLogger(object):
    method __init__ (line 126) | def __init__(self, delimiter="\t"):
    method update (line 130) | def update(self, **kwargs):
    method __getattr__ (line 137) | def __getattr__(self, attr):
    method __str__ (line 145) | def __str__(self):
    method synchronize_between_processes (line 153) | def synchronize_between_processes(self):
    method add_meter (line 157) | def add_meter(self, name, meter):
    method log_every (line 160) | def log_every(self, iterable, print_freq, header=None):
  function mkdir (line 214) | def mkdir(path):
  function setup_for_distributed (line 222) | def setup_for_distributed(is_master):
  function is_dist_avail_and_initialized (line 237) | def is_dist_avail_and_initialized():
  function get_world_size (line 245) | def get_world_size():
  function get_rank (line 251) | def get_rank():
  function is_main_process (line 257) | def is_main_process():
  function save_on_master (line 261) | def save_on_master(*args, **kwargs):
  function init_distributed_mode (line 266) | def init_distributed_mode(args):

FILE: pytorch_segmentation/deeplab_v3/train_utils/train_and_eval.py
  function criterion (line 6) | def criterion(inputs, target):
  function evaluate (line 18) | def evaluate(model, data_loader, device, num_classes):
  function train_one_epoch (line 36) | def train_one_epoch(model, optimizer, data_loader, device, epoch, lr_sch...
  function create_lr_scheduler (line 65) | def create_lr_scheduler(optimizer,

FILE: pytorch_segmentation/deeplab_v3/transforms.py
  function pad_if_smaller (line 9) | def pad_if_smaller(img, size, fill=0):
  class Compose (line 20) | class Compose(object):
    method __init__ (line 21) | def __init__(self, transforms):
    method __call__ (line 24) | def __call__(self, image, target):
  class RandomResize (line 30) | class RandomResize(object):
    method __init__ (line 31) | def __init__(self, min_size, max_size=None):
    method __call__ (line 37) | def __call__(self, image, target):
  class RandomHorizontalFlip (line 47) | class RandomHorizontalFlip(object):
    method __init__ (line 48) | def __init__(self, flip_prob):
    method __call__ (line 51) | def __call__(self, image, target):
  class RandomCrop (line 58) | class RandomCrop(object):
    method __init__ (line 59) | def __init__(self, size):
    method __call__ (line 62) | def __call__(self, image, target):
  class CenterCrop (line 71) | class CenterCrop(object):
    method __init__ (line 72) | def __init__(self, size):
    method __call__ (line 75) | def __call__(self, image, target):
  class ToTensor (line 81) | class ToTensor(object):
    method __call__ (line 82) | def __call__(self, image, target):
  class Normalize (line 88) | class Normalize(object):
    method __init__ (line 89) | def __init__(self, mean, std):
    method __call__ (line 93) | def __call__(self, image, target):

FILE: pytorch_segmentation/deeplab_v3/validation.py
  class SegmentationPresetEval (line 10) | class SegmentationPresetEval:
    method __init__ (line 11) | def __init__(self, base_size, mean=(0.485, 0.456, 0.406), std=(0.229, ...
    method __call__ (line 18) | def __call__(self, img, target):
  function main (line 22) | def main(args):
  function parse_args (line 50) | def parse_args():

FILE: pytorch_segmentation/fcn/my_dataset.py
  class VOCSegmentation (line 7) | class VOCSegmentation(data.Dataset):
    method __init__ (line 8) | def __init__(self, voc_root, year="2012", transforms=None, txt_name: s...
    method __getitem__ (line 26) | def __getitem__(self, index):
    method __len__ (line 42) | def __len__(self):
    method collate_fn (line 46) | def collate_fn(batch):
  function cat_list (line 53) | def cat_list(images, fill_value=0):

FILE: pytorch_segmentation/fcn/predict.py
  function time_synchronized (line 13) | def time_synchronized():
  function main (line 18) | def main():

FILE: pytorch_segmentation/fcn/src/backbone.py
  function conv3x3 (line 5) | def conv3x3(in_planes, out_planes, stride=1, groups=1, dilation=1):
  function conv1x1 (line 11) | def conv1x1(in_planes, out_planes, stride=1):
  class Bottleneck (line 16) | class Bottleneck(nn.Module):
    method __init__ (line 25) | def __init__(self, inplanes, planes, stride=1, downsample=None, groups=1,
    method forward (line 42) | def forward(self, x):
  class ResNet (line 65) | class ResNet(nn.Module):
    method __init__ (line 67) | def __init__(self, block, layers, num_classes=1000, zero_init_residual...
    method _make_layer (line 116) | def _make_layer(self, block, planes, blocks, stride=1, dilate=False):
   
Condensed preview — 593 files, each showing path, character count, and a content snippet. Download the .json file or copy for the full structured content (3,687K chars).
[
  {
    "path": ".github/ISSUE_TEMPLATE/issue-template.md",
    "chars": 481,
    "preview": "---\nname: Issue template\nabout: Use this template for reporting your problem\ntitle: ''\nlabels: ''\nassignees: ''\n\n---\n\n**"
  },
  {
    "path": ".gitignore",
    "chars": 217,
    "preview": "##ignore this file##\n*.idea\n__pycache__\n*.zip\nflower_data\n*.h5\n*.pth\n*.pt\n*.jpg\n*.ckpt.*\n*.ckpt\n*.config\n*.gz\n*.onnx\n*.x"
  },
  {
    "path": "LICENSE",
    "chars": 35149,
    "preview": "                    GNU GENERAL PUBLIC LICENSE\n                       Version 3, 29 June 2007\n\n Copyright (C) 2007 Free "
  },
  {
    "path": "README.md",
    "chars": 6610,
    "preview": "# 深度学习在图像处理中的应用教程\n\n## 前言\n* 本教程是对本人研究生期间的研究内容进行整理总结,总结的同时也希望能够帮助更多的小伙伴。后期如果有学习到新的知识也会与大家一起分享。\n* 本教程会以视频的方式进行分享,教学流程如下:  \n"
  },
  {
    "path": "article_link/README.md",
    "chars": 8487,
    "preview": "# 文献链接\n\n## 图像分类(Classification)\n- LeNet [http://yann.lecun.com/exdb/lenet/index.html](http://yann.lecun.com/exdb/lenet/i"
  },
  {
    "path": "course_ppt/README.md",
    "chars": 3649,
    "preview": "# 为了精简项目,课程中的所有ppt都已转存至百度云\n\n**所有PPT都放在该文件夹中** 链接:https://pan.baidu.com/s/1VL6QTQ86sfY2aMDVo4Z-kg 提取码:4ydw\n\n**下面为单独每个ppt的"
  },
  {
    "path": "data_set/README.md",
    "chars": 487,
    "preview": "## 该文件夹是用来存放训练数据的目录\n### 使用步骤如下:\n* (1)在data_set文件夹下创建新文件夹\"flower_data\"\n* (2)点击链接下载花分类数据集 [https://storage.googleapis.com/"
  },
  {
    "path": "data_set/split_data.py",
    "chars": 2005,
    "preview": "import os\nfrom shutil import copy, rmtree\nimport random\n\n\ndef mk_file(file_path: str):\n    if os.path.exists(file_path):"
  },
  {
    "path": "deploying_service/deploying_pytorch/convert_onnx_cls/class_indices.json",
    "chars": 102,
    "preview": "{\n    \"0\": \"daisy\",\n    \"1\": \"dandelion\",\n    \"2\": \"roses\",\n    \"3\": \"sunflowers\",\n    \"4\": \"tulips\"\n}"
  },
  {
    "path": "deploying_service/deploying_pytorch/convert_onnx_cls/main.py",
    "chars": 3209,
    "preview": "from PIL import Image\nimport torchvision.transforms as transforms\nimport torch\nimport torch.onnx\nimport onnx\nimport onnx"
  },
  {
    "path": "deploying_service/deploying_pytorch/convert_onnx_cls/model.py",
    "chars": 5003,
    "preview": "import torch.nn as nn\nimport torch\n\n\nclass BasicBlock(nn.Module):\n    expansion = 1\n\n    def __init__(self, in_channel, "
  },
  {
    "path": "deploying_service/deploying_pytorch/convert_openvino/convert_resnet34/README.md",
    "chars": 599,
    "preview": "本项目展示如何将Pytorch中的ResNet34网络转成Openvino的IR格式,并进行量化处理,具体使用流程如下:\n1. 按照`requirements.txt`配置环境\n2. 下载事先训练好的ResNet34权重(之前在花分类数据集"
  },
  {
    "path": "deploying_service/deploying_pytorch/convert_openvino/convert_resnet34/compare_fps.py",
    "chars": 3733,
    "preview": "import time\nimport numpy as np\nimport torch\nimport onnxruntime\nimport matplotlib.pyplot as plt\nfrom openvino.runtime imp"
  },
  {
    "path": "deploying_service/deploying_pytorch/convert_openvino/convert_resnet34/compare_onnx_and_ir.py",
    "chars": 1981,
    "preview": "import numpy as np\nimport onnxruntime\nfrom openvino.runtime import Core\n\n\ndef normalize(image: np.ndarray) -> np.ndarray"
  },
  {
    "path": "deploying_service/deploying_pytorch/convert_openvino/convert_resnet34/convert_pytorch2onnx.py",
    "chars": 1797,
    "preview": "import torch\nimport torch.onnx\nimport onnx\nimport onnxruntime\nimport numpy as np\nfrom torchvision.models import resnet34"
  },
  {
    "path": "deploying_service/deploying_pytorch/convert_openvino/convert_resnet34/model.py",
    "chars": 12689,
    "preview": "from typing import Callable, List, Optional\n\nimport torch\nfrom torch import nn, Tensor\nfrom torch.nn import functional a"
  },
  {
    "path": "deploying_service/deploying_pytorch/convert_openvino/convert_resnet34/quantization_int8.py",
    "chars": 2848,
    "preview": "from addict import Dict\nfrom compression.engines.ie_engine import IEEngine\nfrom compression.graph import load_model, sav"
  },
  {
    "path": "deploying_service/deploying_pytorch/convert_openvino/convert_resnet34/requirements.txt",
    "chars": 116,
    "preview": "torch==1.11.0\ntorchvision==0.12.0\nonnx==1.13.0\nonnxruntime==1.8.0\nprotobuf==3.19.5\nopenvino-dev==2022.1.0\nmatplotlib"
  },
  {
    "path": "deploying_service/deploying_pytorch/convert_openvino/convert_resnet34/utils.py",
    "chars": 4895,
    "preview": "import os\nimport json\nimport random\n\nfrom PIL import Image\nimport numpy as np\nfrom compression.api import DataLoader, Me"
  },
  {
    "path": "deploying_service/deploying_pytorch/convert_openvino/convert_yolov5/README.md",
    "chars": 1525,
    "preview": "OpenVINO量化YOLOv5\n\n1. 按照`requirements.txt`配置环境\n2. 将YOLOv5转为ONNX\nYOLOv5官方有提供导出ONNX以及OpenVINO的方法,但我这里仅导出成ONNX,这里以YOLOv5s为例\n"
  },
  {
    "path": "deploying_service/deploying_pytorch/convert_openvino/convert_yolov5/compare_fps.py",
    "chars": 3597,
    "preview": "import time\nimport numpy as np\nimport torch\nimport onnxruntime\nimport matplotlib.pyplot as plt\nfrom openvino.runtime imp"
  },
  {
    "path": "deploying_service/deploying_pytorch/convert_openvino/convert_yolov5/compare_onnx_and_ir.py",
    "chars": 1879,
    "preview": "import numpy as np\nimport onnxruntime\nfrom openvino.runtime import Core\n\n\ndef normalize(image: np.ndarray) -> np.ndarray"
  },
  {
    "path": "deploying_service/deploying_pytorch/convert_openvino/convert_yolov5/draw_box_utils.py",
    "chars": 5803,
    "preview": "from PIL.Image import Image, fromarray\nimport PIL.ImageDraw as ImageDraw\nimport PIL.ImageFont as ImageFont\nfrom PIL impo"
  },
  {
    "path": "deploying_service/deploying_pytorch/convert_openvino/convert_yolov5/evaluation.py",
    "chars": 1440,
    "preview": "from tqdm import tqdm\nimport torch\nfrom openvino.runtime import Core\nfrom utils import MyDataLoader, EvalCOCOMetric, non"
  },
  {
    "path": "deploying_service/deploying_pytorch/convert_openvino/convert_yolov5/predict.py",
    "chars": 1689,
    "preview": "import cv2\nimport numpy as np\nimport torch\nfrom PIL import Image\nimport matplotlib.pyplot as plt\nfrom openvino.runtime i"
  },
  {
    "path": "deploying_service/deploying_pytorch/convert_openvino/convert_yolov5/quantization_int8.py",
    "chars": 3552,
    "preview": "import time\nfrom addict import Dict\nfrom compression.engines.ie_engine import IEEngine\nfrom compression.graph import loa"
  },
  {
    "path": "deploying_service/deploying_pytorch/convert_openvino/convert_yolov5/requirements.txt",
    "chars": 136,
    "preview": "torch==1.13.1\ntorchvision==0.12.0\nonnx==1.13.0\nonnxruntime==1.8.0\nprotobuf==3.19.5\nopenvino-dev==2022.1.0\nmatplotlib\ntor"
  },
  {
    "path": "deploying_service/deploying_pytorch/convert_openvino/convert_yolov5/utils.py",
    "chars": 21523,
    "preview": "import os\nimport time\nimport json\nimport copy\n\nimport cv2\nimport numpy as np\nimport torch\nfrom torchmetrics.detection.me"
  },
  {
    "path": "deploying_service/deploying_pytorch/convert_tensorrt/convert_resnet34/compare_onnx_and_trt.py",
    "chars": 3181,
    "preview": "import numpy as np\nimport tensorrt as trt\nimport onnxruntime\nimport pycuda.driver as cuda\nimport pycuda.autoinit\n\n\ndef n"
  },
  {
    "path": "deploying_service/deploying_pytorch/convert_tensorrt/convert_resnet34/convert_pytorch2onnx.py",
    "chars": 1889,
    "preview": "import torch\nimport torch.onnx\nimport onnx\nimport onnxruntime\nimport numpy as np\nfrom torchvision.models import resnet34"
  },
  {
    "path": "deploying_service/deploying_pytorch/convert_tensorrt/convert_resnet34/my_dataset.py",
    "chars": 1113,
    "preview": "from PIL import Image\nimport torch\nfrom torch.utils.data import Dataset\n\n\nclass MyDataSet(Dataset):\n    \"\"\"自定义数据集\"\"\"\n\n  "
  },
  {
    "path": "deploying_service/deploying_pytorch/convert_tensorrt/convert_resnet34/quantization.py",
    "chars": 7914,
    "preview": "\"\"\"\nrefer to:\nhttps://docs.nvidia.com/deeplearning/tensorrt/pytorch-quantization-toolkit/docs/userguide.html\n\"\"\"\nimport "
  },
  {
    "path": "deploying_service/deploying_pytorch/convert_tensorrt/convert_resnet34/utils.py",
    "chars": 4630,
    "preview": "import os\nimport sys\nimport json\nimport pickle\nimport random\n\nimport torch\nfrom tqdm import tqdm\n\n\ndef read_split_data(r"
  },
  {
    "path": "deploying_service/deploying_pytorch/pytorch_flask_service/class_indices.json",
    "chars": 102,
    "preview": "{\n    \"0\": \"daisy\",\n    \"1\": \"dandelion\",\n    \"2\": \"roses\",\n    \"3\": \"sunflowers\",\n    \"4\": \"tulips\"\n}"
  },
  {
    "path": "deploying_service/deploying_pytorch/pytorch_flask_service/main.py",
    "chars": 2517,
    "preview": "import os\nimport io\nimport json\nimport torch\nimport torchvision.transforms as transforms\nfrom PIL import Image\nfrom flas"
  },
  {
    "path": "deploying_service/deploying_pytorch/pytorch_flask_service/model.py",
    "chars": 4109,
    "preview": "from torch import nn\nimport torch\n\n\ndef _make_divisible(ch, divisor=8, min_ch=None):\n    \"\"\"\n    This function is taken "
  },
  {
    "path": "deploying_service/deploying_pytorch/pytorch_flask_service/requirements.txt",
    "chars": 38,
    "preview": "Flask==2.2.5\nFlask_Cors==3.0.9\nPillow\n"
  },
  {
    "path": "deploying_service/deploying_pytorch/pytorch_flask_service/templates/up.html",
    "chars": 4311,
    "preview": "<!DOCTYPE html>\r\n<html>\r\n<head>\r\n    <title>HTML5上传图片并预览</title>\r\n    <meta http-equiv=\"Content-Type\" content=\"text/html"
  },
  {
    "path": "deploying_service/pruning_model_pytorch/class_indices.json",
    "chars": 102,
    "preview": "{\n    \"0\": \"daisy\",\n    \"1\": \"dandelion\",\n    \"2\": \"roses\",\n    \"3\": \"sunflowers\",\n    \"4\": \"tulips\"\n}"
  },
  {
    "path": "deploying_service/pruning_model_pytorch/main.py",
    "chars": 3806,
    "preview": "import os\nimport torch\nfrom torchvision import transforms, datasets\nimport torch.nn.utils.prune as prune\nimport torch.nn"
  },
  {
    "path": "deploying_service/pruning_model_pytorch/model.py",
    "chars": 5003,
    "preview": "import torch.nn as nn\nimport torch\n\n\nclass BasicBlock(nn.Module):\n    expansion = 1\n\n    def __init__(self, in_channel, "
  },
  {
    "path": "deploying_service/pruning_model_pytorch/predict.py",
    "chars": 1188,
    "preview": "import torch\nfrom model import resnet34\nfrom PIL import Image\nfrom torchvision import transforms\nimport matplotlib.pyplo"
  },
  {
    "path": "deploying_service/pruning_model_pytorch/train.py",
    "chars": 4045,
    "preview": "import torch\nimport torch.nn as nn\nfrom torchvision import transforms, datasets\nimport json\nimport matplotlib.pyplot as "
  },
  {
    "path": "others_project/draw_dilated_conv/main.py",
    "chars": 2708,
    "preview": "import numpy as np\nimport matplotlib.pyplot as plt\nfrom matplotlib.colors import LinearSegmentedColormap\n\n\ndef dilated_c"
  },
  {
    "path": "others_project/kmeans_anchors/main.py",
    "chars": 2769,
    "preview": "import random\nimport numpy as np\nfrom tqdm import tqdm\nfrom scipy.cluster.vq import kmeans\n\nfrom read_voc import VOCData"
  },
  {
    "path": "others_project/kmeans_anchors/plot_kmeans.py",
    "chars": 2072,
    "preview": "import numpy as np\nfrom matplotlib import pyplot as plt\nnp.random.seed(0)\n\ncolors = np.array(['blue', 'black'])\n\n\ndef pl"
  },
  {
    "path": "others_project/kmeans_anchors/read_voc.py",
    "chars": 2900,
    "preview": "import os\nfrom tqdm import tqdm\nfrom lxml import etree\n\n\nclass VOCDataSet(object):\n    def __init__(self, voc_root, year"
  },
  {
    "path": "others_project/kmeans_anchors/yolo_kmeans.py",
    "chars": 1183,
    "preview": "import numpy as np\n\n\ndef wh_iou(wh1, wh2):\n    # Returns the nxm IoU matrix. wh1 is nx2, wh2 is mx2\n    wh1 = wh1[:, Non"
  },
  {
    "path": "others_project/openvinotest/openvino_cls_test/class_indices.json",
    "chars": 102,
    "preview": "{\n    \"0\": \"daisy\",\n    \"1\": \"dandelion\",\n    \"2\": \"roses\",\n    \"3\": \"sunflowers\",\n    \"4\": \"tulips\"\n}"
  },
  {
    "path": "others_project/openvinotest/openvino_cls_test/create_imagenet_annotation.py",
    "chars": 1049,
    "preview": "import os\nimport glob\n\nimage_dir = \"/home/w180662/my_project/my_github/data_set/flower_data/train\"\nassert os.path.exists"
  },
  {
    "path": "others_project/openvinotest/openvino_cls_test/float32vsint8.py",
    "chars": 3661,
    "preview": "import os\nimport time\nimport torch\nfrom torchvision import transforms, datasets\nfrom tqdm import tqdm\nimport numpy as np"
  },
  {
    "path": "others_project/openvinotest/openvino_cls_test/main.py",
    "chars": 3448,
    "preview": "import sys\nimport cv2\nimport os\nimport glob\nimport json\nimport numpy as np\nimport logging as log\nfrom openvino.inference"
  },
  {
    "path": "others_project/openvinotest/openvino_cls_test/model.py",
    "chars": 5003,
    "preview": "import torch.nn as nn\nimport torch\n\n\nclass BasicBlock(nn.Module):\n    expansion = 1\n\n    def __init__(self, in_channel, "
  },
  {
    "path": "others_project/openvinotest/openvino_cls_test/speed_test.py",
    "chars": 5932,
    "preview": "import os\nimport time\nimport torch\nfrom torchvision import transforms, datasets\nfrom tqdm import tqdm\nimport onnx\nimport"
  },
  {
    "path": "others_project/readPbFile/README.md",
    "chars": 283,
    "preview": "该项目用于读取冻结后的pb文件并进行预测  \n使用步骤:   \n(1)准备好需要使用的pb冻结文件,pbtxt标签文件,测试用的图片  \n(2)修改info.config文件中的相关信息  \n\n![Example image](https:"
  },
  {
    "path": "others_project/readPbFile/pascal_label_map.pbtxt",
    "chars": 705,
    "preview": "item {\n  id: 1\n  name: 'aeroplane'\n}\n\nitem {\n  id: 2\n  name: 'bicycle'\n}\n\nitem {\n  id: 3\n  name: 'bird'\n}\n\nitem {\n  id: "
  },
  {
    "path": "others_project/readPbFile/readPb.py",
    "chars": 2114,
    "preview": "import tensorflow as tf\nimport configparser\nfrom distutils.version import StrictVersion\nimport cv2\nimport glob\nfrom usin"
  },
  {
    "path": "others_project/readPbFile/test_images/image_info.txt",
    "chars": 230,
    "preview": "\nImage provenance:\nimage1.jpg: https://commons.wikimedia.org/wiki/File:Baegle_dwa.jpg\nimage2.jpg: Michael Miley,\n  https"
  },
  {
    "path": "others_project/readPbFile/using_function.py",
    "chars": 6772,
    "preview": "import collections\nimport six\nimport PIL.Image as Image\nimport PIL.ImageDraw as ImageDraw\nimport PIL.ImageFont as ImageF"
  },
  {
    "path": "others_project/textcnnKeras/dataGenerator.py",
    "chars": 1935,
    "preview": "from tensorflow import keras\nfrom sklearn.preprocessing import LabelEncoder\nimport random\n\n\ndef content2idList(content, "
  },
  {
    "path": "others_project/textcnnKeras/data_link.txt",
    "chars": 86,
    "preview": "baidupan_url = \"https://pan.baidu.com/s/1w452Z5eXbQSDQfgEBNUdlg\"\nextract_code = \"8cwv\""
  },
  {
    "path": "others_project/textcnnKeras/main.py",
    "chars": 1409,
    "preview": "from models import text_cnn, simpleNet, text_cnn_V2\nfrom dataGenerator import generatorInfo\nfrom tensorflow import keras"
  },
  {
    "path": "others_project/textcnnKeras/models.py",
    "chars": 4090,
    "preview": "from tensorflow import keras\n\n\ndef text_cnn(seq_length, vocab_size, embedding_dim, num_cla, kernelNum):\n    \"\"\"\n    :par"
  },
  {
    "path": "others_project/trans_widerface_to_xml/create_xml.py",
    "chars": 4713,
    "preview": "import copy\r\nimport os\r\nfrom xml.dom import minidom as dom\r\n\r\n\r\nclass XMLGenerator(object):\r\n    def __init__(self, xml_"
  },
  {
    "path": "others_project/trans_widerface_to_xml/main.py",
    "chars": 4399,
    "preview": "import os\n\nfrom tqdm import tqdm\nimport cv2\nfrom create_xml import create_pascal_voc_xml\n\n\ndef create_xml(labels: list, "
  },
  {
    "path": "pytorch_classification/ConfusionMatrix/class_indices.json",
    "chars": 102,
    "preview": "{\n    \"0\": \"daisy\",\n    \"1\": \"dandelion\",\n    \"2\": \"roses\",\n    \"3\": \"sunflowers\",\n    \"4\": \"tulips\"\n}"
  },
  {
    "path": "pytorch_classification/ConfusionMatrix/main.py",
    "chars": 4719,
    "preview": "import os\nimport json\n\nimport torch\nfrom torchvision import transforms, datasets\nimport numpy as np\nfrom tqdm import tqd"
  },
  {
    "path": "pytorch_classification/ConfusionMatrix/model.py",
    "chars": 4109,
    "preview": "from torch import nn\nimport torch\n\n\ndef _make_divisible(ch, divisor=8, min_ch=None):\n    \"\"\"\n    This function is taken "
  },
  {
    "path": "pytorch_classification/ConvNeXt/README.md",
    "chars": 864,
    "preview": "## 代码使用简介\n\n1. 下载好数据集,代码中默认使用的是花分类数据集,下载地址: [https://storage.googleapis.com/download.tensorflow.org/example_images/flower"
  },
  {
    "path": "pytorch_classification/ConvNeXt/model.py",
    "chars": 9224,
    "preview": "\"\"\"\noriginal code from facebook research:\nhttps://github.com/facebookresearch/ConvNeXt\n\"\"\"\n\nimport torch\nimport torch.nn"
  },
  {
    "path": "pytorch_classification/ConvNeXt/my_dataset.py",
    "chars": 1113,
    "preview": "from PIL import Image\nimport torch\nfrom torch.utils.data import Dataset\n\n\nclass MyDataSet(Dataset):\n    \"\"\"自定义数据集\"\"\"\n\n  "
  },
  {
    "path": "pytorch_classification/ConvNeXt/predict.py",
    "chars": 1983,
    "preview": "import os\nimport json\n\nimport torch\nfrom PIL import Image\nfrom torchvision import transforms\nimport matplotlib.pyplot as"
  },
  {
    "path": "pytorch_classification/ConvNeXt/train.py",
    "chars": 6078,
    "preview": "import os\nimport argparse\n\nimport torch\nimport torch.optim as optim\nfrom torch.utils.tensorboard import SummaryWriter\nfr"
  },
  {
    "path": "pytorch_classification/ConvNeXt/utils.py",
    "chars": 8300,
    "preview": "import os\nimport sys\nimport json\nimport pickle\nimport random\nimport math\n\nimport torch\nfrom tqdm import tqdm\n\nimport mat"
  },
  {
    "path": "pytorch_classification/MobileViT/README.md",
    "chars": 864,
    "preview": "## 代码使用简介\n\n1. 下载好数据集,代码中默认使用的是花分类数据集,下载地址: [https://storage.googleapis.com/download.tensorflow.org/example_images/flower"
  },
  {
    "path": "pytorch_classification/MobileViT/model.py",
    "chars": 19702,
    "preview": "\"\"\"\noriginal code from apple:\nhttps://github.com/apple/ml-cvnets/blob/main/cvnets/models/classification/mobilevit.py\n\"\"\""
  },
  {
    "path": "pytorch_classification/MobileViT/model_config.py",
    "chars": 5783,
    "preview": "def get_config(mode: str = \"xxs\") -> dict:\n    if mode == \"xx_small\":\n        mv2_exp_mult = 2\n        config = {\n      "
  },
  {
    "path": "pytorch_classification/MobileViT/my_dataset.py",
    "chars": 1113,
    "preview": "from PIL import Image\nimport torch\nfrom torch.utils.data import Dataset\n\n\nclass MyDataSet(Dataset):\n    \"\"\"自定义数据集\"\"\"\n\n  "
  },
  {
    "path": "pytorch_classification/MobileViT/predict.py",
    "chars": 1922,
    "preview": "import os\nimport json\n\nimport torch\nfrom PIL import Image\nfrom torchvision import transforms\nimport matplotlib.pyplot as"
  },
  {
    "path": "pytorch_classification/MobileViT/train.py",
    "chars": 5739,
    "preview": "import os\nimport argparse\n\nimport torch\nimport torch.optim as optim\nfrom torch.utils.tensorboard import SummaryWriter\nfr"
  },
  {
    "path": "pytorch_classification/MobileViT/transformer.py",
    "chars": 5008,
    "preview": "from typing import Optional\n\nimport torch\nimport torch.nn as nn\nfrom torch import Tensor\n\n\nclass MultiHeadAttention(nn.M"
  },
  {
    "path": "pytorch_classification/MobileViT/unfold_test.py",
    "chars": 1753,
    "preview": "import time\nimport torch\n\nbatch_size = 8\nin_channels = 32\npatch_h = 2\npatch_w = 2\nnum_patch_h = 16\nnum_patch_w = 16\nnum_"
  },
  {
    "path": "pytorch_classification/MobileViT/utils.py",
    "chars": 6376,
    "preview": "import os\nimport sys\nimport json\nimport pickle\nimport random\n\nimport torch\nfrom tqdm import tqdm\n\nimport matplotlib.pypl"
  },
  {
    "path": "pytorch_classification/README.md",
    "chars": 256,
    "preview": "## 该文件夹存放使用pytorch实现的代码版本\n**model.py**: 是模型文件  \n**train.py**: 是调用模型训练的文件    \n**predict.py**: 是调用模型进行预测的文件  \n**class_indi"
  },
  {
    "path": "pytorch_classification/Test10_regnet/README.md",
    "chars": 890,
    "preview": "## 代码使用简介\n\n1. 下载好数据集,代码中默认使用的是花分类数据集,下载地址: [https://storage.googleapis.com/download.tensorflow.org/example_images/flower"
  },
  {
    "path": "pytorch_classification/Test10_regnet/model.py",
    "chars": 11457,
    "preview": "from typing import Optional\n\nimport numpy as np\nimport torch\nimport torch.nn as nn\nfrom torch import Tensor\n\n\ndef _make_"
  },
  {
    "path": "pytorch_classification/Test10_regnet/my_dataset.py",
    "chars": 1113,
    "preview": "from PIL import Image\nimport torch\nfrom torch.utils.data import Dataset\n\n\nclass MyDataSet(Dataset):\n    \"\"\"自定义数据集\"\"\"\n\n  "
  },
  {
    "path": "pytorch_classification/Test10_regnet/predict.py",
    "chars": 1886,
    "preview": "import os\nimport json\n\nimport torch\nfrom PIL import Image\nfrom torchvision import transforms\nimport matplotlib.pyplot as"
  },
  {
    "path": "pytorch_classification/Test10_regnet/pretrain_weights.py",
    "chars": 4286,
    "preview": "import requests\n\n\ndownload_links = {\n    \"regnetx_200mf\": 'https://github.com/rwightman/pytorch-image-models/releases/do"
  },
  {
    "path": "pytorch_classification/Test10_regnet/train.py",
    "chars": 6004,
    "preview": "import os\nimport math\nimport argparse\n\nimport torch\nimport torch.optim as optim\nfrom torch.utils.tensorboard import Summ"
  },
  {
    "path": "pytorch_classification/Test10_regnet/utils.py",
    "chars": 5382,
    "preview": "import os\nimport sys\nimport json\nimport pickle\nimport random\n\nimport torch\nfrom tqdm import tqdm\n\nimport matplotlib.pypl"
  },
  {
    "path": "pytorch_classification/Test11_efficientnetV2/README.md",
    "chars": 890,
    "preview": "## 代码使用简介\n\n1. 下载好数据集,代码中默认使用的是花分类数据集,下载地址: [https://storage.googleapis.com/download.tensorflow.org/example_images/flower"
  },
  {
    "path": "pytorch_classification/Test11_efficientnetV2/class_indices.json",
    "chars": 102,
    "preview": "{\n    \"0\": \"daisy\",\n    \"1\": \"dandelion\",\n    \"2\": \"roses\",\n    \"3\": \"sunflowers\",\n    \"4\": \"tulips\"\n}"
  },
  {
    "path": "pytorch_classification/Test11_efficientnetV2/model.py",
    "chars": 13355,
    "preview": "from collections import OrderedDict\nfrom functools import partial\nfrom typing import Callable, Optional\n\nimport torch.nn"
  },
  {
    "path": "pytorch_classification/Test11_efficientnetV2/my_dataset.py",
    "chars": 1113,
    "preview": "from PIL import Image\nimport torch\nfrom torch.utils.data import Dataset\n\n\nclass MyDataSet(Dataset):\n    \"\"\"自定义数据集\"\"\"\n\n  "
  },
  {
    "path": "pytorch_classification/Test11_efficientnetV2/predict.py",
    "chars": 2046,
    "preview": "import os\nimport json\n\nimport torch\nfrom PIL import Image\nfrom torchvision import transforms\nimport matplotlib.pyplot as"
  },
  {
    "path": "pytorch_classification/Test11_efficientnetV2/train.py",
    "chars": 6281,
    "preview": "import os\nimport math\nimport argparse\n\nimport torch\nimport torch.optim as optim\nfrom torch.utils.tensorboard import Summ"
  },
  {
    "path": "pytorch_classification/Test11_efficientnetV2/trans_effv2_weights.py",
    "chars": 8695,
    "preview": "import tensorflow as tf\nimport torch\nimport numpy as np\n\n\ndef main(model_name: str = \"efficientnetv2-s\",\n         tf_wei"
  },
  {
    "path": "pytorch_classification/Test11_efficientnetV2/utils.py",
    "chars": 6357,
    "preview": "import os\nimport sys\nimport json\nimport pickle\nimport random\n\nimport torch\nfrom tqdm import tqdm\n\nimport matplotlib.pypl"
  },
  {
    "path": "pytorch_classification/Test1_official_demo/model.py",
    "chars": 920,
    "preview": "import torch.nn as nn\nimport torch.nn.functional as F\n\n\nclass LeNet(nn.Module):\n    def __init__(self):\n        super(Le"
  },
  {
    "path": "pytorch_classification/Test1_official_demo/predict.py",
    "chars": 768,
    "preview": "import torch\nimport torchvision.transforms as transforms\nfrom PIL import Image\n\nfrom model import LeNet\n\n\ndef main():\n  "
  },
  {
    "path": "pytorch_classification/Test1_official_demo/train.py",
    "chars": 2589,
    "preview": "import torch\nimport torchvision\nimport torch.nn as nn\nfrom model import LeNet\nimport torch.optim as optim\nimport torchvi"
  },
  {
    "path": "pytorch_classification/Test2_alexnet/class_indices.json",
    "chars": 102,
    "preview": "{\n    \"0\": \"daisy\",\n    \"1\": \"dandelion\",\n    \"2\": \"roses\",\n    \"3\": \"sunflowers\",\n    \"4\": \"tulips\"\n}"
  },
  {
    "path": "pytorch_classification/Test2_alexnet/model.py",
    "chars": 2061,
    "preview": "import torch.nn as nn\nimport torch\n\n\nclass AlexNet(nn.Module):\n    def __init__(self, num_classes=1000, init_weights=Fal"
  },
  {
    "path": "pytorch_classification/Test2_alexnet/predict.py",
    "chars": 1858,
    "preview": "import os\nimport json\n\nimport torch\nfrom PIL import Image\nfrom torchvision import transforms\nimport matplotlib.pyplot as"
  },
  {
    "path": "pytorch_classification/Test2_alexnet/train.py",
    "chars": 5018,
    "preview": "import os\nimport sys\nimport json\n\nimport torch\nimport torch.nn as nn\nfrom torchvision import transforms, datasets, utils"
  },
  {
    "path": "pytorch_classification/Test3_vggnet/class_indices.json",
    "chars": 102,
    "preview": "{\n    \"0\": \"daisy\",\n    \"1\": \"dandelion\",\n    \"2\": \"roses\",\n    \"3\": \"sunflowers\",\n    \"4\": \"tulips\"\n}"
  },
  {
    "path": "pytorch_classification/Test3_vggnet/model.py",
    "chars": 2616,
    "preview": "import torch.nn as nn\nimport torch\n\n# official pretrain weights\nmodel_urls = {\n    'vgg11': 'https://download.pytorch.or"
  },
  {
    "path": "pytorch_classification/Test3_vggnet/predict.py",
    "chars": 1894,
    "preview": "import os\nimport json\n\nimport torch\nfrom PIL import Image\nfrom torchvision import transforms\nimport matplotlib.pyplot as"
  },
  {
    "path": "pytorch_classification/Test3_vggnet/train.py",
    "chars": 4652,
    "preview": "import os\nimport sys\nimport json\n\nimport torch\nimport torch.nn as nn\nfrom torchvision import transforms, datasets\nimport"
  },
  {
    "path": "pytorch_classification/Test4_googlenet/class_indices.json",
    "chars": 102,
    "preview": "{\n    \"0\": \"daisy\",\n    \"1\": \"dandelion\",\n    \"2\": \"roses\",\n    \"3\": \"sunflowers\",\n    \"4\": \"tulips\"\n}"
  },
  {
    "path": "pytorch_classification/Test4_googlenet/model.py",
    "chars": 6068,
    "preview": "import torch.nn as nn\nimport torch\nimport torch.nn.functional as F\n\n\nclass GoogLeNet(nn.Module):\n    def __init__(self, "
  },
  {
    "path": "pytorch_classification/Test4_googlenet/predict.py",
    "chars": 2006,
    "preview": "import os\nimport json\n\nimport torch\nfrom PIL import Image\nfrom torchvision import transforms\nimport matplotlib.pyplot as"
  },
  {
    "path": "pytorch_classification/Test4_googlenet/train.py",
    "chars": 5507,
    "preview": "import os\nimport sys\nimport json\n\nimport torch\nimport torch.nn as nn\nfrom torchvision import transforms, datasets\nimport"
  },
  {
    "path": "pytorch_classification/Test5_resnet/README.md",
    "chars": 124,
    "preview": "## 文件结构:\n```\n  ├── model.py: ResNet模型搭建\n  ├── train.py: 训练脚本\n  ├── predict.py: 单张图像预测脚本\n  └── batch_predict.py: 批量图像预测脚本"
  },
  {
    "path": "pytorch_classification/Test5_resnet/batch_predict.py",
    "chars": 2393,
    "preview": "import os\nimport json\n\nimport torch\nfrom PIL import Image\nfrom torchvision import transforms\n\nfrom model import resnet34"
  },
  {
    "path": "pytorch_classification/Test5_resnet/class_indices.json",
    "chars": 102,
    "preview": "{\n    \"0\": \"daisy\",\n    \"1\": \"dandelion\",\n    \"2\": \"roses\",\n    \"3\": \"sunflowers\",\n    \"4\": \"tulips\"\n}"
  },
  {
    "path": "pytorch_classification/Test5_resnet/load_weights.py",
    "chars": 1184,
    "preview": "import os\nimport torch\nimport torch.nn as nn\nfrom model import resnet34\n\n\ndef main():\n    device = torch.device(\"cuda:0\""
  },
  {
    "path": "pytorch_classification/Test5_resnet/model.py",
    "chars": 7033,
    "preview": "import torch.nn as nn\nimport torch\n\n\nclass BasicBlock(nn.Module):\n    expansion = 1\n\n    def __init__(self, in_channel, "
  },
  {
    "path": "pytorch_classification/Test5_resnet/predict.py",
    "chars": 1940,
    "preview": "import os\nimport json\n\nimport torch\nfrom PIL import Image\nfrom torchvision import transforms\nimport matplotlib.pyplot as"
  },
  {
    "path": "pytorch_classification/Test5_resnet/train.py",
    "chars": 5364,
    "preview": "import os\nimport sys\nimport json\n\nimport torch\nimport torch.nn as nn\nimport torch.optim as optim\nfrom torchvision import"
  },
  {
    "path": "pytorch_classification/Test6_mobilenet/class_indices.json",
    "chars": 102,
    "preview": "{\n    \"0\": \"daisy\",\n    \"1\": \"dandelion\",\n    \"2\": \"roses\",\n    \"3\": \"sunflowers\",\n    \"4\": \"tulips\"\n}"
  },
  {
    "path": "pytorch_classification/Test6_mobilenet/model_v2.py",
    "chars": 4109,
    "preview": "from torch import nn\nimport torch\n\n\ndef _make_divisible(ch, divisor=8, min_ch=None):\n    \"\"\"\n    This function is taken "
  },
  {
    "path": "pytorch_classification/Test6_mobilenet/model_v3.py",
    "chars": 12689,
    "preview": "from typing import Callable, List, Optional\n\nimport torch\nfrom torch import nn, Tensor\nfrom torch.nn import functional a"
  },
  {
    "path": "pytorch_classification/Test6_mobilenet/predict.py",
    "chars": 1852,
    "preview": "import os\nimport json\n\nimport torch\nfrom PIL import Image\nfrom torchvision import transforms\nimport matplotlib.pyplot as"
  },
  {
    "path": "pytorch_classification/Test6_mobilenet/train.py",
    "chars": 5543,
    "preview": "import os\nimport sys\nimport json\n\nimport torch\nimport torch.nn as nn\nimport torch.optim as optim\nfrom torchvision import"
  },
  {
    "path": "pytorch_classification/Test7_shufflenet/README.md",
    "chars": 864,
    "preview": "## 代码使用简介\n\n1. 下载好数据集,代码中默认使用的是花分类数据集,下载地址: [https://storage.googleapis.com/download.tensorflow.org/example_images/flower"
  },
  {
    "path": "pytorch_classification/Test7_shufflenet/class_indices.json",
    "chars": 102,
    "preview": "{\n    \"0\": \"daisy\",\n    \"1\": \"dandelion\",\n    \"2\": \"roses\",\n    \"3\": \"sunflowers\",\n    \"4\": \"tulips\"\n}"
  },
  {
    "path": "pytorch_classification/Test7_shufflenet/model.py",
    "chars": 7693,
    "preview": "from typing import List, Callable\n\nimport torch\nfrom torch import Tensor\nimport torch.nn as nn\n\n\ndef channel_shuffle(x: "
  },
  {
    "path": "pytorch_classification/Test7_shufflenet/my_dataset.py",
    "chars": 1113,
    "preview": "from PIL import Image\nimport torch\nfrom torch.utils.data import Dataset\n\n\nclass MyDataSet(Dataset):\n    \"\"\"自定义数据集\"\"\"\n\n  "
  },
  {
    "path": "pytorch_classification/Test7_shufflenet/predict.py",
    "chars": 1868,
    "preview": "import os\nimport json\n\nimport torch\nfrom PIL import Image\nfrom torchvision import transforms\nimport matplotlib.pyplot as"
  },
  {
    "path": "pytorch_classification/Test7_shufflenet/train.py",
    "chars": 5806,
    "preview": "import os\nimport math\nimport argparse\n\nimport torch\nimport torch.optim as optim\nfrom torch.utils.tensorboard import Summ"
  },
  {
    "path": "pytorch_classification/Test7_shufflenet/utils.py",
    "chars": 5382,
    "preview": "import os\nimport sys\nimport json\nimport pickle\nimport random\n\nimport torch\nfrom tqdm import tqdm\n\nimport matplotlib.pypl"
  },
  {
    "path": "pytorch_classification/Test8_densenet/README.md",
    "chars": 864,
    "preview": "## 代码使用简介\n\n1. 下载好数据集,代码中默认使用的是花分类数据集,下载地址: [https://storage.googleapis.com/download.tensorflow.org/example_images/flower"
  },
  {
    "path": "pytorch_classification/Test8_densenet/model.py",
    "chars": 9965,
    "preview": "import re\nfrom typing import Any, List, Tuple\nfrom collections import OrderedDict\n\nimport torch\nimport torch.nn as nn\nim"
  },
  {
    "path": "pytorch_classification/Test8_densenet/my_dataset.py",
    "chars": 1113,
    "preview": "from PIL import Image\nimport torch\nfrom torch.utils.data import Dataset\n\n\nclass MyDataSet(Dataset):\n    \"\"\"自定义数据集\"\"\"\n\n  "
  },
  {
    "path": "pytorch_classification/Test8_densenet/predict.py",
    "chars": 1853,
    "preview": "import os\nimport json\n\nimport torch\nfrom PIL import Image\nfrom torchvision import transforms\nimport matplotlib.pyplot as"
  },
  {
    "path": "pytorch_classification/Test8_densenet/train.py",
    "chars": 5566,
    "preview": "import os\nimport math\nimport argparse\n\nimport torch\nimport torch.optim as optim\nfrom torch.utils.tensorboard import Summ"
  },
  {
    "path": "pytorch_classification/Test8_densenet/utils.py",
    "chars": 5382,
    "preview": "import os\nimport sys\nimport json\nimport pickle\nimport random\n\nimport torch\nfrom tqdm import tqdm\n\nimport matplotlib.pypl"
  },
  {
    "path": "pytorch_classification/Test9_efficientNet/README.md",
    "chars": 890,
    "preview": "## 代码使用简介\n\n1. 下载好数据集,代码中默认使用的是花分类数据集,下载地址: [https://storage.googleapis.com/download.tensorflow.org/example_images/flower"
  },
  {
    "path": "pytorch_classification/Test9_efficientNet/model.py",
    "chars": 14227,
    "preview": "import math\nimport copy\nfrom functools import partial\nfrom collections import OrderedDict\nfrom typing import Optional, C"
  },
  {
    "path": "pytorch_classification/Test9_efficientNet/my_dataset.py",
    "chars": 1113,
    "preview": "from PIL import Image\nimport torch\nfrom torch.utils.data import Dataset\n\n\nclass MyDataSet(Dataset):\n    \"\"\"自定义数据集\"\"\"\n\n  "
  },
  {
    "path": "pytorch_classification/Test9_efficientNet/predict.py",
    "chars": 2145,
    "preview": "import os\nimport json\n\nimport torch\nfrom PIL import Image\nfrom torchvision import transforms\nimport matplotlib.pyplot as"
  },
  {
    "path": "pytorch_classification/Test9_efficientNet/requirements.txt",
    "chars": 62,
    "preview": "numpy\nmatplotlib\ntqdm==4.56.0\ntorch>=1.7.1\ntorchvision>=0.8.2\n"
  },
  {
    "path": "pytorch_classification/Test9_efficientNet/train.py",
    "chars": 6205,
    "preview": "import os\nimport math\nimport argparse\n\nimport torch\nimport torch.optim as optim\nfrom torch.utils.tensorboard import Summ"
  },
  {
    "path": "pytorch_classification/Test9_efficientNet/trans_weights_to_pytorch.py",
    "chars": 4788,
    "preview": "import numpy as np\nimport torch\nimport tensorflow as tf\n\nassert tf.version.VERSION >= \"2.4.0\", \"version of tf must great"
  },
  {
    "path": "pytorch_classification/Test9_efficientNet/utils.py",
    "chars": 5382,
    "preview": "import os\nimport sys\nimport json\nimport pickle\nimport random\n\nimport torch\nfrom tqdm import tqdm\n\nimport matplotlib.pypl"
  },
  {
    "path": "pytorch_classification/analyze_weights_featuremap/alexnet_model.py",
    "chars": 2147,
    "preview": "import torch.nn as nn\nimport torch\n\n\nclass AlexNet(nn.Module):\n    def __init__(self, num_classes=1000, init_weights=Fal"
  },
  {
    "path": "pytorch_classification/analyze_weights_featuremap/analyze_feature_map.py",
    "chars": 1334,
    "preview": "import torch\nfrom alexnet_model import AlexNet\nfrom resnet_model import resnet34\nimport matplotlib.pyplot as plt\nimport "
  },
  {
    "path": "pytorch_classification/analyze_weights_featuremap/analyze_kernel_weight.py",
    "chars": 1326,
    "preview": "import torch\nfrom alexnet_model import AlexNet\nfrom resnet_model import resnet34\nimport matplotlib.pyplot as plt\nimport "
  },
  {
    "path": "pytorch_classification/analyze_weights_featuremap/resnet_model.py",
    "chars": 5105,
    "preview": "import torch.nn as nn\nimport torch\n\n\nclass BasicBlock(nn.Module):\n    expansion = 1\n\n    def __init__(self, in_channel, "
  },
  {
    "path": "pytorch_classification/custom_dataset/main.py",
    "chars": 2033,
    "preview": "import os\n\nimport torch\nfrom torchvision import transforms\n\nfrom my_dataset import MyDataSet\nfrom utils import read_spli"
  },
  {
    "path": "pytorch_classification/custom_dataset/my_dataset.py",
    "chars": 1114,
    "preview": "from PIL import Image\nimport torch\nfrom torch.utils.data import Dataset\n\n\nclass MyDataSet(Dataset):\n    \"\"\"自定义数据集\"\"\"\n\n  "
  },
  {
    "path": "pytorch_classification/custom_dataset/utils.py",
    "chars": 3749,
    "preview": "import os\nimport json\nimport pickle\nimport random\n\nimport matplotlib.pyplot as plt\n\n\ndef read_split_data(root: str, val_"
  },
  {
    "path": "pytorch_classification/grad_cam/README.md",
    "chars": 430,
    "preview": "## Grad-CAM\n- Original Impl: [https://github.com/jacobgil/pytorch-grad-cam](https://github.com/jacobgil/pytorch-grad-cam"
  },
  {
    "path": "pytorch_classification/grad_cam/imagenet1k_classes.txt",
    "chars": 21674,
    "preview": "tench, Tinca tinca\ngoldfish, Carassius auratus\ngreat white shark, white shark, man-eater, man-eating shark, Carcharodon "
  },
  {
    "path": "pytorch_classification/grad_cam/imagenet21k_classes.txt",
    "chars": 522999,
    "preview": "organism, being\nbenthos\nheterotroph\ncell\nperson, individual, someone, somebody, mortal, soul\nanimal, animate_being, beas"
  },
  {
    "path": "pytorch_classification/grad_cam/main_cnn.py",
    "chars": 1846,
    "preview": "import os\nimport numpy as np\nimport torch\nfrom PIL import Image\nimport matplotlib.pyplot as plt\nfrom torchvision import "
  },
  {
    "path": "pytorch_classification/grad_cam/main_swin.py",
    "chars": 2632,
    "preview": "import os\nimport math\nimport numpy as np\nimport torch\nfrom PIL import Image\nimport matplotlib.pyplot as plt\nfrom torchvi"
  },
  {
    "path": "pytorch_classification/grad_cam/main_vit.py",
    "chars": 2710,
    "preview": "import os\nimport numpy as np\nimport torch\nfrom PIL import Image\nimport matplotlib.pyplot as plt\nfrom torchvision import "
  },
  {
    "path": "pytorch_classification/grad_cam/swin_model.py",
    "chars": 28233,
    "preview": "\"\"\" Swin Transformer\nA PyTorch impl of : `Swin Transformer: Hierarchical Vision Transformer using Shifted Windows`\n    -"
  },
  {
    "path": "pytorch_classification/grad_cam/utils.py",
    "chars": 8015,
    "preview": "import cv2\nimport numpy as np\n\n\nclass ActivationsAndGradients:\n    \"\"\" Class for extracting activations and\n    register"
  },
  {
    "path": "pytorch_classification/grad_cam/vit_model.py",
    "chars": 18204,
    "preview": "\"\"\"\noriginal code from rwightman:\nhttps://github.com/rwightman/pytorch-image-models/blob/master/timm/models/vision_trans"
  },
  {
    "path": "pytorch_classification/mini_imagenet/README.md",
    "chars": 393,
    "preview": "## download mini-imagenet\nlink: [https://pan.baidu.com/s/1Uro6RuEbRGGCQ8iXvF2SAQ](https://pan.baidu.com/s/1Uro6RuEbRGGCQ"
  },
  {
    "path": "pytorch_classification/mini_imagenet/imagenet_class_index.json",
    "chars": 35363,
    "preview": "{\"0\": [\"n01440764\", \"tench\"], \"1\": [\"n01443537\", \"goldfish\"], \"2\": [\"n01484850\", \"great_white_shark\"], \"3\": [\"n01491361\""
  },
  {
    "path": "pytorch_classification/mini_imagenet/model.py",
    "chars": 6567,
    "preview": "from typing import List, Callable\n\nimport torch\nfrom torch import Tensor\nimport torch.nn as nn\n\n\ndef channel_shuffle(x: "
  },
  {
    "path": "pytorch_classification/mini_imagenet/multi_train_utils/__init__.py",
    "chars": 124,
    "preview": "from .train_eval_utils import train_one_epoch, evaluate\nfrom .distributed_utils import init_distributed_mode, dist, clea"
  },
  {
    "path": "pytorch_classification/mini_imagenet/multi_train_utils/distributed_utils.py",
    "chars": 2120,
    "preview": "import os\n\nimport torch\nimport torch.distributed as dist\n\n\ndef init_distributed_mode(args):\n    if 'RANK' in os.environ "
  },
  {
    "path": "pytorch_classification/mini_imagenet/multi_train_utils/train_eval_utils.py",
    "chars": 2973,
    "preview": "import sys\n\nfrom tqdm import tqdm\nimport torch\n\nfrom .distributed_utils import reduce_value, is_main_process, warmup_lr_"
  },
  {
    "path": "pytorch_classification/mini_imagenet/my_dataset.py",
    "chars": 1861,
    "preview": "import os\nimport json\nfrom PIL import Image\nimport pandas as pd\nimport torch\nfrom torch.utils.data import Dataset\n\n\nclas"
  },
  {
    "path": "pytorch_classification/mini_imagenet/restructure_csv.py",
    "chars": 3194,
    "preview": "import os\nimport json\n\nimport pandas as pd\nfrom PIL import Image\nimport matplotlib.pyplot as plt\n\n\ndef read_csv_classes("
  },
  {
    "path": "pytorch_classification/mini_imagenet/train_multi_gpu_using_launch.py",
    "chars": 7715,
    "preview": "import os\nimport math\nimport tempfile\nimport argparse\n\nimport torch\nimport torch.optim as optim\nimport torch.optim.lr_sc"
  },
  {
    "path": "pytorch_classification/mini_imagenet/train_single_gpu.py",
    "chars": 5950,
    "preview": "import os\nimport math\nimport argparse\n\nimport torch\nimport torch.optim as optim\nfrom torch.utils.tensorboard import Summ"
  },
  {
    "path": "pytorch_classification/model_complexity/main.py",
    "chars": 1022,
    "preview": "import torch\nfrom fvcore.nn import FlopCountAnalysis, parameter_count_table\nfrom prettytable import PrettyTable\nfrom mod"
  },
  {
    "path": "pytorch_classification/model_complexity/model.py",
    "chars": 15999,
    "preview": "from collections import OrderedDict\nfrom functools import partial\nfrom typing import Callable, Optional\n\nimport torch.nn"
  },
  {
    "path": "pytorch_classification/model_complexity/utils.py",
    "chars": 2237,
    "preview": "\"\"\"\nthese code refers to:\nhttps://github.com/facebookresearch/pycls/blob/master/pycls/models/blocks.py\n\"\"\"\n\n\ndef conv2d_"
  },
  {
    "path": "pytorch_classification/swin_transformer/README.md",
    "chars": 864,
    "preview": "## 代码使用简介\n\n1. 下载好数据集,代码中默认使用的是花分类数据集,下载地址: [https://storage.googleapis.com/download.tensorflow.org/example_images/flower"
  },
  {
    "path": "pytorch_classification/swin_transformer/create_confusion_matrix.py",
    "chars": 5742,
    "preview": "import os\nimport json\nimport argparse\nimport sys\n\nimport torch\nfrom torchvision import transforms\nimport numpy as np\nfro"
  },
  {
    "path": "pytorch_classification/swin_transformer/model.py",
    "chars": 28233,
    "preview": "\"\"\" Swin Transformer\nA PyTorch impl of : `Swin Transformer: Hierarchical Vision Transformer using Shifted Windows`\n    -"
  },
  {
    "path": "pytorch_classification/swin_transformer/my_dataset.py",
    "chars": 1113,
    "preview": "from PIL import Image\nimport torch\nfrom torch.utils.data import Dataset\n\n\nclass MyDataSet(Dataset):\n    \"\"\"自定义数据集\"\"\"\n\n  "
  },
  {
    "path": "pytorch_classification/swin_transformer/predict.py",
    "chars": 1928,
    "preview": "import os\nimport json\n\nimport torch\nfrom PIL import Image\nfrom torchvision import transforms\nimport matplotlib.pyplot as"
  },
  {
    "path": "pytorch_classification/swin_transformer/select_incorrect_samples.py",
    "chars": 3696,
    "preview": "\"\"\"\n该脚本能够把验证集中预测错误的图片挑选出来,并记录在record.txt中\n\"\"\"\nimport os\nimport json\nimport argparse\nimport sys\n\nimport torch\nfrom torchv"
  },
  {
    "path": "pytorch_classification/swin_transformer/train.py",
    "chars": 5529,
    "preview": "import os\nimport argparse\n\nimport torch\nimport torch.optim as optim\nfrom torch.utils.tensorboard import SummaryWriter\nfr"
  },
  {
    "path": "pytorch_classification/swin_transformer/utils.py",
    "chars": 6357,
    "preview": "import os\nimport sys\nimport json\nimport pickle\nimport random\n\nimport torch\nfrom tqdm import tqdm\n\nimport matplotlib.pypl"
  },
  {
    "path": "pytorch_classification/tensorboard_test/data_utils.py",
    "chars": 7197,
    "preview": "import os\nimport json\nimport pickle\nimport random\n\nfrom PIL import Image\nimport torch\nimport numpy as np\nimport matplotl"
  },
  {
    "path": "pytorch_classification/tensorboard_test/model.py",
    "chars": 5003,
    "preview": "import torch.nn as nn\nimport torch\n\n\nclass BasicBlock(nn.Module):\n    expansion = 1\n\n    def __init__(self, in_channel, "
  },
  {
    "path": "pytorch_classification/tensorboard_test/my_dataset.py",
    "chars": 1559,
    "preview": "from tqdm import tqdm\nfrom PIL import Image\nimport torch\nfrom torch.utils.data import Dataset\n\n\nclass MyDataSet(Dataset)"
  },
  {
    "path": "pytorch_classification/tensorboard_test/requirements.txt",
    "chars": 83,
    "preview": "torchvision==0.7.0\ntqdm==4.42.1\nmatplotlib==3.2.1\ntorch==1.13.1\nPillow\ntensorboard\n"
  },
  {
    "path": "pytorch_classification/tensorboard_test/train.py",
    "chars": 7036,
    "preview": "import os\nimport math\nimport argparse\n\nimport torch\nimport torch.optim as optim\nfrom torch.utils.tensorboard import Summ"
  },
  {
    "path": "pytorch_classification/tensorboard_test/train_eval_utils.py",
    "chars": 1504,
    "preview": "import sys\n\nfrom tqdm import tqdm\nimport torch\n\n\ndef train_one_epoch(model, optimizer, data_loader, device, epoch):\n    "
  },
  {
    "path": "pytorch_classification/train_multi_GPU/README.md",
    "chars": 622,
    "preview": "## 多GPU启动指令\n- 如果要使用```train_multi_gpu_using_launch.py```脚本,使用以下指令启动\n- ```python -m torch.distributed.launch --nproc_per_"
  },
  {
    "path": "pytorch_classification/train_multi_GPU/model.py",
    "chars": 5003,
    "preview": "import torch.nn as nn\nimport torch\n\n\nclass BasicBlock(nn.Module):\n    expansion = 1\n\n    def __init__(self, in_channel, "
  },
  {
    "path": "pytorch_classification/train_multi_GPU/multi_train_utils/distributed_utils.py",
    "chars": 1721,
    "preview": "import os\n\nimport torch\nimport torch.distributed as dist\n\n\ndef init_distributed_mode(args):\n    if 'RANK' in os.environ "
  },
  {
    "path": "pytorch_classification/train_multi_GPU/multi_train_utils/train_eval_utils.py",
    "chars": 1870,
    "preview": "import sys\n\nfrom tqdm import tqdm\nimport torch\n\nfrom multi_train_utils.distributed_utils import reduce_value, is_main_pr"
  },
  {
    "path": "pytorch_classification/train_multi_GPU/my_dataset.py",
    "chars": 1113,
    "preview": "from PIL import Image\nimport torch\nfrom torch.utils.data import Dataset\n\n\nclass MyDataSet(Dataset):\n    \"\"\"自定义数据集\"\"\"\n\n  "
  },
  {
    "path": "pytorch_classification/train_multi_GPU/plot_results.py",
    "chars": 3107,
    "preview": "import math\nimport matplotlib.pyplot as plt\n\nx = [0, 1, 2, 3]\ny = [9, 5.5, 3, 2]\n\nplt.bar(x, y, align='center')\nplt.xtic"
  },
  {
    "path": "pytorch_classification/train_multi_GPU/requirements.txt",
    "chars": 64,
    "preview": "matplotlib==3.2.1\ntqdm==4.42.1\ntorchvision==0.7.0\ntorch==1.13.1\n"
  },
  {
    "path": "pytorch_classification/train_multi_GPU/train_multi_gpu_using_launch.py",
    "chars": 8071,
    "preview": "import os\nimport math\nimport tempfile\nimport argparse\n\nimport torch\nimport torch.optim as optim\nimport torch.optim.lr_sc"
  },
  {
    "path": "pytorch_classification/train_multi_GPU/train_multi_gpu_using_spawn.py",
    "chars": 9148,
    "preview": "import os\nimport math\nimport tempfile\nimport argparse\n\nimport torch\nimport torch.multiprocessing as mp\nfrom torch.multip"
  },
  {
    "path": "pytorch_classification/train_multi_GPU/train_single_gpu.py",
    "chars": 6224,
    "preview": "import os\nimport math\nimport argparse\n\nimport torch\nimport torch.optim as optim\nfrom torch.utils.tensorboard import Summ"
  }
]

// ... and 393 more files (download for full content)

About this extraction

This page contains the full source code of the WZMIAOMIAO/deep-learning-for-image-processing GitHub repository, extracted and formatted as plain text for AI agents and large language models (LLMs). The extraction includes 593 files (3.3 MB), approximately 908.8k tokens, and a symbol index with 3150 extracted functions, classes, methods, constants, and types. Use this with OpenClaw, Claude, ChatGPT, Cursor, Windsurf, or any other AI tool that accepts text input. You can copy the full output to your clipboard or download it as a .txt file.

Extracted by GitExtract — free GitHub repo to text converter for AI. Built by Nikandr Surkov.

Copied to clipboard!