Showing preview only (6,639K chars total). Download the full file or copy to clipboard to get everything.
Repository: Mikubill/sd-webui-controlnet
Branch: main
Commit: 56cec5b2958e
Files: 932
Total size: 6.2 MB
Directory structure:
gitextract_wjd3xpkj/
├── .github/
│ ├── ISSUE_TEMPLATE/
│ │ ├── bug_report.yml
│ │ └── config.yml
│ └── workflows/
│ ├── lint.yaml
│ └── tests.yml
├── .gitignore
├── LICENSE
├── README.md
├── annotator/
│ ├── __init__.py
│ ├── anime_face_segment/
│ │ ├── LICENSE
│ │ └── __init__.py
│ ├── annotator_path.py
│ ├── binary/
│ │ └── __init__.py
│ ├── canny/
│ │ └── __init__.py
│ ├── clipvision/
│ │ ├── __init__.py
│ │ ├── clip_vision_h_uc.data
│ │ └── clip_vision_vith_uc.data
│ ├── color/
│ │ └── __init__.py
│ ├── densepose/
│ │ ├── __init__.py
│ │ └── densepose.py
│ ├── depth_anything.py
│ ├── depth_anything_v2.py
│ ├── hed/
│ │ └── __init__.py
│ ├── keypose/
│ │ ├── __init__.py
│ │ ├── faster_rcnn_r50_fpn_coco.py
│ │ └── hrnet_w48_coco_256x192.py
│ ├── lama/
│ │ ├── __init__.py
│ │ ├── config.yaml
│ │ └── saicinpainting/
│ │ ├── __init__.py
│ │ ├── training/
│ │ │ ├── __init__.py
│ │ │ ├── data/
│ │ │ │ ├── __init__.py
│ │ │ │ └── masks.py
│ │ │ ├── losses/
│ │ │ │ ├── __init__.py
│ │ │ │ ├── adversarial.py
│ │ │ │ ├── constants.py
│ │ │ │ ├── distance_weighting.py
│ │ │ │ ├── feature_matching.py
│ │ │ │ ├── perceptual.py
│ │ │ │ ├── segmentation.py
│ │ │ │ └── style_loss.py
│ │ │ ├── modules/
│ │ │ │ ├── __init__.py
│ │ │ │ ├── base.py
│ │ │ │ ├── depthwise_sep_conv.py
│ │ │ │ ├── fake_fakes.py
│ │ │ │ ├── ffc.py
│ │ │ │ ├── multidilated_conv.py
│ │ │ │ ├── multiscale.py
│ │ │ │ ├── pix2pixhd.py
│ │ │ │ ├── spatial_transform.py
│ │ │ │ └── squeeze_excitation.py
│ │ │ ├── trainers/
│ │ │ │ ├── __init__.py
│ │ │ │ ├── base.py
│ │ │ │ └── default.py
│ │ │ └── visualizers/
│ │ │ ├── __init__.py
│ │ │ ├── base.py
│ │ │ ├── colors.py
│ │ │ ├── directory.py
│ │ │ └── noop.py
│ │ └── utils.py
│ ├── leres/
│ │ ├── __init__.py
│ │ ├── leres/
│ │ │ ├── LICENSE
│ │ │ ├── Resnet.py
│ │ │ ├── Resnext_torch.py
│ │ │ ├── depthmap.py
│ │ │ ├── multi_depth_model_woauxi.py
│ │ │ ├── net_tools.py
│ │ │ └── network_auxi.py
│ │ └── pix2pix/
│ │ ├── LICENSE
│ │ ├── models/
│ │ │ ├── __init__.py
│ │ │ ├── base_model.py
│ │ │ ├── base_model_hg.py
│ │ │ ├── networks.py
│ │ │ └── pix2pix4depth_model.py
│ │ ├── options/
│ │ │ ├── __init__.py
│ │ │ ├── base_options.py
│ │ │ └── test_options.py
│ │ └── util/
│ │ ├── __init__.py
│ │ ├── get_data.py
│ │ ├── guidedfilter.py
│ │ ├── html.py
│ │ ├── image_pool.py
│ │ ├── util.py
│ │ └── visualizer.py
│ ├── lineart/
│ │ ├── LICENSE
│ │ └── __init__.py
│ ├── lineart_anime/
│ │ ├── LICENSE
│ │ └── __init__.py
│ ├── manga_line/
│ │ ├── LICENSE
│ │ └── __init__.py
│ ├── mediapipe_face/
│ │ ├── __init__.py
│ │ └── mediapipe_face_common.py
│ ├── midas/
│ │ ├── LICENSE
│ │ ├── __init__.py
│ │ ├── api.py
│ │ ├── midas/
│ │ │ ├── __init__.py
│ │ │ ├── base_model.py
│ │ │ ├── blocks.py
│ │ │ ├── dpt_depth.py
│ │ │ ├── midas_net.py
│ │ │ ├── midas_net_custom.py
│ │ │ ├── transforms.py
│ │ │ └── vit.py
│ │ └── utils.py
│ ├── mlsd/
│ │ ├── LICENSE
│ │ ├── __init__.py
│ │ ├── models/
│ │ │ ├── mbv2_mlsd_large.py
│ │ │ └── mbv2_mlsd_tiny.py
│ │ └── utils.py
│ ├── mmpkg/
│ │ ├── mmcv/
│ │ │ ├── __init__.py
│ │ │ ├── arraymisc/
│ │ │ │ ├── __init__.py
│ │ │ │ └── quantization.py
│ │ │ ├── cnn/
│ │ │ │ ├── __init__.py
│ │ │ │ ├── alexnet.py
│ │ │ │ ├── bricks/
│ │ │ │ │ ├── __init__.py
│ │ │ │ │ ├── activation.py
│ │ │ │ │ ├── context_block.py
│ │ │ │ │ ├── conv.py
│ │ │ │ │ ├── conv2d_adaptive_padding.py
│ │ │ │ │ ├── conv_module.py
│ │ │ │ │ ├── conv_ws.py
│ │ │ │ │ ├── depthwise_separable_conv_module.py
│ │ │ │ │ ├── drop.py
│ │ │ │ │ ├── generalized_attention.py
│ │ │ │ │ ├── hsigmoid.py
│ │ │ │ │ ├── hswish.py
│ │ │ │ │ ├── non_local.py
│ │ │ │ │ ├── norm.py
│ │ │ │ │ ├── padding.py
│ │ │ │ │ ├── plugin.py
│ │ │ │ │ ├── registry.py
│ │ │ │ │ ├── scale.py
│ │ │ │ │ ├── swish.py
│ │ │ │ │ ├── transformer.py
│ │ │ │ │ ├── upsample.py
│ │ │ │ │ └── wrappers.py
│ │ │ │ ├── builder.py
│ │ │ │ ├── resnet.py
│ │ │ │ ├── utils/
│ │ │ │ │ ├── __init__.py
│ │ │ │ │ ├── flops_counter.py
│ │ │ │ │ ├── fuse_conv_bn.py
│ │ │ │ │ ├── sync_bn.py
│ │ │ │ │ └── weight_init.py
│ │ │ │ └── vgg.py
│ │ │ ├── engine/
│ │ │ │ ├── __init__.py
│ │ │ │ └── test.py
│ │ │ ├── fileio/
│ │ │ │ ├── __init__.py
│ │ │ │ ├── file_client.py
│ │ │ │ ├── handlers/
│ │ │ │ │ ├── __init__.py
│ │ │ │ │ ├── base.py
│ │ │ │ │ ├── json_handler.py
│ │ │ │ │ ├── pickle_handler.py
│ │ │ │ │ └── yaml_handler.py
│ │ │ │ ├── io.py
│ │ │ │ └── parse.py
│ │ │ ├── image/
│ │ │ │ ├── __init__.py
│ │ │ │ ├── colorspace.py
│ │ │ │ ├── geometric.py
│ │ │ │ ├── io.py
│ │ │ │ ├── misc.py
│ │ │ │ └── photometric.py
│ │ │ ├── model_zoo/
│ │ │ │ ├── deprecated.json
│ │ │ │ ├── mmcls.json
│ │ │ │ └── open_mmlab.json
│ │ │ ├── ops/
│ │ │ │ ├── __init__.py
│ │ │ │ ├── assign_score_withk.py
│ │ │ │ ├── ball_query.py
│ │ │ │ ├── bbox.py
│ │ │ │ ├── border_align.py
│ │ │ │ ├── box_iou_rotated.py
│ │ │ │ ├── carafe.py
│ │ │ │ ├── cc_attention.py
│ │ │ │ ├── contour_expand.py
│ │ │ │ ├── corner_pool.py
│ │ │ │ ├── correlation.py
│ │ │ │ ├── deform_conv.py
│ │ │ │ ├── deform_roi_pool.py
│ │ │ │ ├── deprecated_wrappers.py
│ │ │ │ ├── focal_loss.py
│ │ │ │ ├── furthest_point_sample.py
│ │ │ │ ├── fused_bias_leakyrelu.py
│ │ │ │ ├── gather_points.py
│ │ │ │ ├── group_points.py
│ │ │ │ ├── info.py
│ │ │ │ ├── iou3d.py
│ │ │ │ ├── knn.py
│ │ │ │ ├── masked_conv.py
│ │ │ │ ├── merge_cells.py
│ │ │ │ ├── modulated_deform_conv.py
│ │ │ │ ├── multi_scale_deform_attn.py
│ │ │ │ ├── nms.py
│ │ │ │ ├── pixel_group.py
│ │ │ │ ├── point_sample.py
│ │ │ │ ├── points_in_boxes.py
│ │ │ │ ├── points_sampler.py
│ │ │ │ ├── psa_mask.py
│ │ │ │ ├── roi_align.py
│ │ │ │ ├── roi_align_rotated.py
│ │ │ │ ├── roi_pool.py
│ │ │ │ ├── roiaware_pool3d.py
│ │ │ │ ├── roipoint_pool3d.py
│ │ │ │ ├── saconv.py
│ │ │ │ ├── scatter_points.py
│ │ │ │ ├── sync_bn.py
│ │ │ │ ├── three_interpolate.py
│ │ │ │ ├── three_nn.py
│ │ │ │ ├── tin_shift.py
│ │ │ │ ├── upfirdn2d.py
│ │ │ │ └── voxelize.py
│ │ │ ├── parallel/
│ │ │ │ ├── __init__.py
│ │ │ │ ├── _functions.py
│ │ │ │ ├── collate.py
│ │ │ │ ├── data_container.py
│ │ │ │ ├── data_parallel.py
│ │ │ │ ├── distributed.py
│ │ │ │ ├── distributed_deprecated.py
│ │ │ │ ├── registry.py
│ │ │ │ ├── scatter_gather.py
│ │ │ │ └── utils.py
│ │ │ ├── runner/
│ │ │ │ ├── __init__.py
│ │ │ │ ├── base_module.py
│ │ │ │ ├── base_runner.py
│ │ │ │ ├── builder.py
│ │ │ │ ├── checkpoint.py
│ │ │ │ ├── default_constructor.py
│ │ │ │ ├── dist_utils.py
│ │ │ │ ├── epoch_based_runner.py
│ │ │ │ ├── fp16_utils.py
│ │ │ │ ├── hooks/
│ │ │ │ │ ├── __init__.py
│ │ │ │ │ ├── checkpoint.py
│ │ │ │ │ ├── closure.py
│ │ │ │ │ ├── ema.py
│ │ │ │ │ ├── evaluation.py
│ │ │ │ │ ├── hook.py
│ │ │ │ │ ├── iter_timer.py
│ │ │ │ │ ├── logger/
│ │ │ │ │ │ ├── __init__.py
│ │ │ │ │ │ ├── base.py
│ │ │ │ │ │ ├── dvclive.py
│ │ │ │ │ │ ├── mlflow.py
│ │ │ │ │ │ ├── neptune.py
│ │ │ │ │ │ ├── pavi.py
│ │ │ │ │ │ ├── tensorboard.py
│ │ │ │ │ │ ├── text.py
│ │ │ │ │ │ └── wandb.py
│ │ │ │ │ ├── lr_updater.py
│ │ │ │ │ ├── memory.py
│ │ │ │ │ ├── momentum_updater.py
│ │ │ │ │ ├── optimizer.py
│ │ │ │ │ ├── profiler.py
│ │ │ │ │ ├── sampler_seed.py
│ │ │ │ │ └── sync_buffer.py
│ │ │ │ ├── iter_based_runner.py
│ │ │ │ ├── log_buffer.py
│ │ │ │ ├── optimizer/
│ │ │ │ │ ├── __init__.py
│ │ │ │ │ ├── builder.py
│ │ │ │ │ └── default_constructor.py
│ │ │ │ ├── priority.py
│ │ │ │ └── utils.py
│ │ │ ├── utils/
│ │ │ │ ├── __init__.py
│ │ │ │ ├── config.py
│ │ │ │ ├── env.py
│ │ │ │ ├── ext_loader.py
│ │ │ │ ├── logging.py
│ │ │ │ ├── misc.py
│ │ │ │ ├── parrots_jit.py
│ │ │ │ ├── parrots_wrapper.py
│ │ │ │ ├── path.py
│ │ │ │ ├── progressbar.py
│ │ │ │ ├── registry.py
│ │ │ │ ├── testing.py
│ │ │ │ ├── timer.py
│ │ │ │ ├── trace.py
│ │ │ │ └── version_utils.py
│ │ │ ├── version.py
│ │ │ ├── video/
│ │ │ │ ├── __init__.py
│ │ │ │ ├── io.py
│ │ │ │ ├── optflow.py
│ │ │ │ └── processing.py
│ │ │ └── visualization/
│ │ │ ├── __init__.py
│ │ │ ├── color.py
│ │ │ ├── image.py
│ │ │ └── optflow.py
│ │ └── mmseg/
│ │ ├── apis/
│ │ │ ├── __init__.py
│ │ │ ├── inference.py
│ │ │ ├── test.py
│ │ │ └── train.py
│ │ ├── core/
│ │ │ ├── __init__.py
│ │ │ ├── evaluation/
│ │ │ │ ├── __init__.py
│ │ │ │ ├── class_names.py
│ │ │ │ ├── eval_hooks.py
│ │ │ │ └── metrics.py
│ │ │ ├── seg/
│ │ │ │ ├── __init__.py
│ │ │ │ ├── builder.py
│ │ │ │ └── sampler/
│ │ │ │ ├── __init__.py
│ │ │ │ ├── base_pixel_sampler.py
│ │ │ │ └── ohem_pixel_sampler.py
│ │ │ └── utils/
│ │ │ ├── __init__.py
│ │ │ └── misc.py
│ │ ├── datasets/
│ │ │ ├── __init__.py
│ │ │ ├── ade.py
│ │ │ ├── builder.py
│ │ │ ├── chase_db1.py
│ │ │ ├── cityscapes.py
│ │ │ ├── custom.py
│ │ │ ├── dataset_wrappers.py
│ │ │ ├── drive.py
│ │ │ ├── hrf.py
│ │ │ ├── pascal_context.py
│ │ │ ├── pipelines/
│ │ │ │ ├── __init__.py
│ │ │ │ ├── compose.py
│ │ │ │ ├── formating.py
│ │ │ │ ├── loading.py
│ │ │ │ ├── test_time_aug.py
│ │ │ │ └── transforms.py
│ │ │ ├── stare.py
│ │ │ └── voc.py
│ │ ├── models/
│ │ │ ├── __init__.py
│ │ │ ├── backbones/
│ │ │ │ ├── __init__.py
│ │ │ │ ├── cgnet.py
│ │ │ │ ├── fast_scnn.py
│ │ │ │ ├── hrnet.py
│ │ │ │ ├── mobilenet_v2.py
│ │ │ │ ├── mobilenet_v3.py
│ │ │ │ ├── resnest.py
│ │ │ │ ├── resnet.py
│ │ │ │ ├── resnext.py
│ │ │ │ ├── unet.py
│ │ │ │ └── vit.py
│ │ │ ├── builder.py
│ │ │ ├── decode_heads/
│ │ │ │ ├── __init__.py
│ │ │ │ ├── ann_head.py
│ │ │ │ ├── apc_head.py
│ │ │ │ ├── aspp_head.py
│ │ │ │ ├── cascade_decode_head.py
│ │ │ │ ├── cc_head.py
│ │ │ │ ├── da_head.py
│ │ │ │ ├── decode_head.py
│ │ │ │ ├── dm_head.py
│ │ │ │ ├── dnl_head.py
│ │ │ │ ├── ema_head.py
│ │ │ │ ├── enc_head.py
│ │ │ │ ├── fcn_head.py
│ │ │ │ ├── fpn_head.py
│ │ │ │ ├── gc_head.py
│ │ │ │ ├── lraspp_head.py
│ │ │ │ ├── nl_head.py
│ │ │ │ ├── ocr_head.py
│ │ │ │ ├── point_head.py
│ │ │ │ ├── psa_head.py
│ │ │ │ ├── psp_head.py
│ │ │ │ ├── sep_aspp_head.py
│ │ │ │ ├── sep_fcn_head.py
│ │ │ │ └── uper_head.py
│ │ │ ├── losses/
│ │ │ │ ├── __init__.py
│ │ │ │ ├── accuracy.py
│ │ │ │ ├── cross_entropy_loss.py
│ │ │ │ ├── dice_loss.py
│ │ │ │ ├── lovasz_loss.py
│ │ │ │ └── utils.py
│ │ │ ├── necks/
│ │ │ │ ├── __init__.py
│ │ │ │ ├── fpn.py
│ │ │ │ └── multilevel_neck.py
│ │ │ ├── segmentors/
│ │ │ │ ├── __init__.py
│ │ │ │ ├── base.py
│ │ │ │ ├── cascade_encoder_decoder.py
│ │ │ │ └── encoder_decoder.py
│ │ │ └── utils/
│ │ │ ├── __init__.py
│ │ │ ├── drop.py
│ │ │ ├── inverted_residual.py
│ │ │ ├── make_divisible.py
│ │ │ ├── res_layer.py
│ │ │ ├── se_layer.py
│ │ │ ├── self_attention_block.py
│ │ │ ├── up_conv_block.py
│ │ │ └── weight_init.py
│ │ ├── ops/
│ │ │ ├── __init__.py
│ │ │ ├── encoding.py
│ │ │ └── wrappers.py
│ │ └── utils/
│ │ ├── __init__.py
│ │ ├── collect_env.py
│ │ └── logger.py
│ ├── mobile_sam/
│ │ └── __init__.py
│ ├── normalbae/
│ │ ├── LICENSE
│ │ ├── __init__.py
│ │ └── models/
│ │ ├── NNET.py
│ │ ├── baseline.py
│ │ └── submodules/
│ │ ├── decoder.py
│ │ ├── efficientnet_repo/
│ │ │ ├── .gitignore
│ │ │ ├── BENCHMARK.md
│ │ │ ├── LICENSE
│ │ │ ├── README.md
│ │ │ ├── caffe2_benchmark.py
│ │ │ ├── caffe2_validate.py
│ │ │ ├── geffnet/
│ │ │ │ ├── __init__.py
│ │ │ │ ├── activations/
│ │ │ │ │ ├── __init__.py
│ │ │ │ │ ├── activations.py
│ │ │ │ │ ├── activations_jit.py
│ │ │ │ │ └── activations_me.py
│ │ │ │ ├── config.py
│ │ │ │ ├── conv2d_layers.py
│ │ │ │ ├── efficientnet_builder.py
│ │ │ │ ├── gen_efficientnet.py
│ │ │ │ ├── helpers.py
│ │ │ │ ├── mobilenetv3.py
│ │ │ │ ├── model_factory.py
│ │ │ │ └── version.py
│ │ │ ├── hubconf.py
│ │ │ ├── onnx_export.py
│ │ │ ├── onnx_optimize.py
│ │ │ ├── onnx_to_caffe.py
│ │ │ ├── onnx_validate.py
│ │ │ ├── requirements.txt
│ │ │ ├── setup.py
│ │ │ ├── utils.py
│ │ │ └── validate.py
│ │ ├── encoder.py
│ │ └── submodules.py
│ ├── normaldsine/
│ │ ├── LICENSE
│ │ └── __init__.py
│ ├── oneformer/
│ │ ├── LICENSE
│ │ ├── __init__.py
│ │ ├── api.py
│ │ ├── configs/
│ │ │ ├── ade20k/
│ │ │ │ ├── Base-ADE20K-UnifiedSegmentation.yaml
│ │ │ │ ├── oneformer_R50_bs16_160k.yaml
│ │ │ │ └── oneformer_swin_large_IN21k_384_bs16_160k.yaml
│ │ │ └── coco/
│ │ │ ├── Base-COCO-UnifiedSegmentation.yaml
│ │ │ ├── oneformer_R50_bs16_50ep.yaml
│ │ │ └── oneformer_swin_large_IN21k_384_bs16_100ep.yaml
│ │ ├── detectron2/
│ │ │ ├── __init__.py
│ │ │ ├── checkpoint/
│ │ │ │ ├── __init__.py
│ │ │ │ ├── c2_model_loading.py
│ │ │ │ ├── catalog.py
│ │ │ │ └── detection_checkpoint.py
│ │ │ ├── config/
│ │ │ │ ├── __init__.py
│ │ │ │ ├── compat.py
│ │ │ │ ├── config.py
│ │ │ │ ├── defaults.py
│ │ │ │ ├── instantiate.py
│ │ │ │ └── lazy.py
│ │ │ ├── data/
│ │ │ │ ├── __init__.py
│ │ │ │ ├── benchmark.py
│ │ │ │ ├── build.py
│ │ │ │ ├── catalog.py
│ │ │ │ ├── common.py
│ │ │ │ ├── dataset_mapper.py
│ │ │ │ ├── datasets/
│ │ │ │ │ ├── README.md
│ │ │ │ │ ├── __init__.py
│ │ │ │ │ ├── builtin.py
│ │ │ │ │ ├── builtin_meta.py
│ │ │ │ │ ├── cityscapes.py
│ │ │ │ │ ├── cityscapes_panoptic.py
│ │ │ │ │ ├── coco.py
│ │ │ │ │ ├── coco_panoptic.py
│ │ │ │ │ ├── lvis.py
│ │ │ │ │ ├── lvis_v0_5_categories.py
│ │ │ │ │ ├── lvis_v1_categories.py
│ │ │ │ │ ├── lvis_v1_category_image_count.py
│ │ │ │ │ ├── pascal_voc.py
│ │ │ │ │ └── register_coco.py
│ │ │ │ ├── detection_utils.py
│ │ │ │ ├── samplers/
│ │ │ │ │ ├── __init__.py
│ │ │ │ │ ├── distributed_sampler.py
│ │ │ │ │ └── grouped_batch_sampler.py
│ │ │ │ └── transforms/
│ │ │ │ ├── __init__.py
│ │ │ │ ├── augmentation.py
│ │ │ │ ├── augmentation_impl.py
│ │ │ │ └── transform.py
│ │ │ ├── engine/
│ │ │ │ ├── __init__.py
│ │ │ │ ├── defaults.py
│ │ │ │ ├── hooks.py
│ │ │ │ ├── launch.py
│ │ │ │ └── train_loop.py
│ │ │ ├── evaluation/
│ │ │ │ ├── __init__.py
│ │ │ │ ├── cityscapes_evaluation.py
│ │ │ │ ├── coco_evaluation.py
│ │ │ │ ├── evaluator.py
│ │ │ │ ├── fast_eval_api.py
│ │ │ │ ├── lvis_evaluation.py
│ │ │ │ ├── panoptic_evaluation.py
│ │ │ │ ├── pascal_voc_evaluation.py
│ │ │ │ ├── rotated_coco_evaluation.py
│ │ │ │ ├── sem_seg_evaluation.py
│ │ │ │ └── testing.py
│ │ │ ├── export/
│ │ │ │ ├── README.md
│ │ │ │ ├── __init__.py
│ │ │ │ ├── api.py
│ │ │ │ ├── c10.py
│ │ │ │ ├── caffe2_export.py
│ │ │ │ ├── caffe2_inference.py
│ │ │ │ ├── caffe2_modeling.py
│ │ │ │ ├── caffe2_patch.py
│ │ │ │ ├── flatten.py
│ │ │ │ ├── shared.py
│ │ │ │ ├── torchscript.py
│ │ │ │ └── torchscript_patch.py
│ │ │ ├── layers/
│ │ │ │ ├── __init__.py
│ │ │ │ ├── aspp.py
│ │ │ │ ├── batch_norm.py
│ │ │ │ ├── blocks.py
│ │ │ │ ├── csrc/
│ │ │ │ │ ├── README.md
│ │ │ │ │ ├── ROIAlignRotated/
│ │ │ │ │ │ ├── ROIAlignRotated.h
│ │ │ │ │ │ ├── ROIAlignRotated_cpu.cpp
│ │ │ │ │ │ └── ROIAlignRotated_cuda.cu
│ │ │ │ │ ├── box_iou_rotated/
│ │ │ │ │ │ ├── box_iou_rotated.h
│ │ │ │ │ │ ├── box_iou_rotated_cpu.cpp
│ │ │ │ │ │ ├── box_iou_rotated_cuda.cu
│ │ │ │ │ │ └── box_iou_rotated_utils.h
│ │ │ │ │ ├── cocoeval/
│ │ │ │ │ │ ├── cocoeval.cpp
│ │ │ │ │ │ └── cocoeval.h
│ │ │ │ │ ├── cuda_version.cu
│ │ │ │ │ ├── deformable/
│ │ │ │ │ │ ├── deform_conv.h
│ │ │ │ │ │ ├── deform_conv_cuda.cu
│ │ │ │ │ │ └── deform_conv_cuda_kernel.cu
│ │ │ │ │ ├── nms_rotated/
│ │ │ │ │ │ ├── nms_rotated.h
│ │ │ │ │ │ ├── nms_rotated_cpu.cpp
│ │ │ │ │ │ └── nms_rotated_cuda.cu
│ │ │ │ │ └── vision.cpp
│ │ │ │ ├── deform_conv.py
│ │ │ │ ├── losses.py
│ │ │ │ ├── mask_ops.py
│ │ │ │ ├── nms.py
│ │ │ │ ├── roi_align.py
│ │ │ │ ├── roi_align_rotated.py
│ │ │ │ ├── rotated_boxes.py
│ │ │ │ ├── shape_spec.py
│ │ │ │ └── wrappers.py
│ │ │ ├── model_zoo/
│ │ │ │ ├── __init__.py
│ │ │ │ └── model_zoo.py
│ │ │ ├── modeling/
│ │ │ │ ├── __init__.py
│ │ │ │ ├── anchor_generator.py
│ │ │ │ ├── backbone/
│ │ │ │ │ ├── __init__.py
│ │ │ │ │ ├── backbone.py
│ │ │ │ │ ├── build.py
│ │ │ │ │ ├── fpn.py
│ │ │ │ │ ├── mvit.py
│ │ │ │ │ ├── regnet.py
│ │ │ │ │ ├── resnet.py
│ │ │ │ │ ├── swin.py
│ │ │ │ │ ├── utils.py
│ │ │ │ │ └── vit.py
│ │ │ │ ├── box_regression.py
│ │ │ │ ├── matcher.py
│ │ │ │ ├── meta_arch/
│ │ │ │ │ ├── __init__.py
│ │ │ │ │ ├── build.py
│ │ │ │ │ ├── dense_detector.py
│ │ │ │ │ ├── fcos.py
│ │ │ │ │ ├── panoptic_fpn.py
│ │ │ │ │ ├── rcnn.py
│ │ │ │ │ ├── retinanet.py
│ │ │ │ │ └── semantic_seg.py
│ │ │ │ ├── mmdet_wrapper.py
│ │ │ │ ├── poolers.py
│ │ │ │ ├── postprocessing.py
│ │ │ │ ├── proposal_generator/
│ │ │ │ │ ├── __init__.py
│ │ │ │ │ ├── build.py
│ │ │ │ │ ├── proposal_utils.py
│ │ │ │ │ ├── rpn.py
│ │ │ │ │ └── rrpn.py
│ │ │ │ ├── roi_heads/
│ │ │ │ │ ├── __init__.py
│ │ │ │ │ ├── box_head.py
│ │ │ │ │ ├── cascade_rcnn.py
│ │ │ │ │ ├── fast_rcnn.py
│ │ │ │ │ ├── keypoint_head.py
│ │ │ │ │ ├── mask_head.py
│ │ │ │ │ ├── roi_heads.py
│ │ │ │ │ └── rotated_fast_rcnn.py
│ │ │ │ ├── sampling.py
│ │ │ │ └── test_time_augmentation.py
│ │ │ ├── projects/
│ │ │ │ ├── README.md
│ │ │ │ ├── __init__.py
│ │ │ │ └── deeplab/
│ │ │ │ ├── __init__.py
│ │ │ │ ├── build_solver.py
│ │ │ │ ├── config.py
│ │ │ │ ├── loss.py
│ │ │ │ ├── lr_scheduler.py
│ │ │ │ ├── resnet.py
│ │ │ │ └── semantic_seg.py
│ │ │ ├── solver/
│ │ │ │ ├── __init__.py
│ │ │ │ ├── build.py
│ │ │ │ └── lr_scheduler.py
│ │ │ ├── structures/
│ │ │ │ ├── __init__.py
│ │ │ │ ├── boxes.py
│ │ │ │ ├── image_list.py
│ │ │ │ ├── instances.py
│ │ │ │ ├── keypoints.py
│ │ │ │ ├── masks.py
│ │ │ │ └── rotated_boxes.py
│ │ │ ├── tracking/
│ │ │ │ ├── __init__.py
│ │ │ │ ├── base_tracker.py
│ │ │ │ ├── bbox_iou_tracker.py
│ │ │ │ ├── hungarian_tracker.py
│ │ │ │ ├── iou_weighted_hungarian_bbox_iou_tracker.py
│ │ │ │ ├── utils.py
│ │ │ │ └── vanilla_hungarian_bbox_iou_tracker.py
│ │ │ └── utils/
│ │ │ ├── README.md
│ │ │ ├── __init__.py
│ │ │ ├── analysis.py
│ │ │ ├── collect_env.py
│ │ │ ├── colormap.py
│ │ │ ├── comm.py
│ │ │ ├── develop.py
│ │ │ ├── env.py
│ │ │ ├── events.py
│ │ │ ├── file_io.py
│ │ │ ├── logger.py
│ │ │ ├── memory.py
│ │ │ ├── registry.py
│ │ │ ├── serialize.py
│ │ │ ├── testing.py
│ │ │ ├── tracing.py
│ │ │ ├── video_visualizer.py
│ │ │ └── visualizer.py
│ │ ├── oneformer/
│ │ │ ├── __init__.py
│ │ │ ├── config.py
│ │ │ ├── data/
│ │ │ │ ├── __init__.py
│ │ │ │ ├── build.py
│ │ │ │ ├── dataset_mappers/
│ │ │ │ │ ├── __init__.py
│ │ │ │ │ ├── coco_unified_new_baseline_dataset_mapper.py
│ │ │ │ │ ├── dataset_mapper.py
│ │ │ │ │ └── oneformer_unified_dataset_mapper.py
│ │ │ │ ├── datasets/
│ │ │ │ │ ├── __init__.py
│ │ │ │ │ ├── register_ade20k_instance.py
│ │ │ │ │ ├── register_ade20k_panoptic.py
│ │ │ │ │ ├── register_cityscapes_panoptic.py
│ │ │ │ │ ├── register_coco_panoptic2instance.py
│ │ │ │ │ └── register_coco_panoptic_annos_semseg.py
│ │ │ │ └── tokenizer.py
│ │ │ ├── demo/
│ │ │ │ ├── colormap.py
│ │ │ │ ├── defaults.py
│ │ │ │ ├── predictor.py
│ │ │ │ └── visualizer.py
│ │ │ ├── evaluation/
│ │ │ │ ├── __init__.py
│ │ │ │ ├── cityscapes_evaluation.py
│ │ │ │ ├── coco_evaluator.py
│ │ │ │ ├── detection_coco_evaluator.py
│ │ │ │ ├── evaluator.py
│ │ │ │ └── instance_evaluation.py
│ │ │ ├── modeling/
│ │ │ │ ├── __init__.py
│ │ │ │ ├── backbone/
│ │ │ │ │ ├── __init__.py
│ │ │ │ │ ├── dinat.py
│ │ │ │ │ └── swin.py
│ │ │ │ ├── matcher.py
│ │ │ │ ├── meta_arch/
│ │ │ │ │ ├── __init__.py
│ │ │ │ │ └── oneformer_head.py
│ │ │ │ ├── pixel_decoder/
│ │ │ │ │ ├── __init__.py
│ │ │ │ │ ├── fpn.py
│ │ │ │ │ ├── msdeformattn.py
│ │ │ │ │ └── ops/
│ │ │ │ │ ├── functions/
│ │ │ │ │ │ ├── __init__.py
│ │ │ │ │ │ └── ms_deform_attn_func.py
│ │ │ │ │ ├── make.sh
│ │ │ │ │ ├── modules/
│ │ │ │ │ │ ├── __init__.py
│ │ │ │ │ │ └── ms_deform_attn.py
│ │ │ │ │ ├── setup.py
│ │ │ │ │ ├── src/
│ │ │ │ │ │ ├── cpu/
│ │ │ │ │ │ │ ├── ms_deform_attn_cpu.cpp
│ │ │ │ │ │ │ └── ms_deform_attn_cpu.h
│ │ │ │ │ │ ├── cuda/
│ │ │ │ │ │ │ ├── ms_deform_attn_cuda.cu
│ │ │ │ │ │ │ ├── ms_deform_attn_cuda.h
│ │ │ │ │ │ │ └── ms_deform_im2col_cuda.cuh
│ │ │ │ │ │ ├── ms_deform_attn.h
│ │ │ │ │ │ └── vision.cpp
│ │ │ │ │ └── test.py
│ │ │ │ └── transformer_decoder/
│ │ │ │ ├── __init__.py
│ │ │ │ ├── oneformer_transformer_decoder.py
│ │ │ │ ├── position_encoding.py
│ │ │ │ ├── text_transformer.py
│ │ │ │ └── transformer.py
│ │ │ ├── oneformer_model.py
│ │ │ └── utils/
│ │ │ ├── __init__.py
│ │ │ ├── box_ops.py
│ │ │ ├── events.py
│ │ │ ├── misc.py
│ │ │ └── pos_embed.py
│ │ └── pycocotools/
│ │ ├── __init__.py
│ │ ├── coco.py
│ │ ├── cocoeval.py
│ │ └── mask.py
│ ├── openpose/
│ │ ├── LICENSE
│ │ ├── __init__.py
│ │ ├── animalpose.py
│ │ ├── body.py
│ │ ├── cv_ox_det.py
│ │ ├── cv_ox_pose.py
│ │ ├── face.py
│ │ ├── hand.py
│ │ ├── model.py
│ │ ├── types.py
│ │ ├── util.py
│ │ └── wholebody.py
│ ├── pidinet/
│ │ ├── LICENSE
│ │ ├── __init__.py
│ │ └── model.py
│ ├── shuffle/
│ │ └── __init__.py
│ ├── teed/
│ │ ├── Fmish.py
│ │ ├── Fsmish.py
│ │ ├── LICENSE.txt
│ │ ├── Xmish.py
│ │ ├── Xsmish.py
│ │ ├── __init__.py
│ │ └── ted.py
│ ├── uniformer/
│ │ ├── LICENSE
│ │ ├── __init__.py
│ │ ├── configs/
│ │ │ └── _base_/
│ │ │ ├── datasets/
│ │ │ │ ├── ade20k.py
│ │ │ │ ├── chase_db1.py
│ │ │ │ ├── cityscapes.py
│ │ │ │ ├── cityscapes_769x769.py
│ │ │ │ ├── drive.py
│ │ │ │ ├── hrf.py
│ │ │ │ ├── pascal_context.py
│ │ │ │ ├── pascal_context_59.py
│ │ │ │ ├── pascal_voc12.py
│ │ │ │ ├── pascal_voc12_aug.py
│ │ │ │ └── stare.py
│ │ │ ├── default_runtime.py
│ │ │ ├── models/
│ │ │ │ ├── ann_r50-d8.py
│ │ │ │ ├── apcnet_r50-d8.py
│ │ │ │ ├── ccnet_r50-d8.py
│ │ │ │ ├── cgnet.py
│ │ │ │ ├── danet_r50-d8.py
│ │ │ │ ├── deeplabv3_r50-d8.py
│ │ │ │ ├── deeplabv3_unet_s5-d16.py
│ │ │ │ ├── deeplabv3plus_r50-d8.py
│ │ │ │ ├── dmnet_r50-d8.py
│ │ │ │ ├── dnl_r50-d8.py
│ │ │ │ ├── emanet_r50-d8.py
│ │ │ │ ├── encnet_r50-d8.py
│ │ │ │ ├── fast_scnn.py
│ │ │ │ ├── fcn_hr18.py
│ │ │ │ ├── fcn_r50-d8.py
│ │ │ │ ├── fcn_unet_s5-d16.py
│ │ │ │ ├── fpn_r50.py
│ │ │ │ ├── fpn_uniformer.py
│ │ │ │ ├── gcnet_r50-d8.py
│ │ │ │ ├── lraspp_m-v3-d8.py
│ │ │ │ ├── nonlocal_r50-d8.py
│ │ │ │ ├── ocrnet_hr18.py
│ │ │ │ ├── ocrnet_r50-d8.py
│ │ │ │ ├── pointrend_r50.py
│ │ │ │ ├── psanet_r50-d8.py
│ │ │ │ ├── pspnet_r50-d8.py
│ │ │ │ ├── pspnet_unet_s5-d16.py
│ │ │ │ ├── upernet_r50.py
│ │ │ │ └── upernet_uniformer.py
│ │ │ └── schedules/
│ │ │ ├── schedule_160k.py
│ │ │ ├── schedule_20k.py
│ │ │ ├── schedule_40k.py
│ │ │ └── schedule_80k.py
│ │ ├── inference.py
│ │ ├── mmcv_custom/
│ │ │ ├── __init__.py
│ │ │ └── checkpoint.py
│ │ ├── uniformer.py
│ │ └── upernet_global_small.py
│ ├── util.py
│ └── zoe/
│ ├── LICENSE
│ ├── __init__.py
│ └── zoedepth/
│ ├── models/
│ │ ├── __init__.py
│ │ ├── base_models/
│ │ │ ├── __init__.py
│ │ │ ├── midas.py
│ │ │ └── midas_repo/
│ │ │ ├── .gitignore
│ │ │ ├── Dockerfile
│ │ │ ├── LICENSE
│ │ │ ├── README.md
│ │ │ ├── environment.yaml
│ │ │ ├── hubconf.py
│ │ │ ├── input/
│ │ │ │ └── .placeholder
│ │ │ ├── midas/
│ │ │ │ ├── backbones/
│ │ │ │ │ ├── beit.py
│ │ │ │ │ ├── levit.py
│ │ │ │ │ ├── next_vit.py
│ │ │ │ │ ├── swin.py
│ │ │ │ │ ├── swin2.py
│ │ │ │ │ ├── swin_common.py
│ │ │ │ │ ├── utils.py
│ │ │ │ │ └── vit.py
│ │ │ │ ├── base_model.py
│ │ │ │ ├── blocks.py
│ │ │ │ ├── dpt_depth.py
│ │ │ │ ├── midas_net.py
│ │ │ │ ├── midas_net_custom.py
│ │ │ │ ├── model_loader.py
│ │ │ │ └── transforms.py
│ │ │ ├── output/
│ │ │ │ └── .placeholder
│ │ │ ├── ros/
│ │ │ │ ├── LICENSE
│ │ │ │ ├── README.md
│ │ │ │ ├── additions/
│ │ │ │ │ ├── do_catkin_make.sh
│ │ │ │ │ ├── downloads.sh
│ │ │ │ │ ├── install_ros_melodic_ubuntu_17_18.sh
│ │ │ │ │ ├── install_ros_noetic_ubuntu_20.sh
│ │ │ │ │ └── make_package_cpp.sh
│ │ │ │ ├── launch_midas_cpp.sh
│ │ │ │ ├── midas_cpp/
│ │ │ │ │ ├── CMakeLists.txt
│ │ │ │ │ ├── launch/
│ │ │ │ │ │ ├── midas_cpp.launch
│ │ │ │ │ │ └── midas_talker_listener.launch
│ │ │ │ │ ├── package.xml
│ │ │ │ │ ├── scripts/
│ │ │ │ │ │ ├── listener.py
│ │ │ │ │ │ ├── listener_original.py
│ │ │ │ │ │ └── talker.py
│ │ │ │ │ └── src/
│ │ │ │ │ └── main.cpp
│ │ │ │ └── run_talker_listener_test.sh
│ │ │ ├── run.py
│ │ │ ├── tf/
│ │ │ │ ├── README.md
│ │ │ │ ├── input/
│ │ │ │ │ └── .placeholder
│ │ │ │ ├── make_onnx_model.py
│ │ │ │ ├── output/
│ │ │ │ │ └── .placeholder
│ │ │ │ ├── run_onnx.py
│ │ │ │ ├── run_pb.py
│ │ │ │ ├── transforms.py
│ │ │ │ └── utils.py
│ │ │ ├── utils.py
│ │ │ └── weights/
│ │ │ └── .placeholder
│ │ ├── builder.py
│ │ ├── depth_model.py
│ │ ├── layers/
│ │ │ ├── attractor.py
│ │ │ ├── dist_layers.py
│ │ │ ├── localbins_layers.py
│ │ │ └── patch_transformer.py
│ │ ├── model_io.py
│ │ ├── zoedepth/
│ │ │ ├── __init__.py
│ │ │ ├── config_zoedepth.json
│ │ │ ├── config_zoedepth_kitti.json
│ │ │ └── zoedepth_v1.py
│ │ └── zoedepth_nk/
│ │ ├── __init__.py
│ │ ├── config_zoedepth_nk.json
│ │ └── zoedepth_nk_v1.py
│ └── utils/
│ ├── __init__.py
│ ├── arg_utils.py
│ ├── config.py
│ ├── easydict/
│ │ └── __init__.py
│ ├── geometry.py
│ └── misc.py
├── example/
│ ├── advanced_weighting_example/
│ │ └── api_advanced_weighting.py
│ ├── chatgpt.py
│ ├── inpaint_example/
│ │ └── api_inpaint.py
│ ├── txt2img_example/
│ │ └── api_txt2img.py
│ └── visual_chatgpt.ipynb
├── extract_controlnet.py
├── extract_controlnet_diff.py
├── install.py
├── internal_controlnet/
│ ├── __init__.py
│ ├── args.py
│ └── external_code.py
├── javascript/
│ ├── canvas.js
│ ├── controlnet_unit.mjs
│ ├── index.mjs
│ ├── modal.mjs
│ ├── openpose_editor.mjs
│ └── photopea.mjs
├── models/
│ └── put_controlnet_models_here.txt
├── patch_version.py
├── preload.py
├── pyproject.toml
├── requirements.txt
├── scripts/
│ ├── adapter.py
│ ├── animate_diff/
│ │ └── batch.py
│ ├── api.py
│ ├── batch_hijack.py
│ ├── cldm.py
│ ├── controlnet.py
│ ├── controlnet_core/
│ │ └── controlnet_union.py
│ ├── controlnet_diffusers.py
│ ├── controlnet_lllite.py
│ ├── controlnet_lora.py
│ ├── controlnet_model_guess.py
│ ├── controlnet_sparsectrl.py
│ ├── controlnet_ui/
│ │ ├── advanced_weight_control.py
│ │ ├── controlnet_ui_group.py
│ │ ├── modal.py
│ │ ├── openpose_editor.py
│ │ └── photopea.py
│ ├── controlnet_version.py
│ ├── enums.py
│ ├── external_code.py
│ ├── global_state.py
│ ├── hook.py
│ ├── infotext.py
│ ├── ipadapter/
│ │ ├── __init__.py
│ │ ├── image_proj_models.py
│ │ ├── ipadapter_model.py
│ │ ├── plugable_ipadapter.py
│ │ ├── presets.py
│ │ ├── pulid_attn.py
│ │ └── weight.py
│ ├── logging.py
│ ├── lvminthin.py
│ ├── movie2movie.py
│ ├── preprocessor/
│ │ ├── __init__.py
│ │ ├── inpaint.py
│ │ ├── ip_adapter_auto.py
│ │ ├── lama_inpaint.py
│ │ ├── legacy/
│ │ │ ├── legacy_preprocessors.py
│ │ │ ├── preprocessor_compiled.py
│ │ │ └── processor.py
│ │ ├── mobile_sam.py
│ │ ├── model_free_preprocessors.py
│ │ ├── normal_dsine.py
│ │ ├── pulid.py
│ │ └── teed.py
│ ├── supported_preprocessor.py
│ ├── utils.py
│ └── xyz_grid_support.py
├── style.css
├── tests/
│ ├── README.md
│ ├── annotator_tests/
│ │ └── openpose_tests/
│ │ ├── body_test.py
│ │ ├── detection_test.py
│ │ ├── json_encode_test.py
│ │ └── openpose_e2e_test_disabled.py
│ ├── cn_script/
│ │ ├── __init__.py
│ │ ├── batch_hijack_test.py
│ │ ├── cn_script_test.py
│ │ └── utils_test.py
│ ├── conftest.py
│ ├── external_code_api/
│ │ ├── __init__.py
│ │ └── external_code_test.py
│ ├── utils.py
│ └── web_api/
│ ├── __init__.py
│ ├── animal_pose.json
│ ├── clip_mask_test.py
│ ├── detect_test.py
│ ├── effective_region_test.py
│ ├── full_coverage/
│ │ ├── README.md
│ │ ├── __init__.py
│ │ ├── depth_test.py
│ │ ├── inpaint_test.py
│ │ ├── ipadapter_test.py
│ │ └── template.py
│ ├── generation_test.py
│ ├── ipadapter_advanced_weighting.py
│ ├── ipadapter_clip_api.py
│ ├── modules_test.py
│ ├── pose.json
│ ├── render_openpose_json.py
│ └── template.py
├── unit_tests/
│ ├── __init__.py
│ └── args_test.py
└── web_tests/
├── README.md
└── main.py
================================================
FILE CONTENTS
================================================
================================================
FILE: .github/ISSUE_TEMPLATE/bug_report.yml
================================================
name: Bug Report
description: Create a report
title: "[Bug]: "
labels: ["bug-report"]
body:
- type: checkboxes
attributes:
label: Is there an existing issue for this?
description: Please search to see if an issue already exists for the bug you encountered, and that it hasn't been fixed in a recent build/commit.
options:
- label: I have searched the existing issues and checked the recent builds/commits of both this extension and the webui
required: true
- type: markdown
attributes:
value: |
*Please fill this form with as much information as possible, don't forget to fill "What OS..." and "What browsers" and *provide screenshots if possible**
- type: textarea
id: what-did
attributes:
label: What happened?
description: Tell us what happened in a very clear and simple way
validations:
required: true
- type: textarea
id: steps
attributes:
label: Steps to reproduce the problem
description: Please provide us with precise step by step information on how to reproduce the bug
value: |
1. Go to ....
2. Press ....
3. ...
validations:
required: true
- type: textarea
id: what-should
attributes:
label: What should have happened?
description: Tell what you think the normal behavior should be
validations:
required: true
- type: textarea
id: commits
attributes:
label: Commit where the problem happens
description: Which commit of the extension are you running on? Please include the commit of both the extension and the webui (Do not write *Latest version/repo/commit*, as this means nothing and will have changed by the time we read your issue. Rather, copy the **Commit** link at the bottom of the UI, or from the cmd/terminal if you can't launch it.)
value: |
webui:
controlnet:
validations:
required: true
- type: dropdown
id: browsers
attributes:
label: What browsers do you use to access the UI ?
multiple: true
options:
- Mozilla Firefox
- Google Chrome
- Brave
- Apple Safari
- Microsoft Edge
- type: textarea
id: cmdargs
attributes:
label: Command Line Arguments
description: Are you using any launching parameters/command line arguments (modified webui-user .bat/.sh) ? If yes, please write them below. Write "No" otherwise.
render: Shell
validations:
required: true
- type: textarea
id: extensions
attributes:
label: List of enabled extensions
description: Please provide a full list of enabled extensions or screenshots of your "Extensions" tab.
validations:
required: true
- type: textarea
id: logs
attributes:
label: Console logs
description: Please provide full cmd/terminal logs from the moment you started UI to the end of it, after your bug happened. If it's very long, provide a link to pastebin or similar service.
render: Shell
validations:
required: true
- type: textarea
id: misc
attributes:
label: Additional information
description: Please provide us with any relevant additional info or context.
================================================
FILE: .github/ISSUE_TEMPLATE/config.yml
================================================
blank_issues_enabled: true
================================================
FILE: .github/workflows/lint.yaml
================================================
name: Linter
on:
- push
- pull_request
jobs:
lint-python:
name: ruff
runs-on: ubuntu-latest
steps:
- name: Checkout Code
uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
python-version: 3.11
# NB: there's no cache: pip here since we're not installing anything
# from the requirements.txt file(s) in the repository; it's faster
# not to have GHA download an (at the time of writing) 4 GB cache
# of PyTorch and other dependencies.
- name: Install Ruff
run: pip install ruff==0.1.6
- name: Run Ruff
run: ruff .
================================================
FILE: .github/workflows/tests.yml
================================================
name: Run basic features tests on CPU
on:
- push
- pull_request
env:
FORGE_CQ_TEST: "True"
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout Code
uses: actions/checkout@v3
with:
repository: 'AUTOMATIC1111/stable-diffusion-webui'
path: 'stable-diffusion-webui'
ref: '1c0a0c4c26f78c32095ebc7f8af82f5c04fca8c0'
- name: Checkout Code
uses: actions/checkout@v3
with:
repository: 'Mikubill/sd-webui-controlnet'
path: 'stable-diffusion-webui/extensions/sd-webui-controlnet'
- name: Set up Python 3.10
uses: actions/setup-python@v4
with:
python-version: 3.10.6
cache: pip
cache-dependency-path: |
**/requirements*txt
launch.py
- name: Install test dependencies
run: |
pip install wait-for-it
pip install -r requirements-test.txt
working-directory: stable-diffusion-webui
env:
PIP_DISABLE_PIP_VERSION_CHECK: "1"
PIP_PROGRESS_BAR: "off"
- name: Setup environment
run: python launch.py --skip-torch-cuda-test --exit
working-directory: stable-diffusion-webui
env:
PIP_DISABLE_PIP_VERSION_CHECK: "1"
PIP_PROGRESS_BAR: "off"
TORCH_INDEX_URL: https://download.pytorch.org/whl/cpu
WEBUI_LAUNCH_LIVE_OUTPUT: "1"
PYTHONUNBUFFERED: "1"
- name: Cache ControlNet models
uses: actions/cache@v3
with:
path: stable-diffusion-webui/extensions/sd-webui-controlnet/models/
key: controlnet-models-v3
- name: Cache Preprocessor models
uses: actions/cache@v3
with:
path: stable-diffusion-webui/extensions/sd-webui-controlnet/annotator/downloads/
key: preprocessor-models-v1
- name: Download controlnet model for testing
run: |
declare -a urls=(
"https://huggingface.co/lllyasviel/ControlNet-v1-1/resolve/main/control_v11p_sd15_canny.pth"
"https://huggingface.co/h94/IP-Adapter/resolve/main/models/ip-adapter-full-face_sd15.safetensors"
"https://huggingface.co/h94/IP-Adapter/resolve/main/models/ip-adapter-plus-face_sd15.safetensors"
"https://huggingface.co/TencentARC/T2I-Adapter/resolve/main/models/t2iadapter_canny_sd15v2.pth"
"https://huggingface.co/comfyanonymous/ControlNet-v1-1_fp16_safetensors/resolve/main/control_lora_rank128_v11p_sd15_canny_fp16.safetensors"
)
for url in "${urls[@]}"; do
filename="extensions/sd-webui-controlnet/models/${url##*/}" # Extracts the last part of the URL
if [ ! -f "$filename" ]; then
curl -Lo "$filename" "$url"
fi
done
working-directory: stable-diffusion-webui
- name: Start test server
run: >
python -m coverage run
--data-file=.coverage.server
launch.py
--skip-prepare-environment
--skip-torch-cuda-test
--test-server
--do-not-download-clip
--no-half
--disable-opt-split-attention
--use-cpu all
--api-server-stop
2>&1 | tee output.txt &
working-directory: stable-diffusion-webui
- name: Run tests
run: |
wait-for-it --service 127.0.0.1:7860 -t 600
python -m pytest -v --junitxml=test/results.xml --cov ./extensions/sd-webui-controlnet --cov-report=xml --verify-base-url ./extensions/sd-webui-controlnet/tests
working-directory: stable-diffusion-webui
- name: Run unit tests
run: |
python -m pytest -v ./unit_tests/
working-directory: stable-diffusion-webui/extensions/sd-webui-controlnet/
- name: Kill test server
if: always()
run: curl -vv -XPOST http://127.0.0.1:7860/sdapi/v1/server-stop && sleep 10
- name: Show coverage
run: |
python -m coverage combine .coverage*
python -m coverage report -i
python -m coverage html -i
working-directory: stable-diffusion-webui
- name: Upload main app output
uses: actions/upload-artifact@v3
if: always()
with:
name: output
path: stable-diffusion-webui/output.txt
- name: Upload coverage HTML
uses: actions/upload-artifact@v3
if: always()
with:
name: htmlcov
path: stable-diffusion-webui/htmlcov
================================================
FILE: .gitignore
================================================
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class
# C extensions
*.so
# Distribution / packaging
.Python
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
share/python-wheels/
*.egg-info/
.installed.cfg
*.egg
MANIFEST
# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec
# Installer logs
pip-log.txt
pip-delete-this-directory.txt
# Unit test / coverage reports
htmlcov/
.tox/
.nox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*.cover
*.py,cover
.hypothesis/
.pytest_cache/
cover/
# Translations
*.mo
*.pot
# Django stuff:
*.log
local_settings.py
db.sqlite3
db.sqlite3-journal
# Flask stuff:
instance/
.webassets-cache
# Scrapy stuff:
.scrapy
# Sphinx documentation
docs/_build/
# PyBuilder
.pybuilder/
target/
# Jupyter Notebook
.ipynb_checkpoints
# IPython
profile_default/
ipython_config.py
# pyenv
# For a library or package, you might want to ignore these files since the code is
# intended to run in multiple environments; otherwise, check them in:
# .python-version
# pipenv
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
# However, in case of collaboration, if having platform-specific dependencies or dependencies
# having no cross-platform support, pipenv may install dependencies that don't work, or not
# install all needed dependencies.
#Pipfile.lock
# poetry
# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
# This is especially recommended for binary packages to ensure reproducibility, and is more
# commonly ignored for libraries.
# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
#poetry.lock
# pdm
# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
#pdm.lock
# pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it
# in version control.
# https://pdm.fming.dev/#use-with-ide
.pdm.toml
# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
__pypackages__/
# Celery stuff
celerybeat-schedule
celerybeat.pid
# SageMath parsed files
*.sage.py
# Environments
.env
.venv
env/
venv/
ENV/
env.bak/
venv.bak/
# Spyder project settings
.spyderproject
.spyproject
# Rope project settings
.ropeproject
# mkdocs documentation
/site
# mypy
.mypy_cache/
.dmypy.json
dmypy.json
# Pyre type checker
.pyre/
# pytype static type analyzer
.pytype/
# Cython debug symbols
cython_debug/
# PyCharm
# JetBrains specific template is maintained in a separate JetBrains.gitignore that can
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
# and can be added to the global gitignore or merged into this file. For a more nuclear
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
#.idea
*.pt
*.pth
*.ckpt
*.bin
*.safetensors
# Editor setting metadata
.idea/
.vscode/
detected_maps/
annotator/downloads/
# test results and expectations
web_tests/results/
web_tests/expectations/
tests/web_api/full_coverage/results/
tests/web_api/full_coverage/expectations/
tests/web_api/results/
tests/web_api/expectations/
*_diff.png
# Presets
presets/
# Ignore existing dir of hand refiner if exists.
annotator/hand_refiner_portable
# Ruff linter cache dir
.ruff_cache/
================================================
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
================================================
# ControlNet for Stable Diffusion WebUI
The WebUI extension for ControlNet and other injection-based SD controls.

This extension is for AUTOMATIC1111's [Stable Diffusion web UI](https://github.com/AUTOMATIC1111/stable-diffusion-webui), allows the Web UI to add [ControlNet](https://github.com/lllyasviel/ControlNet) to the original Stable Diffusion model to generate images. The addition is on-the-fly, the merging is not required.
# News
- [2024-07-09] 🔥[v1.1.454] ControlNet union model support [Discussion thread: https://github.com/Mikubill/sd-webui-controlnet/discussions/2989]
- [2024-07-01] 🔥[v1.1.452] Depth Anything V2 - UDAV2 depth Preprocessor [Pull thread: https://github.com/Mikubill/sd-webui-controlnet/pull/2969]
- [2024-05-19] 🔥[v1.1.449] Anyline Preprocessor & MistoLine SDXL model [Discussion thread: https://github.com/Mikubill/sd-webui-controlnet/discussions/2907]
- [2024-05-04] 🔥[v1.1.447] PuLID [Discussion thread: https://github.com/Mikubill/sd-webui-controlnet/discussions/2841]
- [2024-04-30] 🔥[v1.1.446] Effective region mask supported for ControlNet/IPAdapter [Discussion thread: https://github.com/Mikubill/sd-webui-controlnet/discussions/2831]
- [2024-04-27] 🔥ControlNet-lllite Normal Dsine released [Discussion thread: https://github.com/Mikubill/sd-webui-controlnet/discussions/2813]
- [2024-04-19] 🔥[v1.1.445] IPAdapter advanced weight [Instant Style] [Discussion thread: https://github.com/Mikubill/sd-webui-controlnet/discussions/2770]
- [2024-04-17] 🔥[v1.1.444] Marigold depth preprocessor [Discussion thread: https://github.com/Mikubill/sd-webui-controlnet/discussions/2760]
- [2024-04-15] 🔥ControlNet++ models released [Discussion thread: https://github.com/Mikubill/sd-webui-controlnet/discussions/2778]
- [2024-04-13] 🔥TTPLanet_SDXL_Controlnet_Tile_Realistic v2 released [[Civitai Page](https://civitai.com/models/330313/ttplanetsdxlcontrolnettilerealistic)]
- [2024-03-31] 🔥[v1.1.443] IP-Adapter CLIP mask and ip-adapter-auto preprocessor [Discussion thread: https://github.com/Mikubill/sd-webui-controlnet/discussions/2723]
- [2024-03-20] 🔥IPAdapter Composition [Discussion thread: https://github.com/Mikubill/sd-webui-controlnet/discussions/2781]
# Installation
1. Open "Extensions" tab.
2. Open "Install from URL" tab in the tab.
3. Enter `https://github.com/Mikubill/sd-webui-controlnet.git` to "URL for extension's git repository".
4. Press "Install" button.
5. Wait for 5 seconds, and you will see the message "Installed into stable-diffusion-webui\extensions\sd-webui-controlnet. Use Installed tab to restart".
6. Go to "Installed" tab, click "Check for updates", and then click "Apply and restart UI". (The next time you can also use these buttons to update ControlNet.)
7. Completely restart A1111 webui including your terminal. (If you do not know what is a "terminal", you can reboot your computer to achieve the same effect.)
8. Download models (see below).
9. After you put models in the correct folder, you may need to refresh to see the models. The refresh button is right to your "Model" dropdown.
# Download Models
You can find all download links here: https://github.com/Mikubill/sd-webui-controlnet/wiki/Model-download.
# Features in ControlNet 1.1
### Perfect Support for All ControlNet 1.0/1.1 and T2I Adapter Models.
Now we have perfect support all available models and preprocessors, including perfect support for T2I style adapter and ControlNet 1.1 Shuffle. (Make sure that your YAML file names and model file names are same, see also YAML files in "stable-diffusion-webui\extensions\sd-webui-controlnet\models".)
### Perfect Support for A1111 High-Res. Fix
Now if you turn on High-Res Fix in A1111, each controlnet will output two different control images: a small one and a large one. The small one is for your basic generating, and the big one is for your High-Res Fix generating. The two control images are computed by a smart algorithm called "super high-quality control image resampling". This is turned on by default, and you do not need to change any setting.
### Perfect Support for All A1111 Img2Img or Inpaint Settings and All Mask Types
Now ControlNet is extensively tested with A1111's different types of masks, including "Inpaint masked"/"Inpaint not masked", and "Whole picture"/"Only masked", and "Only masked padding"&"Mask blur". The resizing perfectly matches A1111's "Just resize"/"Crop and resize"/"Resize and fill". This means you can use ControlNet in nearly everywhere in your A1111 UI without difficulty!
### The New "Pixel-Perfect" Mode
Now if you turn on pixel-perfect mode, you do not need to set preprocessor (annotator) resolutions manually. The ControlNet will automatically compute the best annotator resolution for you so that each pixel perfectly matches Stable Diffusion.
### User-Friendly GUI and Preprocessor Preview
We reorganized some previously confusing UI like "canvas width/height for new canvas" and it is in the 📝 button now. Now the preview GUI is controlled by the "allow preview" option and the trigger button 💥. The preview image size is better than before, and you do not need to scroll up and down - your a1111 GUI will not be messed up anymore!
### Support for Almost All Upscaling Scripts
Now ControlNet 1.1 can support almost all Upscaling/Tile methods. ControlNet 1.1 support the script "Ultimate SD upscale" and almost all other tile-based extensions. Please do not confuse ["Ultimate SD upscale"](https://github.com/Coyote-A/ultimate-upscale-for-automatic1111) with "SD upscale" - they are different scripts. Note that the most recommended upscaling method is ["Tiled VAE/Diffusion"](https://github.com/pkuliyi2015/multidiffusion-upscaler-for-automatic1111) but we test as many methods/extensions as possible. Note that "SD upscale" is supported since 1.1.117, and if you use it, you need to leave all ControlNet images as blank (We do not recommend "SD upscale" since it is somewhat buggy and cannot be maintained - use the "Ultimate SD upscale" instead).
### More Control Modes (previously called Guess Mode)
We have fixed many bugs in previous 1.0’s Guess Mode and now it is called Control Mode

Now you can control which aspect is more important (your prompt or your ControlNet):
* "Balanced": ControlNet on both sides of CFG scale, same as turning off "Guess Mode" in ControlNet 1.0
* "My prompt is more important": ControlNet on both sides of CFG scale, with progressively reduced SD U-Net injections (layer_weight*=0.825**I, where 0<=I <13, and the 13 means ControlNet injected SD 13 times). In this way, you can make sure that your prompts are perfectly displayed in your generated images.
* "ControlNet is more important": ControlNet only on the Conditional Side of CFG scale (the cond in A1111's batch-cond-uncond). This means the ControlNet will be X times stronger if your cfg-scale is X. For example, if your cfg-scale is 7, then ControlNet is 7 times stronger. Note that here the X times stronger is different from "Control Weights" since your weights are not modified. This "stronger" effect usually has less artifact and give ControlNet more room to guess what is missing from your prompts (and in the previous 1.0, it is called "Guess Mode").
<table width="100%">
<tr>
<td width="25%" style="text-align: center">Input (depth+canny+hed)</td>
<td width="25%" style="text-align: center">"Balanced"</td>
<td width="25%" style="text-align: center">"My prompt is more important"</td>
<td width="25%" style="text-align: center">"ControlNet is more important"</td>
</tr>
<tr>
<td width="25%" style="text-align: center"><img src="samples/cm1.png"></td>
<td width="25%" style="text-align: center"><img src="samples/cm2.png"></td>
<td width="25%" style="text-align: center"><img src="samples/cm3.png"></td>
<td width="25%" style="text-align: center"><img src="samples/cm4.png"></td>
</tr>
</table>
### Reference-Only Control
Now we have a `reference-only` preprocessor that does not require any control models. It can guide the diffusion directly using images as references.
(Prompt "a dog running on grassland, best quality, ...")

This method is similar to inpaint-based reference but it does not make your image disordered.
Many professional A1111 users know a trick to diffuse image with references by inpaint. For example, if you have a 512x512 image of a dog, and want to generate another 512x512 image with the same dog, some users will connect the 512x512 dog image and a 512x512 blank image into a 1024x512 image, send to inpaint, and mask out the blank 512x512 part to diffuse a dog with similar appearance. However, that method is usually not very satisfying since images are connected and many distortions will appear.
This `reference-only` ControlNet can directly link the attention layers of your SD to any independent images, so that your SD will read arbitrary images for reference. You need at least ControlNet 1.1.153 to use it.
To use, just select `reference-only` as preprocessor and put an image. Your SD will just use the image as reference.
*Note that this method is as "non-opinioned" as possible. It only contains very basic connection codes, without any personal preferences, to connect the attention layers with your reference images. However, even if we tried best to not include any opinioned codes, we still need to write some subjective implementations to deal with weighting, cfg-scale, etc - tech report is on the way.*
More examples [here](https://github.com/Mikubill/sd-webui-controlnet/discussions/1236).
# Technical Documents
See also the documents of ControlNet 1.1:
https://github.com/lllyasviel/ControlNet-v1-1-nightly#model-specification
# Default Setting
This is my setting. If you run into any problem, you can use this setting as a sanity check

# Use Previous Models
### Use ControlNet 1.0 Models
https://huggingface.co/lllyasviel/ControlNet/tree/main/models
You can still use all previous models in the previous ControlNet 1.0. Now, the previous "depth" is now called "depth_midas", the previous "normal" is called "normal_midas", the previous "hed" is called "softedge_hed". And starting from 1.1, all line maps, edge maps, lineart maps, boundary maps will have black background and white lines.
### Use T2I-Adapter Models
(From TencentARC/T2I-Adapter)
To use T2I-Adapter models:
1. Download files from https://huggingface.co/TencentARC/T2I-Adapter/tree/main/models
2. Put them in "stable-diffusion-webui\extensions\sd-webui-controlnet\models".
3. Make sure that the file names of pth files and yaml files are consistent.
*Note that "CoAdapter" is not implemented yet.*
# Gallery
The below results are from ControlNet 1.0.
| Source | Input | Output |
|:-------------------------:|:-------------------------:|:-------------------------:|
| (no preprocessor) | <img width="256" alt="" src="https://github.com/Mikubill/sd-webui-controlnet/blob/main/samples/bal-source.png?raw=true"> | <img width="256" alt="" src="https://github.com/Mikubill/sd-webui-controlnet/blob/main/samples/bal-gen.png?raw=true"> |
| (no preprocessor) | <img width="256" alt="" src="https://github.com/Mikubill/sd-webui-controlnet/blob/main/samples/dog_rel.jpg?raw=true"> | <img width="256" alt="" src="https://github.com/Mikubill/sd-webui-controlnet/blob/main/samples/dog_rel.png?raw=true"> |
|<img width="256" alt="" src="https://github.com/Mikubill/sd-webui-controlnet/blob/main/samples/mahiro_input.png?raw=true"> | <img width="256" alt="" src="https://github.com/Mikubill/sd-webui-controlnet/blob/main/samples/mahiro_canny.png?raw=true"> | <img width="256" alt="" src="https://github.com/Mikubill/sd-webui-controlnet/blob/main/samples/mahiro-out.png?raw=true"> |
|<img width="256" alt="" src="https://github.com/Mikubill/sd-webui-controlnet/blob/main/samples/evt_source.jpg?raw=true"> | <img width="256" alt="" src="https://github.com/Mikubill/sd-webui-controlnet/blob/main/samples/evt_hed.png?raw=true"> | <img width="256" alt="" src="https://github.com/Mikubill/sd-webui-controlnet/blob/main/samples/evt_gen.png?raw=true"> |
|<img width="256" alt="" src="https://github.com/Mikubill/sd-webui-controlnet/blob/main/samples/an-source.jpg?raw=true"> | <img width="256" alt="" src="https://github.com/Mikubill/sd-webui-controlnet/blob/main/samples/an-pose.png?raw=true"> | <img width="256" alt="" src="https://github.com/Mikubill/sd-webui-controlnet/blob/main/samples/an-gen.png?raw=true"> |
|<img width="256" alt="" src="https://github.com/Mikubill/sd-webui-controlnet/blob/main/samples/sk-b-src.png?raw=true"> | <img width="256" alt="" src="https://github.com/Mikubill/sd-webui-controlnet/blob/main/samples/sk-b-dep.png?raw=true"> | <img width="256" alt="" src="https://github.com/Mikubill/sd-webui-controlnet/blob/main/samples/sk-b-out.png?raw=true"> |
The below examples are from T2I-Adapter.
From `t2iadapter_color_sd14v1.pth` :
| Source | Input | Output |
|:-------------------------:|:-------------------------:|:-------------------------:|
| <img width="256" alt="" src="https://user-images.githubusercontent.com/31246794/222947416-ec9e52a4-a1d0-48d8-bb81-736bf636145e.jpeg"> | <img width="256" alt="" src="https://user-images.githubusercontent.com/31246794/222947435-1164e7d8-d857-42f9-ab10-2d4a4b25f33a.png"> | <img width="256" alt="" src="https://user-images.githubusercontent.com/31246794/222947557-5520d5f8-88b4-474d-a576-5c9cd3acac3a.png"> |
From `t2iadapter_style_sd14v1.pth` :
| Source | Input | Output |
|:-------------------------:|:-------------------------:|:-------------------------:|
| <img width="256" alt="" src="https://user-images.githubusercontent.com/31246794/222947416-ec9e52a4-a1d0-48d8-bb81-736bf636145e.jpeg"> | (clip, non-image) | <img width="256" alt="" src="https://user-images.githubusercontent.com/31246794/222965711-7b884c9e-7095-45cb-a91c-e50d296ba3a2.png"> |
# Minimum Requirements
* (Windows) (NVIDIA: Ampere) 4gb - with `--xformers` enabled, and `Low VRAM` mode ticked in the UI, goes up to 768x832
# Multi-ControlNet
This option allows multiple ControlNet inputs for a single generation. To enable this option, change `Multi ControlNet: Max models amount (requires restart)` in the settings. Note that you will need to restart the WebUI for changes to take effect.
<table width="100%">
<tr>
<td width="25%" style="text-align: center">Source A</td>
<td width="25%" style="text-align: center">Source B</td>
<td width="25%" style="text-align: center">Output</td>
</tr>
<tr>
<td width="25%" style="text-align: center"><img src="https://user-images.githubusercontent.com/31246794/220448620-cd3ede92-8d3f-43d5-b771-32dd8417618f.png"></td>
<td width="25%" style="text-align: center"><img src="https://user-images.githubusercontent.com/31246794/220448619-beed9bdb-f6bb-41c2-a7df-aa3ef1f653c5.png"></td>
<td width="25%" style="text-align: center"><img src="https://user-images.githubusercontent.com/31246794/220448613-c99a9e04-0450-40fd-bc73-a9122cefaa2c.png"></td>
</tr>
</table>
# Control Weight/Start/End
Weight is the weight of the controlnet "influence". It's analogous to prompt attention/emphasis. E.g. (myprompt: 1.2). Technically, it's the factor by which to multiply the ControlNet outputs before merging them with original SD Unet.
Guidance Start/End is the percentage of total steps the controlnet applies (guidance strength = guidance end). It's analogous to prompt editing/shifting. E.g. \[myprompt::0.8\] (It applies from the beginning until 80% of total steps)
# Batch Mode
Put any unit into batch mode to activate batch mode for all units. Specify a batch directory for each unit, or use the new textbox in the img2img batch tab as a fallback. Although the textbox is located in the img2img batch tab, you can use it to generate images in the txt2img tab as well.
Note that this feature is only available in the gradio user interface. Call the APIs as many times as you want for custom batch scheduling.
# API and Script Access
This extension can accept txt2img or img2img tasks via API or external extension call. Note that you may need to enable `Allow other scripts to control this extension` in settings for external calls.
To use the API: start WebUI with argument `--api` and go to `http://webui-address/docs` for documents or checkout [examples](https://github.com/Mikubill/sd-webui-controlnet/blob/main/example/txt2img_example/api_txt2img.py).
To use external call: Checkout [Wiki](https://github.com/Mikubill/sd-webui-controlnet/wiki/API)
# Command Line Arguments
This extension adds these command line arguments to the webui:
```
--controlnet-dir <path to directory with controlnet models> ADD a controlnet models directory
--controlnet-annotator-models-path <path to directory with annotator model directories> SET the directory for annotator models
--no-half-controlnet load controlnet models in full precision
--controlnet-preprocessor-cache-size Cache size for controlnet preprocessor results
--controlnet-loglevel Log level for the controlnet extension
--controlnet-tracemalloc Enable malloc memory tracing
```
# MacOS Support
Tested with pytorch nightly: https://github.com/Mikubill/sd-webui-controlnet/pull/143#issuecomment-1435058285
To use this extension with mps and normal pytorch, currently you may need to start WebUI with `--no-half`.
# Archive of Deprecated Versions
The previous version (sd-webui-controlnet 1.0) is archived in
https://github.com/lllyasviel/webui-controlnet-v1-archived
Using this version is not a temporary stop of updates. You will stop all updates forever.
Please consider this version if you work with professional studios that requires 100% reproducing of all previous results pixel by pixel.
# Thanks
This implementation is inspired by kohya-ss/sd-webui-additional-networks
================================================
FILE: annotator/__init__.py
================================================
================================================
FILE: annotator/anime_face_segment/LICENSE
================================================
MIT License
Copyright (c) 2021 Miaomiao Li
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
================================================
FILE: annotator/anime_face_segment/__init__.py
================================================
import os
import torch
import torch.nn as nn
import torch.nn.functional as F
from PIL import Image
import fnmatch
import cv2
import sys
import numpy as np
from modules import devices
from einops import rearrange
from annotator.annotator_path import models_path
import torchvision
from torchvision.models import MobileNet_V2_Weights
from torchvision import transforms
COLOR_BACKGROUND = (255,255,0)
COLOR_HAIR = (0,0,255)
COLOR_EYE = (255,0,0)
COLOR_MOUTH = (255,255,255)
COLOR_FACE = (0,255,0)
COLOR_SKIN = (0,255,255)
COLOR_CLOTHES = (255,0,255)
PALETTE = [COLOR_BACKGROUND,COLOR_HAIR,COLOR_EYE,COLOR_MOUTH,COLOR_FACE,COLOR_SKIN,COLOR_CLOTHES]
class UNet(nn.Module):
def __init__(self):
super(UNet, self).__init__()
self.NUM_SEG_CLASSES = 7 # Background, hair, face, eye, mouth, skin, clothes
mobilenet_v2 = torchvision.models.mobilenet_v2(weights=MobileNet_V2_Weights.IMAGENET1K_V1)
mob_blocks = mobilenet_v2.features
# Encoder
self.en_block0 = nn.Sequential( # in_ch=3 out_ch=16
mob_blocks[0],
mob_blocks[1]
)
self.en_block1 = nn.Sequential( # in_ch=16 out_ch=24
mob_blocks[2],
mob_blocks[3],
)
self.en_block2 = nn.Sequential( # in_ch=24 out_ch=32
mob_blocks[4],
mob_blocks[5],
mob_blocks[6],
)
self.en_block3 = nn.Sequential( # in_ch=32 out_ch=96
mob_blocks[7],
mob_blocks[8],
mob_blocks[9],
mob_blocks[10],
mob_blocks[11],
mob_blocks[12],
mob_blocks[13],
)
self.en_block4 = nn.Sequential( # in_ch=96 out_ch=160
mob_blocks[14],
mob_blocks[15],
mob_blocks[16],
)
# Decoder
self.de_block4 = nn.Sequential( # in_ch=160 out_ch=96
nn.UpsamplingNearest2d(scale_factor=2),
nn.Conv2d(160, 96, kernel_size=3, padding=1),
nn.InstanceNorm2d(96),
nn.LeakyReLU(0.1),
nn.Dropout(p=0.2)
)
self.de_block3 = nn.Sequential( # in_ch=96x2 out_ch=32
nn.UpsamplingNearest2d(scale_factor=2),
nn.Conv2d(96*2, 32, kernel_size=3, padding=1),
nn.InstanceNorm2d(32),
nn.LeakyReLU(0.1),
nn.Dropout(p=0.2)
)
self.de_block2 = nn.Sequential( # in_ch=32x2 out_ch=24
nn.UpsamplingNearest2d(scale_factor=2),
nn.Conv2d(32*2, 24, kernel_size=3, padding=1),
nn.InstanceNorm2d(24),
nn.LeakyReLU(0.1),
nn.Dropout(p=0.2)
)
self.de_block1 = nn.Sequential( # in_ch=24x2 out_ch=16
nn.UpsamplingNearest2d(scale_factor=2),
nn.Conv2d(24*2, 16, kernel_size=3, padding=1),
nn.InstanceNorm2d(16),
nn.LeakyReLU(0.1),
nn.Dropout(p=0.2)
)
self.de_block0 = nn.Sequential( # in_ch=16x2 out_ch=7
nn.UpsamplingNearest2d(scale_factor=2),
nn.Conv2d(16*2, self.NUM_SEG_CLASSES, kernel_size=3, padding=1),
nn.Softmax2d()
)
def forward(self, x):
e0 = self.en_block0(x)
e1 = self.en_block1(e0)
e2 = self.en_block2(e1)
e3 = self.en_block3(e2)
e4 = self.en_block4(e3)
d4 = self.de_block4(e4)
d4 = F.interpolate(d4, size=e3.size()[2:], mode='bilinear', align_corners=True)
c4 = torch.cat((d4,e3),1)
d3 = self.de_block3(c4)
d3 = F.interpolate(d3, size=e2.size()[2:], mode='bilinear', align_corners=True)
c3 = torch.cat((d3,e2),1)
d2 = self.de_block2(c3)
d2 = F.interpolate(d2, size=e1.size()[2:], mode='bilinear', align_corners=True)
c2 =torch.cat((d2,e1),1)
d1 = self.de_block1(c2)
d1 = F.interpolate(d1, size=e0.size()[2:], mode='bilinear', align_corners=True)
c1 = torch.cat((d1,e0),1)
y = self.de_block0(c1)
return y
class AnimeFaceSegment:
model_dir = os.path.join(models_path, "anime_face_segment")
def __init__(self):
self.model = None
self.device = devices.get_device_for("controlnet")
def load_model(self):
remote_model_path = "https://huggingface.co/bdsqlsz/qinglong_controlnet-lllite/resolve/main/Annotators/UNet.pth"
modelpath = os.path.join(self.model_dir, "UNet.pth")
if not os.path.exists(modelpath):
from scripts.utils import load_file_from_url
load_file_from_url(remote_model_path, model_dir=self.model_dir)
net = UNet()
ckpt = torch.load(modelpath, map_location=self.device)
for key in list(ckpt.keys()):
if 'module.' in key:
ckpt[key.replace('module.', '')] = ckpt[key]
del ckpt[key]
net.load_state_dict(ckpt)
net.eval()
self.model = net.to(self.device)
def unload_model(self):
if self.model is not None:
self.model.cpu()
def __call__(self, input_image):
if self.model is None:
self.load_model()
self.model.to(self.device)
transform = transforms.Compose([
transforms.Resize(512,interpolation=transforms.InterpolationMode.BICUBIC),
transforms.ToTensor(),])
img = Image.fromarray(input_image)
with torch.no_grad():
img = transform(img).unsqueeze(dim=0).to(self.device)
seg = self.model(img).squeeze(dim=0)
seg = seg.cpu().detach().numpy()
img = rearrange(seg,'h w c -> w c h')
img = [[PALETTE[np.argmax(val)] for val in buf]for buf in img]
return np.array(img).astype(np.uint8)
================================================
FILE: annotator/annotator_path.py
================================================
import os
from modules import shared
models_path = shared.opts.data.get('control_net_modules_path', None)
if not models_path:
models_path = getattr(shared.cmd_opts, 'controlnet_annotator_models_path', None)
if not models_path:
models_path = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'downloads')
if not os.path.isabs(models_path):
models_path = os.path.join(shared.data_path, models_path)
clip_vision_path = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'clip_vision')
# clip vision is always inside controlnet "extensions\sd-webui-controlnet"
# and any problem can be solved by removing controlnet and reinstall
models_path = os.path.realpath(models_path)
os.makedirs(models_path, exist_ok=True)
print(f'ControlNet preprocessor location: {models_path}')
# Make sure that the default location is inside controlnet "extensions\sd-webui-controlnet"
# so that any problem can be solved by removing controlnet and reinstall
# if users do not change configs on their own (otherwise users will know what is wrong)
================================================
FILE: annotator/binary/__init__.py
================================================
import cv2
def apply_binary(img, bin_threshold):
img_gray = cv2.cvtColor(img, cv2.COLOR_RGB2GRAY)
if bin_threshold == 0 or bin_threshold == 255:
# Otsu's threshold
otsu_threshold, img_bin = cv2.threshold(img_gray, 0, 255, cv2.THRESH_BINARY_INV + cv2.THRESH_OTSU)
print("Otsu threshold:", otsu_threshold)
else:
_, img_bin = cv2.threshold(img_gray, bin_threshold, 255, cv2.THRESH_BINARY_INV)
return cv2.cvtColor(img_bin, cv2.COLOR_GRAY2RGB)
================================================
FILE: annotator/canny/__init__.py
================================================
import cv2
def apply_canny(img, low_threshold, high_threshold):
return cv2.Canny(img, low_threshold, high_threshold)
================================================
FILE: annotator/clipvision/__init__.py
================================================
import os
import cv2
import torch
import numpy as np
from einops import rearrange
from modules import devices
from annotator.annotator_path import models_path
from transformers import CLIPVisionModelWithProjection, CLIPVisionConfig, CLIPImageProcessor
try:
from modules.modelloader import load_file_from_url
except ImportError:
# backward compability for webui < 1.5.0
from scripts.utils import load_file_from_url
config_clip_g = {
"attention_dropout": 0.0,
"dropout": 0.0,
"hidden_act": "gelu",
"hidden_size": 1664,
"image_size": 224,
"initializer_factor": 1.0,
"initializer_range": 0.02,
"intermediate_size": 8192,
"layer_norm_eps": 1e-05,
"model_type": "clip_vision_model",
"num_attention_heads": 16,
"num_channels": 3,
"num_hidden_layers": 48,
"patch_size": 14,
"projection_dim": 1280,
"torch_dtype": "float32"
}
config_clip_h = {
"attention_dropout": 0.0,
"dropout": 0.0,
"hidden_act": "gelu",
"hidden_size": 1280,
"image_size": 224,
"initializer_factor": 1.0,
"initializer_range": 0.02,
"intermediate_size": 5120,
"layer_norm_eps": 1e-05,
"model_type": "clip_vision_model",
"num_attention_heads": 16,
"num_channels": 3,
"num_hidden_layers": 32,
"patch_size": 14,
"projection_dim": 1024,
"torch_dtype": "float32"
}
config_clip_vitl = {
"attention_dropout": 0.0,
"dropout": 0.0,
"hidden_act": "quick_gelu",
"hidden_size": 1024,
"image_size": 224,
"initializer_factor": 1.0,
"initializer_range": 0.02,
"intermediate_size": 4096,
"layer_norm_eps": 1e-05,
"model_type": "clip_vision_model",
"num_attention_heads": 16,
"num_channels": 3,
"num_hidden_layers": 24,
"patch_size": 14,
"projection_dim": 768,
"torch_dtype": "float32"
}
configs = {
'clip_g': config_clip_g,
'clip_h': config_clip_h,
'clip_vitl': config_clip_vitl,
}
downloads = {
'clip_vitl': 'https://huggingface.co/openai/clip-vit-large-patch14/resolve/main/pytorch_model.bin',
'clip_g': 'https://huggingface.co/lllyasviel/Annotators/resolve/main/clip_g.pth',
'clip_h': 'https://huggingface.co/h94/IP-Adapter/resolve/main/models/image_encoder/pytorch_model.bin'
}
clip_vision_h_uc = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'clip_vision_h_uc.data')
clip_vision_h_uc = torch.load(clip_vision_h_uc, map_location=devices.get_device_for("controlnet") if torch.cuda.is_available() else torch.device('cpu'))['uc']
clip_vision_vith_uc = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'clip_vision_vith_uc.data')
clip_vision_vith_uc = torch.load(clip_vision_vith_uc, map_location=devices.get_device_for("controlnet") if torch.cuda.is_available() else torch.device('cpu'))['uc']
class ClipVisionDetector:
def __init__(self, config, low_vram: bool):
assert config in downloads
self.download_link = downloads[config]
self.model_path = os.path.join(models_path, 'clip_vision')
self.file_name = config + '.pth'
self.config = configs[config]
self.device = (
torch.device("cpu") if low_vram else
devices.get_device_for("controlnet")
)
os.makedirs(self.model_path, exist_ok=True)
file_path = os.path.join(self.model_path, self.file_name)
if not os.path.exists(file_path):
load_file_from_url(url=self.download_link, model_dir=self.model_path, file_name=self.file_name)
config = CLIPVisionConfig(**self.config)
self.model = CLIPVisionModelWithProjection(config)
self.processor = CLIPImageProcessor(crop_size=224,
do_center_crop=True,
do_convert_rgb=True,
do_normalize=True,
do_resize=True,
image_mean=[0.48145466, 0.4578275, 0.40821073],
image_std=[0.26862954, 0.26130258, 0.27577711],
resample=3,
size=224)
sd = torch.load(file_path, map_location=self.device)
self.model.load_state_dict(sd, strict=False)
del sd
self.model.to(self.device)
self.model.eval()
def unload_model(self):
if self.model is not None:
self.model.to('meta')
def __call__(self, input_image: np.ndarray):
assert isinstance(input_image, np.ndarray)
with torch.no_grad():
mask = None
input_image = cv2.resize(input_image, (224, 224), interpolation=cv2.INTER_AREA)
if input_image.shape[2] == 4: # Has alpha channel.
mask = 255 - input_image[:, :, 3:4] # Invert mask
input_image = input_image[:, :, :3]
feat = self.processor(images=input_image, return_tensors="pt")
feat['pixel_values'] = feat['pixel_values'].to(self.device)
# Apply CLIP mask.
if mask is not None:
mask_tensor = torch.from_numpy(mask).to(self.device).float() / 255.0
feat['pixel_values'] *= rearrange(mask_tensor, "h w c -> 1 c h w")
result = self.model(**feat, output_hidden_states=True)
result['hidden_states'] = [v.to(self.device) for v in result['hidden_states']]
result = {k: v.to(self.device) if isinstance(v, torch.Tensor) else v for k, v in result.items()}
return result
================================================
FILE: annotator/color/__init__.py
================================================
import cv2
def cv2_resize_shortest_edge(image, size):
h, w = image.shape[:2]
if h < w:
new_h = size
new_w = int(round(w / h * size))
else:
new_w = size
new_h = int(round(h / w * size))
resized_image = cv2.resize(image, (new_w, new_h), interpolation=cv2.INTER_AREA)
return resized_image
def apply_color(img, res=512):
img = cv2_resize_shortest_edge(img, res)
h, w = img.shape[:2]
input_img_color = cv2.resize(img, (w//64, h//64), interpolation=cv2.INTER_CUBIC)
input_img_color = cv2.resize(input_img_color, (w, h), interpolation=cv2.INTER_NEAREST)
return input_img_color
================================================
FILE: annotator/densepose/__init__.py
================================================
import torchvision # Fix issue Unknown builtin op: torchvision::nms
import cv2
import numpy as np
import torch
from einops import rearrange
from .densepose import DensePoseMaskedColormapResultsVisualizer, _extract_i_from_iuvarr, densepose_chart_predictor_output_to_result_with_confidences
from modules import devices
from annotator.annotator_path import models_path
import os
N_PART_LABELS = 24
result_visualizer = DensePoseMaskedColormapResultsVisualizer(
alpha=1,
data_extractor=_extract_i_from_iuvarr,
segm_extractor=_extract_i_from_iuvarr,
val_scale = 255.0 / N_PART_LABELS
)
remote_torchscript_path = "https://huggingface.co/LayerNorm/DensePose-TorchScript-with-hint-image/resolve/main/densepose_r50_fpn_dl.torchscript"
torchscript_model = None
model_dir = os.path.join(models_path, "densepose")
def apply_densepose(input_image, cmap="viridis"):
global torchscript_model
if torchscript_model is None:
model_path = os.path.join(model_dir, "densepose_r50_fpn_dl.torchscript")
if not os.path.exists(model_path):
from scripts.utils import load_file_from_url
load_file_from_url(remote_torchscript_path, model_dir=model_dir)
torchscript_model = torch.jit.load(model_path, map_location="cpu").to(devices.get_device_for("controlnet")).eval()
H, W = input_image.shape[:2]
hint_image_canvas = np.zeros([H, W], dtype=np.uint8)
hint_image_canvas = np.tile(hint_image_canvas[:, :, np.newaxis], [1, 1, 3])
input_image = rearrange(torch.from_numpy(input_image).to(devices.get_device_for("controlnet")), 'h w c -> c h w')
pred_boxes, corase_segm, fine_segm, u, v = torchscript_model(input_image)
extractor = densepose_chart_predictor_output_to_result_with_confidences
densepose_results = [extractor(pred_boxes[i:i+1], corase_segm[i:i+1], fine_segm[i:i+1], u[i:i+1], v[i:i+1]) for i in range(len(pred_boxes))]
if cmap=="viridis":
result_visualizer.mask_visualizer.cmap = cv2.COLORMAP_VIRIDIS
hint_image = result_visualizer.visualize(hint_image_canvas, densepose_results)
hint_image = cv2.cvtColor(hint_image, cv2.COLOR_BGR2RGB)
hint_image[:, :, 0][hint_image[:, :, 0] == 0] = 68
hint_image[:, :, 1][hint_image[:, :, 1] == 0] = 1
hint_image[:, :, 2][hint_image[:, :, 2] == 0] = 84
else:
result_visualizer.mask_visualizer.cmap = cv2.COLORMAP_PARULA
hint_image = result_visualizer.visualize(hint_image_canvas, densepose_results)
hint_image = cv2.cvtColor(hint_image, cv2.COLOR_BGR2RGB)
return hint_image
def unload_model():
global torchscript_model
if torchscript_model is not None:
torchscript_model.cpu()
================================================
FILE: annotator/densepose/densepose.py
================================================
from typing import Tuple
import math
import numpy as np
from enum import IntEnum
from typing import List, Tuple, Union
import torch
from torch.nn import functional as F
import logging
import cv2
Image = np.ndarray
Boxes = torch.Tensor
ImageSizeType = Tuple[int, int]
_RawBoxType = Union[List[float], Tuple[float, ...], torch.Tensor, np.ndarray]
IntTupleBox = Tuple[int, int, int, int]
class BoxMode(IntEnum):
"""
Enum of different ways to represent a box.
"""
XYXY_ABS = 0
"""
(x0, y0, x1, y1) in absolute floating points coordinates.
The coordinates in range [0, width or height].
"""
XYWH_ABS = 1
"""
(x0, y0, w, h) in absolute floating points coordinates.
"""
XYXY_REL = 2
"""
Not yet supported!
(x0, y0, x1, y1) in range [0, 1]. They are relative to the size of the image.
"""
XYWH_REL = 3
"""
Not yet supported!
(x0, y0, w, h) in range [0, 1]. They are relative to the size of the image.
"""
XYWHA_ABS = 4
"""
(xc, yc, w, h, a) in absolute floating points coordinates.
(xc, yc) is the center of the rotated box, and the angle a is in degrees ccw.
"""
@staticmethod
def convert(box: _RawBoxType, from_mode: "BoxMode", to_mode: "BoxMode") -> _RawBoxType:
"""
Args:
box: can be a k-tuple, k-list or an Nxk array/tensor, where k = 4 or 5
from_mode, to_mode (BoxMode)
Returns:
The converted box of the same type.
"""
if from_mode == to_mode:
return box
original_type = type(box)
is_numpy = isinstance(box, np.ndarray)
single_box = isinstance(box, (list, tuple))
if single_box:
assert len(box) == 4 or len(box) == 5, (
"BoxMode.convert takes either a k-tuple/list or an Nxk array/tensor,"
" where k == 4 or 5"
)
arr = torch.tensor(box)[None, :]
else:
# avoid modifying the input box
if is_numpy:
arr = torch.from_numpy(np.asarray(box)).clone()
else:
arr = box.clone()
assert to_mode not in [BoxMode.XYXY_REL, BoxMode.XYWH_REL] and from_mode not in [
BoxMode.XYXY_REL,
BoxMode.XYWH_REL,
], "Relative mode not yet supported!"
if from_mode == BoxMode.XYWHA_ABS and to_mode == BoxMode.XYXY_ABS:
assert (
arr.shape[-1] == 5
), "The last dimension of input shape must be 5 for XYWHA format"
original_dtype = arr.dtype
arr = arr.double()
w = arr[:, 2]
h = arr[:, 3]
a = arr[:, 4]
c = torch.abs(torch.cos(a * math.pi / 180.0))
s = torch.abs(torch.sin(a * math.pi / 180.0))
# This basically computes the horizontal bounding rectangle of the rotated box
new_w = c * w + s * h
new_h = c * h + s * w
# convert center to top-left corner
arr[:, 0] -= new_w / 2.0
arr[:, 1] -= new_h / 2.0
# bottom-right corner
arr[:, 2] = arr[:, 0] + new_w
arr[:, 3] = arr[:, 1] + new_h
arr = arr[:, :4].to(dtype=original_dtype)
elif from_mode == BoxMode.XYWH_ABS and to_mode == BoxMode.XYWHA_ABS:
original_dtype = arr.dtype
arr = arr.double()
arr[:, 0] += arr[:, 2] / 2.0
arr[:, 1] += arr[:, 3] / 2.0
angles = torch.zeros((arr.shape[0], 1), dtype=arr.dtype)
arr = torch.cat((arr, angles), axis=1).to(dtype=original_dtype)
else:
if to_mode == BoxMode.XYXY_ABS and from_mode == BoxMode.XYWH_ABS:
arr[:, 2] += arr[:, 0]
arr[:, 3] += arr[:, 1]
elif from_mode == BoxMode.XYXY_ABS and to_mode == BoxMode.XYWH_ABS:
arr[:, 2] -= arr[:, 0]
arr[:, 3] -= arr[:, 1]
else:
raise NotImplementedError(
"Conversion from BoxMode {} to {} is not supported yet".format(
from_mode, to_mode
)
)
if single_box:
return original_type(arr.flatten().tolist())
if is_numpy:
return arr.numpy()
else:
return arr
class MatrixVisualizer:
"""
Base visualizer for matrix data
"""
def __init__(
self,
inplace=True,
cmap=cv2.COLORMAP_PARULA,
val_scale=1.0,
alpha=0.7,
interp_method_matrix=cv2.INTER_LINEAR,
interp_method_mask=cv2.INTER_NEAREST,
):
self.inplace = inplace
self.cmap = cmap
self.val_scale = val_scale
self.alpha = alpha
self.interp_method_matrix = interp_method_matrix
self.interp_method_mask = interp_method_mask
def visualize(self, image_bgr, mask, matrix, bbox_xywh):
self._check_image(image_bgr)
self._check_mask_matrix(mask, matrix)
if self.inplace:
image_target_bgr = image_bgr
else:
image_target_bgr = image_bgr * 0
x, y, w, h = [int(v) for v in bbox_xywh]
if w <= 0 or h <= 0:
return image_bgr
mask, matrix = self._resize(mask, matrix, w, h)
mask_bg = np.tile((mask == 0)[:, :, np.newaxis], [1, 1, 3])
matrix_scaled = matrix.astype(np.float32) * self.val_scale
_EPSILON = 1e-6
if np.any(matrix_scaled > 255 + _EPSILON):
logger = logging.getLogger(__name__)
logger.warning(
f"Matrix has values > {255 + _EPSILON} after " f"scaling, clipping to [0..255]"
)
matrix_scaled_8u = matrix_scaled.clip(0, 255).astype(np.uint8)
matrix_vis = cv2.applyColorMap(matrix_scaled_8u, self.cmap)
matrix_vis[mask_bg] = image_target_bgr[y : y + h, x : x + w, :][mask_bg]
image_target_bgr[y : y + h, x : x + w, :] = (
image_target_bgr[y : y + h, x : x + w, :] * (1.0 - self.alpha) + matrix_vis * self.alpha
)
return image_target_bgr.astype(np.uint8)
def _resize(self, mask, matrix, w, h):
if (w != mask.shape[1]) or (h != mask.shape[0]):
mask = cv2.resize(mask, (w, h), self.interp_method_mask)
if (w != matrix.shape[1]) or (h != matrix.shape[0]):
matrix = cv2.resize(matrix, (w, h), self.interp_method_matrix)
return mask, matrix
def _check_image(self, image_rgb):
assert len(image_rgb.shape) == 3
assert image_rgb.shape[2] == 3
assert image_rgb.dtype == np.uint8
def _check_mask_matrix(self, mask, matrix):
assert len(matrix.shape) == 2
assert len(mask.shape) == 2
assert mask.dtype == np.uint8
class DensePoseResultsVisualizer:
def visualize(
self,
image_bgr: Image,
results,
) -> Image:
context = self.create_visualization_context(image_bgr)
for i, result in enumerate(results):
boxes_xywh, labels, uv = result
iuv_array = torch.cat(
(labels[None].type(torch.float32), uv * 255.0)
).type(torch.uint8)
self.visualize_iuv_arr(context, iuv_array.cpu().numpy(), boxes_xywh)
image_bgr = self.context_to_image_bgr(context)
return image_bgr
def create_visualization_context(self, image_bgr: Image):
return image_bgr
def visualize_iuv_arr(self, context, iuv_arr: np.ndarray, bbox_xywh) -> None:
pass
def context_to_image_bgr(self, context):
return context
def get_image_bgr_from_context(self, context):
return context
class DensePoseMaskedColormapResultsVisualizer(DensePoseResultsVisualizer):
def __init__(
self,
data_extractor,
segm_extractor,
inplace=True,
cmap=cv2.COLORMAP_PARULA,
alpha=0.7,
val_scale=1.0,
**kwargs,
):
self.mask_visualizer = MatrixVisualizer(
inplace=inplace, cmap=cmap, val_scale=val_scale, alpha=alpha
)
self.data_extractor = data_extractor
self.segm_extractor = segm_extractor
def context_to_image_bgr(self, context):
return context
def visualize_iuv_arr(self, context, iuv_arr: np.ndarray, bbox_xywh) -> None:
image_bgr = self.get_image_bgr_from_context(context)
matrix = self.data_extractor(iuv_arr)
segm = self.segm_extractor(iuv_arr)
mask = np.zeros(matrix.shape, dtype=np.uint8)
mask[segm > 0] = 1
image_bgr = self.mask_visualizer.visualize(image_bgr, mask, matrix, bbox_xywh)
def _extract_i_from_iuvarr(iuv_arr):
return iuv_arr[0, :, :]
def _extract_u_from_iuvarr(iuv_arr):
return iuv_arr[1, :, :]
def _extract_v_from_iuvarr(iuv_arr):
return iuv_arr[2, :, :]
def make_int_box(box: torch.Tensor) -> IntTupleBox:
int_box = [0, 0, 0, 0]
int_box[0], int_box[1], int_box[2], int_box[3] = tuple(box.long().tolist())
return int_box[0], int_box[1], int_box[2], int_box[3]
def densepose_chart_predictor_output_to_result_with_confidences(
boxes: Boxes,
coarse_segm,
fine_segm,
u, v
):
boxes_xyxy_abs = boxes.clone()
boxes_xywh_abs = BoxMode.convert(boxes_xyxy_abs, BoxMode.XYXY_ABS, BoxMode.XYWH_ABS)
box_xywh = make_int_box(boxes_xywh_abs[0])
labels = resample_fine_and_coarse_segm_tensors_to_bbox(fine_segm, coarse_segm, box_xywh).squeeze(0)
uv = resample_uv_tensors_to_bbox(u, v, labels, box_xywh)
confidences = []
return box_xywh, labels, uv
def resample_fine_and_coarse_segm_tensors_to_bbox(
fine_segm: torch.Tensor, coarse_segm: torch.Tensor, box_xywh_abs: IntTupleBox
):
"""
Resample fine and coarse segmentation tensors to the given
bounding box and derive labels for each pixel of the bounding box
Args:
fine_segm: float tensor of shape [1, C, Hout, Wout]
coarse_segm: float tensor of shape [1, K, Hout, Wout]
box_xywh_abs (tuple of 4 int): bounding box given by its upper-left
corner coordinates, width (W) and height (H)
Return:
Labels for each pixel of the bounding box, a long tensor of size [1, H, W]
"""
x, y, w, h = box_xywh_abs
w = max(int(w), 1)
h = max(int(h), 1)
# coarse segmentation
coarse_segm_bbox = F.interpolate(
coarse_segm,
(h, w),
mode="bilinear",
align_corners=False,
).argmax(dim=1)
# combined coarse and fine segmentation
labels = (
F.interpolate(fine_segm, (h, w), mode="bilinear", align_corners=False).argmax(dim=1)
* (coarse_segm_bbox > 0).long()
)
return labels
def resample_uv_tensors_to_bbox(
u: torch.Tensor,
v: torch.Tensor,
labels: torch.Tensor,
box_xywh_abs: IntTupleBox,
) -> torch.Tensor:
"""
Resamples U and V coordinate estimates for the given bounding box
Args:
u (tensor [1, C, H, W] of float): U coordinates
v (tensor [1, C, H, W] of float): V coordinates
labels (tensor [H, W] of long): labels obtained by resampling segmentation
outputs for the given bounding box
box_xywh_abs (tuple of 4 int): bounding box that corresponds to predictor outputs
Return:
Resampled U and V coordinates - a tensor [2, H, W] of float
"""
x, y, w, h = box_xywh_abs
w = max(int(w), 1)
h = max(int(h), 1)
u_bbox = F.interpolate(u, (h, w), mode="bilinear", align_corners=False)
v_bbox = F.interpolate(v, (h, w), mode="bilinear", align_corners=False)
uv = torch.zeros([2, h, w], dtype=torch.float32, device=u.device)
for part_id in range(1, u_bbox.size(1)):
uv[0][labels == part_id] = u_bbox[0, part_id][labels == part_id]
uv[1][labels == part_id] = v_bbox[0, part_id][labels == part_id]
return uv
================================================
FILE: annotator/depth_anything.py
================================================
import os
import torch
import cv2
import numpy as np
import torch.nn.functional as F
from torchvision.transforms import Compose
from depth_anything.dpt import DPT_DINOv2
from depth_anything.util.transform import Resize, NormalizeImage, PrepareForNet
from .util import load_model
from .annotator_path import models_path
transform = Compose(
[
Resize(
width=518,
height=518,
resize_target=False,
keep_aspect_ratio=True,
ensure_multiple_of=14,
resize_method="lower_bound",
image_interpolation_method=cv2.INTER_CUBIC,
),
NormalizeImage(mean=[0.485, 0.456, 0.406], std=[0.229, 0.224, 0.225]),
PrepareForNet(),
]
)
class DepthAnythingDetector:
"""https://github.com/LiheYoung/Depth-Anything"""
model_dir = os.path.join(models_path, "depth_anything")
def __init__(self, device: torch.device):
self.device = device
self.model = (
DPT_DINOv2(
encoder="vitl",
features=256,
out_channels=[256, 512, 1024, 1024],
localhub=False,
)
.to(device)
.eval()
)
remote_url = os.environ.get(
"CONTROLNET_DEPTH_ANYTHING_MODEL_URL",
"https://huggingface.co/spaces/LiheYoung/Depth-Anything/resolve/main/checkpoints/depth_anything_vitl14.pth",
)
model_path = load_model(
"depth_anything_vitl14.pth", remote_url=remote_url, model_dir=self.model_dir
)
self.model.load_state_dict(torch.load(model_path))
def __call__(self, image: np.ndarray, colored: bool = True) -> np.ndarray:
self.model.to(self.device)
h, w = image.shape[:2]
image = cv2.cvtColor(image, cv2.COLOR_BGR2RGB) / 255.0
image = transform({"image": image})["image"]
image = torch.from_numpy(image).unsqueeze(0).to(self.device)
@torch.no_grad()
def predict_depth(model, image):
return model(image)
depth = predict_depth(self.model, image)
depth = F.interpolate(
depth[None], (h, w), mode="bilinear", align_corners=False
)[0, 0]
depth = (depth - depth.min()) / (depth.max() - depth.min()) * 255.0
depth = depth.cpu().numpy().astype(np.uint8)
if colored:
return cv2.applyColorMap(depth, cv2.COLORMAP_INFERNO)[:, :, ::-1]
else:
return depth
def unload_model(self):
self.model.to("cpu")
================================================
FILE: annotator/depth_anything_v2.py
================================================
import os
import torch
import cv2
import numpy as np
import torch.nn.functional as F
from torchvision.transforms import Compose
from safetensors.torch import load_file
from depth_anything_v2.dpt import DepthAnythingV2
from depth_anything_v2.util.transform import Resize, NormalizeImage, PrepareForNet
from .util import load_model
from .annotator_path import models_path
transform = Compose(
[
Resize(
width=518,
height=518,
resize_target=False,
keep_aspect_ratio=True,
ensure_multiple_of=14,
resize_method="lower_bound",
image_interpolation_method=cv2.INTER_CUBIC,
),
NormalizeImage(mean=[0.485, 0.456, 0.406], std=[0.229, 0.224, 0.225]),
PrepareForNet(),
]
)
class DepthAnythingV2Detector:
"""https://github.com/MackinationsAi/Upgraded-Depth-Anything-V2"""
model_dir = os.path.join(models_path, "depth_anything_v2")
def __init__(self, device: torch.device):
self.device = device
self.model = (
DepthAnythingV2(
encoder="vitl",
features=256,
out_channels=[256, 512, 1024, 1024],
)
.to(device)
.eval()
)
remote_url = os.environ.get(
"CONTROLNET_DEPTH_ANYTHING_V2_MODEL_URL",
"https://huggingface.co/MackinationsAi/Depth-Anything-V2_Safetensors/resolve/main/depth_anything_v2_vitl.safetensors",
)
model_path = load_model(
"depth_anything_v2_vitl.safetensors", remote_url=remote_url, model_dir=self.model_dir
)
self.model.load_state_dict(load_file(model_path))
def __call__(self, image: np.ndarray, colored: bool = True) -> np.ndarray:
self.model.to(self.device)
h, w = image.shape[:2]
image = cv2.cvtColor(image, cv2.COLOR_BGR2RGB) / 255.0
image = transform({"image": image})["image"]
image = torch.from_numpy(image).unsqueeze(0).to(self.device)
@torch.no_grad()
def predict_depth(model, image):
return model(image)
depth = predict_depth(self.model, image)
depth = F.interpolate(
depth[None], (h, w), mode="bilinear", align_corners=False
)[0, 0]
depth = (depth - depth.min()) / (depth.max() - depth.min()) * 255.0
depth = depth.cpu().numpy().astype(np.uint8)
if colored:
depth_color = cv2.applyColorMap(depth, cv2.COLORMAP_INFERNO)[:, :, ::-1]
return depth_color
else:
return depth
def unload_model(self):
self.model.to("cpu")
================================================
FILE: annotator/hed/__init__.py
================================================
# This is an improved version and model of HED edge detection with Apache License, Version 2.0.
# Please use this implementation in your products
# This implementation may produce slightly different results from Saining Xie's official implementations,
# but it generates smoother edges and is more suitable for ControlNet as well as other image-to-image translations.
# Different from official models and other implementations, this is an RGB-input model (rather than BGR)
# and in this way it works better for gradio's RGB protocol
import os
import cv2
import torch
import numpy as np
from einops import rearrange
import os
from modules import devices
from annotator.annotator_path import models_path
from annotator.util import safe_step, nms
class DoubleConvBlock(torch.nn.Module):
def __init__(self, input_channel, output_channel, layer_number):
super().__init__()
self.convs = torch.nn.Sequential()
self.convs.append(torch.nn.Conv2d(in_channels=input_channel, out_channels=output_channel, kernel_size=(3, 3), stride=(1, 1), padding=1))
for i in range(1, layer_number):
self.convs.append(torch.nn.Conv2d(in_channels=output_channel, out_channels=output_channel, kernel_size=(3, 3), stride=(1, 1), padding=1))
self.projection = torch.nn.Conv2d(in_channels=output_channel, out_channels=1, kernel_size=(1, 1), stride=(1, 1), padding=0)
def __call__(self, x, down_sampling=False):
h = x
if down_sampling:
h = torch.nn.functional.max_pool2d(h, kernel_size=(2, 2), stride=(2, 2))
for conv in self.convs:
h = conv(h)
h = torch.nn.functional.relu(h)
return h, self.projection(h)
class ControlNetHED_Apache2(torch.nn.Module):
def __init__(self):
super().__init__()
self.norm = torch.nn.Parameter(torch.zeros(size=(1, 3, 1, 1)))
self.block1 = DoubleConvBlock(input_channel=3, output_channel=64, layer_number=2)
self.block2 = DoubleConvBlock(input_channel=64, output_channel=128, layer_number=2)
self.block3 = DoubleConvBlock(input_channel=128, output_channel=256, layer_number=3)
self.block4 = DoubleConvBlock(input_channel=256, output_channel=512, layer_number=3)
self.block5 = DoubleConvBlock(input_channel=512, output_channel=512, layer_number=3)
def __call__(self, x):
h = x - self.norm
h, projection1 = self.block1(h)
h, projection2 = self.block2(h, down_sampling=True)
h, projection3 = self.block3(h, down_sampling=True)
h, projection4 = self.block4(h, down_sampling=True)
h, projection5 = self.block5(h, down_sampling=True)
return projection1, projection2, projection3, projection4, projection5
netNetwork = None
remote_model_path = "https://huggingface.co/lllyasviel/Annotators/resolve/main/ControlNetHED.pth"
modeldir = os.path.join(models_path, "hed")
old_modeldir = os.path.dirname(os.path.realpath(__file__))
def apply_hed(input_image, is_safe=False):
global netNetwork
if netNetwork is None:
modelpath = os.path.join(modeldir, "ControlNetHED.pth")
old_modelpath = os.path.join(old_modeldir, "ControlNetHED.pth")
if os.path.exists(old_modelpath):
modelpath = old_modelpath
elif not os.path.exists(modelpath):
from scripts.utils import load_file_from_url
load_file_from_url(remote_model_path, model_dir=modeldir)
netNetwork = ControlNetHED_Apache2().to(devices.get_device_for("controlnet"))
netNetwork.load_state_dict(torch.load(modelpath, map_location='cpu'))
netNetwork.to(devices.get_device_for("controlnet")).float().eval()
assert input_image.ndim == 3
H, W, C = input_image.shape
with torch.no_grad():
image_hed = torch.from_numpy(input_image.copy()).float().to(devices.get_device_for("controlnet"))
image_hed = rearrange(image_hed, 'h w c -> 1 c h w')
edges = netNetwork(image_hed)
edges = [e.detach().cpu().numpy().astype(np.float32)[0, 0] for e in edges]
edges = [cv2.resize(e, (W, H), interpolation=cv2.INTER_LINEAR) for e in edges]
edges = np.stack(edges, axis=2)
edge = 1 / (1 + np.exp(-np.mean(edges, axis=2).astype(np.float64)))
if is_safe:
edge = safe_step(edge)
edge = (edge * 255.0).clip(0, 255).astype(np.uint8)
return edge
def unload_hed_model():
global netNetwork
if netNetwork is not None:
netNetwork.cpu()
================================================
FILE: annotator/keypose/__init__.py
================================================
import numpy as np
import cv2
import torch
import os
from modules import devices
from annotator.annotator_path import models_path
import mmcv
from mmdet.apis import inference_detector, init_detector
from mmpose.apis import inference_top_down_pose_model
from mmpose.apis import init_pose_model, process_mmdet_results, vis_pose_result
def preprocessing(image, device):
# Resize
scale = 640 / max(image.shape[:2])
image = cv2.resize(image, dsize=None, fx=scale, fy=scale)
raw_image = image.astype(np.uint8)
# Subtract mean values
image = image.astype(np.float32)
image -= np.array(
[
float(104.008),
float(116.669),
float(122.675),
]
)
# Convert to torch.Tensor and add "batch" axis
image = torch.from_numpy(image.transpose(2, 0, 1)).float().unsqueeze(0)
image = image.to(device)
return image, raw_image
def imshow_keypoints(img,
pose_result,
skeleton=None,
kpt_score_thr=0.1,
pose_kpt_color=None,
pose_link_color=None,
radius=4,
thickness=1):
"""Draw keypoints and links on an image.
Args:
img (ndarry): The image to draw poses on.
pose_result (list[kpts]): The poses to draw. Each element kpts is
a set of K keypoints as an Kx3 numpy.ndarray, where each
keypoint is represented as x, y, score.
kpt_score_thr (float, optional): Minimum score of keypoints
to be shown. Default: 0.3.
pose_kpt_color (np.array[Nx3]`): Color of N keypoints. If None,
the keypoint will not be drawn.
pose_link_color (np.array[Mx3]): Color of M links. If None, the
links will not be drawn.
thickness (int): Thickness of lines.
"""
img_h, img_w, _ = img.shape
img = np.zeros(img.shape)
for idx, kpts in enumerate(pose_result):
if idx > 1:
continue
kpts = kpts['keypoints']
# print(kpts)
kpts = np.array(kpts, copy=False)
# draw each point on image
if pose_kpt_color is not None:
assert len(pose_kpt_color) == len(kpts)
for kid, kpt in enumerate(kpts):
x_coord, y_coord, kpt_score = int(kpt[0]), int(kpt[1]), kpt[2]
if kpt_score < kpt_score_thr or pose_kpt_color[kid] is None:
# skip the point that should not be drawn
continue
color = tuple(int(c) for c in pose_kpt_color[kid])
cv2.circle(img, (int(x_coord), int(y_coord)),
radius, color, -1)
# draw links
if skeleton is not None and pose_link_color is not None:
assert len(pose_link_color) == len(skeleton)
for sk_id, sk in enumerate(skeleton):
pos1 = (int(kpts[sk[0], 0]), int(kpts[sk[0], 1]))
pos2 = (int(kpts[sk[1], 0]), int(kpts[sk[1], 1]))
if (pos1[0] <= 0 or pos1[0] >= img_w or pos1[1] <= 0 or pos1[1] >= img_h or pos2[0] <= 0
or pos2[0] >= img_w or pos2[1] <= 0 or pos2[1] >= img_h or kpts[sk[0], 2] < kpt_score_thr
or kpts[sk[1], 2] < kpt_score_thr or pose_link_color[sk_id] is None):
# skip the link that should not be drawn
continue
color = tuple(int(c) for c in pose_link_color[sk_id])
cv2.line(img, pos1, pos2, color, thickness=thickness)
return img
human_det, pose_model = None, None
det_model_path = "https://download.openmmlab.com/mmdetection/v2.0/faster_rcnn/faster_rcnn_r50_fpn_1x_coco/faster_rcnn_r50_fpn_1x_coco_20200130-047c8118.pth"
pose_model_path = "https://download.openmmlab.com/mmpose/top_down/hrnet/hrnet_w48_coco_256x192-b9e0b3ab_20200708.pth"
modeldir = os.path.join(models_path, "keypose")
old_modeldir = os.path.dirname(os.path.realpath(__file__))
det_config = 'faster_rcnn_r50_fpn_coco.py'
pose_config = 'hrnet_w48_coco_256x192.py'
det_checkpoint = 'faster_rcnn_r50_fpn_1x_coco_20200130-047c8118.pth'
pose_checkpoint = 'hrnet_w48_coco_256x192-b9e0b3ab_20200708.pth'
det_cat_id = 1
bbox_thr = 0.2
skeleton = [
[15, 13], [13, 11], [16, 14], [14, 12], [11, 12], [5, 11], [6, 12], [5, 6], [5, 7], [6, 8],
[7, 9], [8, 10],
[1, 2], [0, 1], [0, 2], [1, 3], [2, 4], [3, 5], [4, 6]
]
pose_kpt_color = [
[51, 153, 255], [51, 153, 255], [51, 153, 255], [51, 153, 255], [51, 153, 255],
[0, 255, 0],
[255, 128, 0], [0, 255, 0], [255, 128, 0], [0, 255, 0], [255, 128, 0], [0, 255, 0],
[255, 128, 0],
[0, 255, 0], [255, 128, 0], [0, 255, 0], [255, 128, 0]
]
pose_link_color = [
[0, 255, 0], [0, 255, 0], [255, 128, 0], [255, 128, 0],
[51, 153, 255], [51, 153, 255], [51, 153, 255], [51, 153, 255], [0, 255, 0],
[255, 128, 0],
[0, 255, 0], [255, 128, 0], [51, 153, 255], [51, 153, 255], [51, 153, 255],
[51, 153, 255],
[51, 153, 255], [51, 153, 255], [51, 153, 255]
]
def find_download_model(checkpoint, remote_path):
modelpath = os.path.join(modeldir, checkpoint)
old_modelpath = os.path.join(old_modeldir, checkpoint)
if os.path.exists(old_modelpath):
modelpath = old_modelpath
elif not os.path.exists(modelpath):
from scripts.utils import load_file_from_url
load_file_from_url(remote_path, model_dir=modeldir)
return modelpath
def apply_keypose(input_image):
global human_det, pose_model
if netNetwork is None:
det_model_local = find_download_model(det_checkpoint, det_model_path)
hrnet_model_local = find_download_model(pose_checkpoint, pose_model_path)
det_config_mmcv = mmcv.Config.fromfile(det_config)
pose_config_mmcv = mmcv.Config.fromfile(pose_config)
human_det = init_detector(det_config_mmcv, det_model_local, device=devices.get_device_for("controlnet"))
pose_model = init_pose_model(pose_config_mmcv, hrnet_model_local, device=devices.get_device_for("controlnet"))
assert input_image.ndim == 3
input_image = input_image.copy()
with torch.no_grad():
image = torch.from_numpy(input_image).float().to(devices.get_device_for("controlnet"))
image = image / 255.0
mmdet_results = inference_detector(human_det, image)
# keep the person class bounding boxes.
person_results = process_mmdet_results(mmdet_results, det_cat_id)
return_heatmap = False
dataset = pose_model.cfg.data['test']['type']
# e.g. use ('backbone', ) to return backbone feature
output_layer_names = None
pose_results, _ = inference_top_down_pose_model(
pose_model,
image,
person_results,
bbox_thr=bbox_thr,
format='xyxy',
dataset=dataset,
dataset_info=None,
return_heatmap=return_heatmap,
outputs=output_layer_names
)
im_keypose_out = imshow_keypoints(
image,
pose_results,
skeleton=skeleton,
pose_kpt_color=pose_kpt_color,
pose_link_color=pose_link_color,
radius=2,
thickness=2
)
im_keypose_out = im_keypose_out.astype(np.uint8)
# image_hed = rearrange(image_hed, 'h w c -> 1 c h w')
# edge = netNetwork(image_hed)[0]
# edge = (edge.cpu().numpy() * 255.0).clip(0, 255).astype(np.uint8)
return im_keypose_out
def unload_hed_model():
global netNetwork
if netNetwork is not None:
netNetwork.cpu()
================================================
FILE: annotator/keypose/faster_rcnn_r50_fpn_coco.py
================================================
checkpoint_config = dict(interval=1)
# yapf:disable
log_config = dict(
interval=50,
hooks=[
dict(type='TextLoggerHook'),
# dict(type='TensorboardLoggerHook')
])
# yapf:enable
dist_params = dict(backend='nccl')
log_level = 'INFO'
load_from = None
resume_from = None
workflow = [('train', 1)]
# optimizer
optimizer = dict(type='SGD', lr=0.02, momentum=0.9, weight_decay=0.0001)
optimizer_config = dict(grad_clip=None)
# learning policy
lr_config = dict(
policy='step',
warmup='linear',
warmup_iters=500,
warmup_ratio=0.001,
step=[8, 11])
total_epochs = 12
model = dict(
type='FasterRCNN',
pretrained='torchvision://resnet50',
backbone=dict(
type='ResNet',
depth=50,
num_stages=4,
out_indices=(0, 1, 2, 3),
frozen_stages=1,
norm_cfg=dict(type='BN', requires_grad=True),
norm_eval=True,
style='pytorch'),
neck=dict(
type='FPN',
in_channels=[256, 512, 1024, 2048],
out_channels=256,
num_outs=5),
rpn_head=dict(
type='RPNHead',
in_channels=256,
feat_channels=256,
anchor_generator=dict(
type='AnchorGenerator',
scales=[8],
ratios=[0.5, 1.0, 2.0],
strides=[4, 8, 16, 32, 64]),
bbox_coder=dict(
type='DeltaXYWHBBoxCoder',
target_means=[.0, .0, .0, .0],
target_stds=[1.0, 1.0, 1.0, 1.0]),
loss_cls=dict(
type='CrossEntropyLoss', use_sigmoid=True, loss_weight=1.0),
loss_bbox=dict(type='L1Loss', loss_weight=1.0)),
roi_head=dict(
type='StandardRoIHead',
bbox_roi_extractor=dict(
type='SingleRoIExtractor',
roi_layer=dict(type='RoIAlign', output_size=7, sampling_ratio=0),
out_channels=256,
featmap_strides=[4, 8, 16, 32]),
bbox_head=dict(
type='Shared2FCBBoxHead',
in_channels=256,
fc_out_channels=1024,
roi_feat_size=7,
num_classes=80,
bbox_coder=dict(
type='DeltaXYWHBBoxCoder',
target_means=[0., 0., 0., 0.],
target_stds=[0.1, 0.1, 0.2, 0.2]),
reg_class_agnostic=False,
loss_cls=dict(
type='CrossEntropyLoss', use_sigmoid=False, loss_weight=1.0),
loss_bbox=dict(type='L1Loss', loss_weight=1.0))),
# model training and testing settings
train_cfg=dict(
rpn=dict(
assigner=dict(
type='MaxIoUAssigner',
pos_iou_thr=0.7,
neg_iou_thr=0.3,
min_pos_iou=0.3,
match_low_quality=True,
ignore_iof_thr=-1),
sampler=dict(
type='RandomSampler',
num=256,
pos_fraction=0.5,
neg_pos_ub=-1,
add_gt_as_proposals=False),
allowed_border=-1,
pos_weight=-1,
debug=False),
rpn_proposal=dict(
nms_pre=2000,
max_per_img=1000,
nms=dict(type='nms', iou_threshold=0.7),
min_bbox_size=0),
rcnn=dict(
assigner=dict(
type='MaxIoUAssigner',
pos_iou_thr=0.5,
neg_iou_thr=0.5,
min_pos_iou=0.5,
match_low_quality=False,
ignore_iof_thr=-1),
sampler=dict(
type='RandomSampler',
num=512,
pos_fraction=0.25,
neg_pos_ub=-1,
add_gt_as_proposals=True),
pos_weight=-1,
debug=False)),
test_cfg=dict(
rpn=dict(
nms_pre=1000,
max_per_img=1000,
nms=dict(type='nms', iou_threshold=0.7),
min_bbox_size=0),
rcnn=dict(
score_thr=0.05,
nms=dict(type='nms', iou_threshold=0.5),
max_per_img=100)
# soft-nms is also supported for rcnn testing
# e.g., nms=dict(type='soft_nms', iou_threshold=0.5, min_score=0.05)
))
dataset_type = 'CocoDataset'
data_root = 'data/coco'
img_norm_cfg = dict(
mean=[123.675, 116.28, 103.53], std=[58.395, 57.12, 57.375], to_rgb=True)
train_pipeline = [
dict(type='LoadImageFromFile'),
dict(type='LoadAnnotations', with_bbox=True),
dict(type='Resize', img_scale=(1333, 800), keep_ratio=True),
dict(type='RandomFlip', flip_ratio=0.5),
dict(type='Normalize', **img_norm_cfg),
dict(type='Pad', size_divisor=32),
dict(type='DefaultFormatBundle'),
dict(type='Collect', keys=['img', 'gt_bboxes', 'gt_labels']),
]
test_pipeline = [
dict(type='LoadImageFromFile'),
dict(
type='MultiScaleFlipAug',
img_scale=(1333, 800),
flip=False,
transforms=[
dict(type='Resize', keep_ratio=True),
dict(type='RandomFlip'),
dict(type='Normalize', **img_norm_cfg),
dict(type='Pad', size_divisor=32),
dict(type='DefaultFormatBundle'),
dict(type='Collect', keys=['img']),
])
]
data = dict(
samples_per_gpu=2,
workers_per_gpu=2,
train=dict(
type=dataset_type,
ann_file=f'{data_root}/annotations/instances_train2017.json',
img_prefix=f'{data_root}/train2017/',
pipeline=train_pipeline),
val=dict(
type=dataset_type,
ann_file=f'{data_root}/annotations/instances_val2017.json',
img_prefix=f'{data_root}/val2017/',
pipeline=test_pipeline),
test=dict(
type=dataset_type,
ann_file=f'{data_root}/annotations/instances_val2017.json',
img_prefix=f'{data_root}/val2017/',
pipeline=test_pipeline))
evaluation = dict(interval=1, metric='bbox')
================================================
FILE: annotator/keypose/hrnet_w48_coco_256x192.py
================================================
# _base_ = [
# '../../../../_base_/default_runtime.py',
# '../../../../_base_/datasets/coco.py'
# ]
evaluation = dict(interval=10, metric='mAP', save_best='AP')
optimizer = dict(
type='Adam',
lr=5e-4,
)
optimizer_config = dict(grad_clip=None)
# learning policy
lr_config = dict(
policy='step',
warmup='linear',
warmup_iters=500,
warmup_ratio=0.001,
step=[170, 200])
total_epochs = 210
channel_cfg = dict(
num_output_channels=17,
dataset_joints=17,
dataset_channel=[
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16],
],
inference_channel=[
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16
])
# model settings
model = dict(
type='TopDown',
pretrained='https://download.openmmlab.com/mmpose/'
'pretrain_models/hrnet_w48-8ef0771d.pth',
backbone=dict(
type='HRNet',
in_channels=3,
extra=dict(
stage1=dict(
num_modules=1,
num_branches=1,
block='BOTTLENECK',
num_blocks=(4, ),
num_channels=(64, )),
stage2=dict(
num_modules=1,
num_branches=2,
block='BASIC',
num_blocks=(4, 4),
num_channels=(48, 96)),
stage3=dict(
num_modules=4,
num_branches=3,
block='BASIC',
num_blocks=(4, 4, 4),
num_channels=(48, 96, 192)),
stage4=dict(
num_modules=3,
num_branches=4,
block='BASIC',
num_blocks=(4, 4, 4, 4),
num_channels=(48, 96, 192, 384))),
),
keypoint_head=dict(
type='TopdownHeatmapSimpleHead',
in_channels=48,
out_channels=channel_cfg['num_output_channels'],
num_deconv_layers=0,
extra=dict(final_conv_kernel=1, ),
loss_keypoint=dict(type='JointsMSELoss', use_target_weight=True)),
train_cfg=dict(),
test_cfg=dict(
flip_test=True,
post_process='default',
shift_heatmap=True,
modulate_kernel=11))
data_cfg = dict(
image_size=[192, 256],
heatmap_size=[48, 64],
num_output_channels=channel_cfg['num_output_channels'],
num_joints=channel_cfg['dataset_joints'],
dataset_channel=channel_cfg['dataset_channel'],
inference_channel=channel_cfg['inference_channel'],
soft_nms=False,
nms_thr=1.0,
oks_thr=0.9,
vis_thr=0.2,
use_gt_bbox=False,
det_bbox_thr=0.0,
bbox_file='data/coco/person_detection_results/'
'COCO_val2017_detections_AP_H_56_person.json',
)
train_pipeline = [
dict(type='LoadImageFromFile'),
dict(type='TopDownGetBboxCenterScale', padding=1.25),
dict(type='TopDownRandomShiftBboxCenter', shift_factor=0.16, prob=0.3),
dict(type='TopDownRandomFlip', flip_prob=0.5),
dict(
type='TopDownHalfBodyTransform',
num_joints_half_body=8,
prob_half_body=0.3),
dict(
type='TopDownGetRandomScaleRotation', rot_factor=40, scale_factor=0.5),
dict(type='TopDownAffine'),
dict(type='ToTensor'),
dict(
type='NormalizeTensor',
mean=[0.485, 0.456, 0.406],
std=[0.229, 0.224, 0.225]),
dict(type='TopDownGenerateTarget', sigma=2),
dict(
type='Collect',
keys=['img', 'target', 'target_weight'],
meta_keys=[
'image_file', 'joints_3d', 'joints_3d_visible', 'center', 'scale',
'rotation', 'bbox_score', 'flip_pairs'
]),
]
val_pipeline = [
dict(type='LoadImageFromFile'),
dict(type='TopDownGetBboxCenterScale', padding=1.25),
dict(type='TopDownAffine'),
dict(type='ToTensor'),
dict(
type='NormalizeTensor',
mean=[0.485, 0.456, 0.406],
std=[0.229, 0.224, 0.225]),
dict(
type='Collect',
keys=['img'],
meta_keys=[
'image_file', 'center', 'scale', 'rotation', 'bbox_score',
'flip_pairs'
]),
]
test_pipeline = val_pipeline
data_root = 'data/coco'
data = dict(
samples_per_gpu=32,
workers_per_gpu=2,
val_dataloader=dict(samples_per_gpu=32),
test_dataloader=dict(samples_per_gpu=32),
train=dict(
type='TopDownCocoDataset',
ann_file=f'{data_root}/annotations/person_keypoints_train2017.json',
img_prefix=f'{data_root}/train2017/',
data_cfg=data_cfg,
pipeline=train_pipeline,
dataset_info={{_base_.dataset_info}}),
val=dict(
type='TopDownCocoDataset',
ann_file=f'{data_root}/annotations/person_keypoints_val2017.json',
img_prefix=f'{data_root}/val2017/',
data_cfg=data_cfg,
pipeline=val_pipeline,
dataset_info={{_base_.dataset_info}}),
test=dict(
type='TopDownCocoDataset',
ann_file=f'{data_root}/annotations/person_keypoints_val2017.json',
img_prefix=f'{data_root}/val2017/',
data_cfg=data_cfg,
pipeline=test_pipeline,
dataset_info={{_base_.dataset_info}}),
)
================================================
FILE: annotator/lama/__init__.py
================================================
# https://github.com/advimman/lama
import yaml
import torch
from omegaconf import OmegaConf
import numpy as np
from einops import rearrange
import os
from modules import devices
from annotator.annotator_path import models_path
from annotator.lama.saicinpainting.training.trainers import load_checkpoint
class LamaInpainting:
model_dir = os.path.join(models_path, "lama")
def __init__(self):
self.model = None
self.device = devices.get_device_for("controlnet")
def load_model(self):
remote_model_path = "https://huggingface.co/lllyasviel/Annotators/resolve/main/ControlNetLama.pth"
modelpath = os.path.join(self.model_dir, "ControlNetLama.pth")
if not os.path.exists(modelpath):
from scripts.utils import load_file_from_url
load_file_from_url(remote_model_path, model_dir=self.model_dir)
config_path = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'config.yaml')
cfg = yaml.safe_load(open(config_path, 'rt'))
cfg = OmegaConf.create(cfg)
cfg.training_model.predict_only = True
cfg.visualizer.kind = 'noop'
self.model = load_checkpoint(cfg, os.path.abspath(modelpath), strict=False, map_location='cpu')
self.model = self.model.to(self.device)
self.model.eval()
def unload_model(self):
if self.model is not None:
self.model.cpu()
def __call__(self, input_image):
if self.model is None:
self.load_model()
self.model.to(self.device)
color = np.ascontiguousarray(input_image[:, :, 0:3]).astype(np.float32) / 255.0
mask = np.ascontiguousarray(input_image[:, :, 3:4]).astype(np.float32) / 255.0
with torch.no_grad():
color = torch.from_numpy(color).float().to(self.device)
mask = torch.from_numpy(mask).float().to(self.device)
mask = (mask > 0.5).float()
color = color * (1 - mask)
image_feed = torch.cat([color, mask], dim=2)
image_feed = rearrange(image_feed, 'h w c -> 1 c h w')
result = self.model(image_feed)[0]
result = rearrange(result, 'c h w -> h w c')
result = result * mask + color * (1 - mask)
result *= 255.0
return result.detach().cpu().numpy().clip(0, 255).astype(np.uint8)
================================================
FILE: annotator/lama/config.yaml
================================================
run_title: b18_ffc075_batch8x15
training_model:
kind: default
visualize_each_iters: 1000
concat_mask: true
store_discr_outputs_for_vis: true
losses:
l1:
weight_missing: 0
weight_known: 10
perceptual:
weight: 0
adversarial:
kind: r1
weight: 10
gp_coef: 0.001
mask_as_fake_target: true
allow_scale_mask: true
feature_matching:
weight: 100
resnet_pl:
weight: 30
weights_path: ${env:TORCH_HOME}
optimizers:
generator:
kind: adam
lr: 0.001
discriminator:
kind: adam
lr: 0.0001
visualizer:
key_order:
- image
- predicted_image
- discr_output_fake
- discr_output_real
- inpainted
rescale_keys:
- discr_output_fake
- discr_output_real
kind: directory
outdir: /group-volume/User-Driven-Content-Generation/r.suvorov/inpainting/experiments/r.suvorov_2021-04-30_14-41-12_train_simple_pix2pix2_gap_sdpl_novgg_large_b18_ffc075_batch8x15/samples
location:
data_root_dir: /group-volume/User-Driven-Content-Generation/datasets/inpainting_data_root_large
out_root_dir: /group-volume/User-Driven-Content-Generation/${env:USER}/inpainting/experiments
tb_dir: /group-volume/User-Driven-Content-Generation/${env:USER}/inpainting/tb_logs
data:
batch_size: 15
val_batch_size: 2
num_workers: 3
train:
indir: ${location.data_root_dir}/train
out_size: 256
mask_gen_kwargs:
irregular_proba: 1
irregular_kwargs:
max_angle: 4
max_len: 200
max_width: 100
max_times: 5
min_times: 1
box_proba: 1
box_kwargs:
margin: 10
bbox_min_size: 30
bbox_max_size: 150
max_times: 3
min_times: 1
segm_proba: 0
segm_kwargs:
confidence_threshold: 0.5
max_object_area: 0.5
min_mask_area: 0.07
downsample_levels: 6
num_variants_per_mask: 1
rigidness_mode: 1
max_foreground_coverage: 0.3
max_foreground_intersection: 0.7
max_mask_intersection: 0.1
max_hidden_area: 0.1
max_scale_change: 0.25
horizontal_flip: true
max_vertical_shift: 0.2
position_shuffle: true
transform_variant: distortions
dataloader_kwargs:
batch_size: ${data.batch_size}
shuffle: true
num_workers: ${data.num_workers}
val:
indir: ${location.data_root_dir}/val
img_suffix: .png
dataloader_kwargs:
batch_size: ${data.val_batch_size}
shuffle: false
num_workers: ${data.num_workers}
visual_test:
indir: ${location.data_root_dir}/korean_test
img_suffix: _input.png
pad_out_to_modulo: 32
dataloader_kwargs:
batch_size: 1
shuffle: false
num_workers: ${data.num_workers}
generator:
kind: ffc_resnet
input_nc: 4
output_nc: 3
ngf: 64
n_downsampling: 3
n_blocks: 18
add_out_act: sigmoid
init_conv_kwargs:
ratio_gin: 0
ratio_gout: 0
enable_lfu: false
downsample_conv_kwargs:
ratio_gin: ${generator.init_conv_kwargs.ratio_gout}
ratio_gout: ${generator.downsample_conv_kwargs.ratio_gin}
enable_lfu: false
resnet_conv_kwargs:
ratio_gin: 0.75
ratio_gout: ${generator.resnet_conv_kwargs.ratio_gin}
enable_lfu: false
discriminator:
kind: pix2pixhd_nlayer
input_nc: 3
ndf: 64
n_layers: 4
evaluator:
kind: default
inpainted_key: inpainted
integral_kind: ssim_fid100_f1
trainer:
kwargs:
gpus: -1
accelerator: ddp
max_epochs: 200
gradient_clip_val: 1
log_gpu_memory: None
limit_train_batches: 25000
val_check_interval: ${trainer.kwargs.limit_train_batches}
log_every_n_steps: 1000
precision: 32
terminate_on_nan: false
check_val_every_n_epoch: 1
num_sanity_val_steps: 8
limit_val_batches: 1000
replace_sampler_ddp: false
checkpoint_kwargs:
verbose: true
save_top_k: 5
save_last: true
period: 1
monitor: val_ssim_fid100_f1_total_mean
mode: max
================================================
FILE: annotator/lama/saicinpainting/__init__.py
================================================
================================================
FILE: annotator/lama/saicinpainting/training/__init__.py
================================================
================================================
FILE: annotator/lama/saicinpainting/training/data/__init__.py
================================================
================================================
FILE: annotator/lama/saicinpainting/training/data/masks.py
================================================
import math
import random
import hashlib
import logging
from enum import Enum
import cv2
import numpy as np
# from annotator.lama.saicinpainting.evaluation.masks.mask import SegmentationMask
from annotator.lama.saicinpainting.utils import LinearRamp
LOGGER = logging.getLogger(__name__)
class DrawMethod(Enum):
LINE = 'line'
CIRCLE = 'circle'
SQUARE = 'square'
def make_random_irregular_mask(shape, max_angle=4, max_len=60, max_width=20, min_times=0, max_times=10,
draw_method=DrawMethod.LINE):
draw_method = DrawMethod(draw_method)
height, width = shape
mask = np.zeros((height, width), np.float32)
times = np.random.randint(min_times, max_times + 1)
for i in range(times):
start_x = np.random.randint(width)
start_y = np.random.randint(height)
for j in range(1 + np.random.randint(5)):
angle = 0.01 + np.random.randint(max_angle)
if i % 2 == 0:
angle = 2 * 3.1415926 - angle
length = 10 + np.random.randint(max_len)
brush_w = 5 + np.random.randint(max_width)
end_x = np.clip((start_x + length * np.sin(angle)).astype(np.int32), 0, width)
end_y = np.clip((start_y + length * np.cos(angle)).astype(np.int32), 0, height)
if draw_method == DrawMethod.LINE:
cv2.line(mask, (start_x, start_y), (end_x, end_y), 1.0, brush_w)
elif draw_method == DrawMethod.CIRCLE:
cv2.circle(mask, (start_x, start_y), radius=brush_w, color=1., thickness=-1)
elif draw_method == DrawMethod.SQUARE:
radius = brush_w // 2
mask[start_y - radius:start_y + radius, start_x - radius:start_x + radius] = 1
start_x, start_y = end_x, end_y
return mask[None, ...]
class RandomIrregularMaskGenerator:
def __init__(self, max_angle=4, max_len=60, max_width=20, min_times=0, max_times=10, ramp_kwargs=None,
draw_method=DrawMethod.LINE):
self.max_angle = max_angle
self.max_len = max_len
self.max_width = max_width
self.min_times = min_times
self.max_times = max_times
self.draw_method = draw_method
self.ramp = LinearRamp(**ramp_kwargs) if ramp_kwargs is not None else None
def __call__(self, img, iter_i=None, raw_image=None):
coef = self.ramp(iter_i) if (self.ramp is not None) and (iter_i is not None) else 1
cur_max_len = int(max(1, self.max_len * coef))
cur_max_width = int(max(1, self.max_width * coef))
cur_max_times = int(self.min_times + 1 + (self.max_times - self.min_times) * coef)
return make_random_irregular_mask(img.shape[1:], max_angle=self.max_angle, max_len=cur_max_len,
max_width=cur_max_width, min_times=self.min_times, max_times=cur_max_times,
draw_method=self.draw_method)
def make_random_rectangle_mask(shape, margin=10, bbox_min_size=30, bbox_max_size=100, min_times=0, max_times=3):
height, width = shape
mask = np.zeros((height, width), np.float32)
bbox_max_size = min(bbox_max_size, height - margin * 2, width - margin * 2)
times = np.random.randint(min_times, max_times + 1)
for i in range(times):
box_width = np.random.randint(bbox_min_size, bbox_max_size)
box_height = np.random.randint(bbox_min_size, bbox_max_size)
start_x = np.random.randint(margin, width - margin - box_width + 1)
start_y = np.random.randint(margin, height - margin - box_height + 1)
mask[start_y:start_y + box_height, start_x:start_x + box_width] = 1
return mask[None, ...]
class RandomRectangleMaskGenerator:
def __init__(self, margin=10, bbox_min_size=30, bbox_max_size=100, min_times=0, max_times=3, ramp_kwargs=None):
self.margin = margin
self.bbox_min_size = bbox_min_size
self.bbox_max_size = bbox_max_size
self.min_times = min_times
self.max_times = max_times
self.ramp = LinearRamp(**ramp_kwargs) if ramp_kwargs is not None else None
def __call__(self, img, iter_i=None, raw_image=None):
coef = self.ramp(iter_i) if (self.ramp is not None) and (iter_i is not None) else 1
cur_bbox_max_size = int(self.bbox_min_size + 1 + (self.bbox_max_size - self.bbox_min_size) * coef)
cur_max_times = int(self.min_times + (self.max_times - self.min_times) * coef)
return make_random_rectangle_mask(img.shape[1:], margin=self.margin, bbox_min_size=self.bbox_min_size,
bbox_max_size=cur_bbox_max_size, min_times=self.min_times,
max_times=cur_max_times)
class RandomSegmentationMaskGenerator:
def __init__(self, **kwargs):
self.impl = None # will be instantiated in first call (effectively in subprocess)
self.kwargs = kwargs
def __call__(self, img, iter_i=None, raw_image=None):
if self.impl is None:
self.impl = SegmentationMask(**self.kwargs)
masks = self.impl.get_masks(np.transpose(img, (1, 2, 0)))
masks = [m for m in masks if len(np.unique(m)) > 1]
return np.random.choice(masks)
def make_random_superres_mask(shape, min_step=2, max_step=4, min_width=1, max_width=3):
height, width = shape
mask = np.zeros((height, width), np.float32)
step_x = np.random.randint(min_step, max_step + 1)
width_x = np.random.randint(min_width, min(step_x, max_width + 1))
offset_x = np.random.randint(0, step_x)
step_y = np.random.randint(min_step, max_step + 1)
width_y = np.random.randint(min_width, min(step_y, max_width + 1))
offset_y = np.random.randint(0, step_y)
for dy in range(width_y):
mask[offset_y + dy::step_y] = 1
for dx in range(width_x):
mask[:, offset_x + dx::step_x] = 1
return mask[None, ...]
class RandomSuperresMaskGenerator:
def __init__(self, **kwargs):
self.kwargs = kwargs
def __call__(self, img, iter_i=None):
return make_random_superres_mask(img.shape[1:], **self.kwargs)
class DumbAreaMaskGenerator:
min_ratio = 0.1
max_ratio = 0.35
default_ratio = 0.225
def __init__(self, is_training):
#Parameters:
# is_training(bool): If true - random rectangular mask, if false - central square mask
self.is_training = is_training
def _random_vector(self, dimension):
if self.is_training:
lower_limit = math.sqrt(self.min_ratio)
upper_limit = math.sqrt(self.max_ratio)
mask_side = round((random.random() * (upper_limit - lower_limit) + lower_limit) * dimension)
u = random.randint(0, dimension-mask_side-1)
v = u+mask_side
else:
margin = (math.sqrt(self.default_ratio) / 2) * dimension
u = round(dimension/2 - margin)
v = round(dimension/2 + margin)
return u, v
def __call__(self, img, iter_i=None, raw_image=None):
c, height, width = img.shape
mask = np.zeros((height, width), np.float32)
x1, x2 = self._random_vector(width)
y1, y2 = self._random_vector(height)
mask[x1:x2, y1:y2] = 1
return mask[None, ...]
class OutpaintingMaskGenerator:
def __init__(self, min_padding_percent:float=0.04, max_padding_percent:int=0.25, left_padding_prob:float=0.5, top_padding_prob:float=0.5,
right_padding_prob:float=0.5, bottom_padding_prob:float=0.5, is_fixed_randomness:bool=False):
"""
is_fixed_randomness - get identical paddings for the same image if args are the same
"""
self.min_padding_percent = min_padding_percent
self.max_padding_percent = max_padding_percent
self.probs = [left_padding_prob, top_padding_prob, right_padding_prob, bottom_padding_prob]
self.is_fixed_randomness = is_fixed_randomness
assert self.min_padding_percent <= self.max_padding_percent
assert self.max_padding_percent > 0
assert len([x for x in [self.min_padding_percent, self.max_padding_percent] if (x>=0 and x<=1)]) == 2, f"Padding percentage should be in [0,1]"
assert sum(self.probs) > 0, f"At least one of the padding probs should be greater than 0 - {self.probs}"
assert len([x for x in self.probs if (x >= 0) and (x <= 1)]) == 4, f"At least one of padding probs is not in [0,1] - {self.probs}"
if len([x for x in self.probs if x > 0]) == 1:
LOGGER.warning(f"Only one padding prob is greater than zero - {self.probs}. That means that the outpainting masks will be always on the same side")
def apply_padding(self, mask, coord):
mask[int(coord[0][0]*self.img_h):int(coord[1][0]*self.img_h),
int(coord[0][1]*self.img_w):int(coord[1][1]*self.img_w)] = 1
return mask
def get_padding(self, size):
n1 = int(self.min_padding_percent*size)
n2 = int(self.max_padding_percent*size)
return self.rnd.randint(n1, n2) / size
@staticmethod
def _img2rs(img):
arr = np.ascontiguousarray(img.astype(np.uint8))
str_hash = hashlib.sha1(arr).hexdigest()
res = hash(str_hash)%(2**32)
return res
def __call__(self, img, iter_i=None, raw_image=None):
c, self.img_h, self.img_w = img.shape
mask = np.zeros((self.img_h, self.img_w), np.float32)
at_least_one_mask_applied = False
if self.is_fixed_randomness:
assert raw_image is not None, f"Cant calculate hash on raw_image=None"
rs = self._img2rs(raw_image)
self.rnd = np.random.RandomState(rs)
else:
self.rnd = np.random
coords = [[
(0,0),
(1,self.get_padding(size=self.img_h))
],
[
(0,0),
(self.get_padding(size=self.img_w),1)
],
[
(0,1-self.get_padding(size=self.img_h)),
(1,1)
],
[
(1-self.get_padding(size=self.img_w),0),
(1,1)
]]
for pp, coord in zip(self.probs, coords):
if self.rnd.random() < pp:
at_least_one_mask_applied = True
mask = self.apply_padding(mask=mask, coord=coord)
if not at_least_one_mask_applied:
idx = self.rnd.choice(range(len(coords)), p=np.array(self.probs)/sum(self.probs))
mask = self.apply_padding(mask=mask, coord=coords[idx])
return mask[None, ...]
class MixedMaskGenerator:
def __init__(self, irregular_proba=1/3, irregular_kwargs=None,
box_proba=1/3, box_kwargs=None,
segm_proba=1/3, segm_kwargs=None,
squares_proba=0, squares_kwargs=None,
superres_proba=0, superres_kwargs=None,
outpainting_proba=0, outpainting_kwargs=None,
invert_proba=0):
self.probas = []
self.gens = []
if irregular_proba > 0:
self.probas.append(irregular_proba)
if irregular_kwargs is None:
irregular_kwargs = {}
else:
irregular_kwargs = dict(irregular_kwargs)
irregular_kwargs['draw_method'] = DrawMethod.LINE
self.gens.append(RandomIrregularMaskGenerator(**irregular_kwargs))
if box_proba > 0:
self.probas.append(box_proba)
if box_kwargs is None:
box_kwargs = {}
self.gens.append(RandomRectangleMaskGenerator(**box_kwargs))
if segm_proba > 0:
self.probas.append(segm_proba)
if segm_kwargs is None:
segm_kwargs = {}
self.gens.append(RandomSegmentationMaskGenerator(**segm_kwargs))
if squares_proba > 0:
self.probas.append(squares_proba)
if squares_kwargs is None:
squares_kwargs = {}
else:
squares_kwargs = dict(squares_kwargs)
squares_kwargs['draw_method'] = DrawMethod.SQUARE
self.gens.append(RandomIrregularMaskGenerator(**squares_kwargs))
if superres_proba > 0:
self.probas.append(superres_proba)
if superres_kwargs is None:
superres_kwargs = {}
self.gens.append(RandomSuperresMaskGenerator(**superres_kwargs))
if outpainting_proba > 0:
self.probas.append(outpainting_proba)
if outpainting_kwargs is None:
outpainting_kwargs = {}
self.gens.append(OutpaintingMaskGenerator(**outpainting_kwargs))
self.probas = np.array(self.probas, dtype='float32')
self.probas /= self.probas.sum()
self.invert_proba = invert_proba
def __call__(self, img, iter_i=None, raw_image=None):
kind = np.random.choice(len(self.probas), p=self.probas)
gen = self.gens[kind]
result = gen(img, iter_i=iter_i, raw_image=raw_image)
if self.invert_proba > 0 and random.random() < self.invert_proba:
result = 1 - result
return result
def get_mask_generator(kind, kwargs):
if kind is None:
kind = "mixed"
if kwargs is None:
kwargs = {}
if kind == "mixed":
cl = MixedMaskGenerator
elif kind == "outpainting":
cl = OutpaintingMaskGenerator
elif kind == "dumb":
cl = DumbAreaMaskGenerator
else:
raise NotImplementedError(f"No such generator kind = {kind}")
return cl(**kwargs)
================================================
FILE: annotator/lama/saicinpainting/training/losses/__init__.py
================================================
================================================
FILE: annotator/lama/saicinpainting/training/losses/adversarial.py
================================================
from typing import Tuple, Dict, Optional
import torch
import torch.nn as nn
import torch.nn.functional as F
class BaseAdversarialLoss:
def pre_generator_step(self, real_batch: torch.Tensor, fake_batch: torch.Tensor,
generator: nn.Module, discriminator: nn.Module):
"""
Prepare for generator step
:param real_batch: Tensor, a batch of real samples
:param fake_batch: Tensor, a batch of samples produced by generator
:param generator:
:param discriminator:
:return: None
"""
def pre_discriminator_step(self, real_batch: torch.Tensor, fake_batch: torch.Tensor,
generator: nn.Module, discriminator: nn.Module):
"""
Prepare for discriminator step
:param real_batch: Tensor, a batch of real samples
:param fake_batch: Tensor, a batch of samples produced by generator
:param generator:
:param discriminator:
:return: None
"""
def generator_loss(self, real_batch: torch.Tensor, fake_batch: torch.Tensor,
discr_real_pred: torch.Tensor, discr_fake_pred: torch.Tensor,
mask: Optional[torch.Tensor] = None) \
-> Tuple[torch.Tensor, Dict[str, torch.Tensor]]:
"""
Calculate generator loss
:param real_batch: Tensor, a batch of real samples
:param fake_batch: Tensor, a batch of samples produced by generator
:param discr_real_pred: Tensor, discriminator output for real_batch
:param discr_fake_pred: Tensor, discriminator output for fake_batch
:param mask: Tensor, actual mask, which was at input of generator when making fake_batch
:return: total generator loss along with some values that might be interesting to log
"""
raise NotImplemented()
def discriminator_loss(self, real_batch: torch.Tensor, fake_batch: torch.Tensor,
discr_real_pred: torch.Tensor, discr_fake_pred: torch.Tensor,
mask: Optional[torch.Tensor] = None) \
-> Tuple[torch.Tensor, Dict[str, torch.Tensor]]:
"""
Calculate discriminator loss and call .backward() on it
:param real_batch: Tensor, a batch of real samples
:param fake_batch: Tensor, a batch of samples produced by generator
:param discr_real_pred: Tensor, discriminator output for real_batch
:param discr_fake_pred: Tensor, discriminator output for fake_batch
:param mask: Tensor, actual mask, which was at input of generator when making fake_batch
:return: total discriminator loss along with some values that might be interesting to log
"""
raise NotImplemented()
def interpolate_mask(self, mask, shape):
assert mask is not None
assert self.allow_scale_mask or shape == mask.shape[-2:]
if shape != mask.shape[-2:] and self.allow_scale_mask:
if self.mask_scale_mode == 'maxpool':
mask = F.adaptive_max_pool2d(mask, shape)
else:
mask = F.interpolate(mask, size=shape, mode=self.mask_scale_mode)
return mask
def make_r1_gp(discr_real_pred, real_batch):
if torch.is_grad_enabled():
grad_real = torch.autograd.grad(outputs=discr_real_pred.sum(), inputs=real_batch, create_graph=True)[0]
grad_penalty = (grad_real.view(grad_real.shape[0], -1).norm(2, dim=1) ** 2).mean()
else:
grad_penalty = 0
real_batch.requires_grad = False
return grad_penalty
class NonSaturatingWithR1(BaseAdversarialLoss):
def __init__(self, gp_coef=5, weight=1, mask_as_fake_target=False, allow_scale_mask=False,
mask_scale_mode='nearest', extra_mask_weight_for_gen=0,
use_unmasked_for_gen=True, use_unmasked_for_discr=True):
self.gp_coef = gp_coef
self.weight = weight
# use for discr => use for gen;
# otherwise we teach only the discr to pay attention to very small difference
assert use_unmasked_for_gen or (not use_unmasked_for_discr)
# mask as target => use unmasked for discr:
# if we don't care about unmasked regions at all
# then it doesn't matter if the value of mask_as_fake_target is true or false
assert use_unmasked_for_discr or (not mask_as_fake_target)
self.use_unmasked_for_gen = use_unmasked_for_gen
self.use_unmasked_for_discr = use_unmasked_for_discr
self.mask_as_fake_target = mask_as_fake_target
self.allow_scale_mask = allow_scale_mask
self.mask_scale_mode = mask_scale_mode
self.extra_mask_weight_for_gen = extra_mask_weight_for_gen
def generator_loss(self, real_batch: torch.Tensor, fake_batch: torch.Tensor,
discr_real_pred: torch.Tensor, discr_fake_pred: torch.Tensor,
mask=None) \
-> Tuple[torch.Tensor, Dict[str, torch.Tensor]]:
fake_loss = F.softplus(-discr_fake_pred)
if (self.mask_as_fake_target and self.extra_mask_weight_for_gen > 0) or \
not self.use_unmasked_for_gen: # == if masked region should be treated differently
mask = self.interpolate_mask(mask, discr_fake_pred.shape[-2:])
if not self.use_unmasked_for_gen:
fake_loss = fake_loss * mask
else:
pixel_weights = 1 + mask * self.extra_mask_weight_for_gen
fake_loss = fake_loss * pixel_weights
return fake_loss.mean() * self.weight, dict()
def pre_discriminator_step(self, real_batch: torch.Tensor, fake_batch: torch.Tensor,
generator: nn.Module, discriminator: nn.Module):
real_batch.requires_grad = True
def discriminator_loss(self, real_batch: torch.Tensor, fake_batch: torch.Tensor,
discr_real_pred: torch.Tensor, discr_fake_pred: torch.Tensor,
mask=None) \
-> Tuple[torch.Tensor, Dict[str, torch.Tensor]]:
real_loss = F.softplus(-discr_real_pred)
grad_penalty = make_r1_gp(discr_real_pred, real_batch) * self.gp_coef
fake_loss = F.softplus(discr_fake_pred)
if not self.use_unmasked_for_discr or self.mask_as_fake_target:
# == if masked region should be treated differently
mask = self.interpolate_mask(mask, discr_fake_pred.shape[-2:])
# use_unmasked_for_discr=False only makes sense for fakes;
# for reals there is no difference beetween two regions
fake_loss = fake_loss * mask
if self.mask_as_fake_target:
fake_loss = fake_loss + (1 - mask) * F.softplus(-discr_fake_pred)
sum_discr_loss = real_loss + grad_penalty + fake_loss
metrics = dict(discr_real_out=discr_real_pred.mean(),
discr_fake_out=discr_fake_pred.mean(),
discr_real_gp=grad_penalty)
return sum_discr_loss.mean(), metrics
class BCELoss(BaseAdversarialLoss):
def __init__(self, weight):
self.weight = weight
self.bce_loss = nn.BCEWithLogitsLoss()
def generator_loss(self, discr_fake_pred: torch.Tensor) -> Tuple[torch.Tensor, Dict[str, torch.Tensor]]:
real_mask_gt = torch.zeros(discr_fake_pred.shape).to(discr_fake_pred.device)
fake_loss = self.bce_loss(discr_fake_pred, real_mask_gt) * self.weight
return fake_loss, dict()
def pre_discriminator_step(self, real_batch: torch.Tensor, fake_batch: torch.Tensor,
generator: nn.Module, discriminator: nn.Module):
real_batch.requires_grad = True
def discriminator_loss(self,
mask: torch.Tensor,
discr_real_pred: torch.Tensor,
discr_fake_pred: torch.Tensor) -> Tuple[torch.Tensor, Dict[str, torch.Tensor]]:
real_mask_gt = torch.zeros(discr_real_pred.shape).to(discr_real_pred.device)
sum_discr_loss = (self.bce_loss(discr_real_pred, real_mask_gt) + self.bce_loss(discr_fake_pred, mask)) / 2
metrics = dict(discr_real_out=discr_real_pred.mean(),
discr_fake_out=discr_fake_pred.mean(),
discr_real_gp=0)
return sum_discr_loss, metrics
def make_discrim_loss(kind, **kwargs):
if kind == 'r1':
return NonSaturatingWithR1(**kwargs)
elif kind == 'bce':
return BCELoss(**kwargs)
raise ValueError(f'Unknown adversarial loss kind {kind}')
================================================
FILE: annotator/lama/saicinpainting/training/losses/constants.py
================================================
weights = {"ade20k":
[6.34517766497462,
9.328358208955224,
11.389521640091116,
16.10305958132045,
20.833333333333332,
22.22222222222222,
25.125628140703515,
43.29004329004329,
50.5050505050505,
54.6448087431694,
55.24861878453038,
60.24096385542168,
62.5,
66.2251655629139,
84.74576271186442,
90.90909090909092,
91.74311926605505,
96.15384615384616,
96.15384615384616,
97.08737864077669,
102.04081632653062,
135.13513513513513,
149.2537313432836,
153.84615384615384,
163.93442622950818,
166.66666666666666,
188.67924528301887,
192.30769230769232,
217.3913043478261,
227.27272727272725,
227.27272727272725,
227.27272727272725,
303.03030303030306,
322.5806451612903,
333.3333333333333,
370.3703703703703,
384.61538461538464,
416.6666666666667,
416.6666666666667,
434.7826086956522,
434.7826086956522,
454.5454545454545,
454.5454545454545,
500.0,
526.3157894736842,
526.3157894736842,
555.5555555555555,
555.5555555555555,
555.5555555555555,
555.5555555555555,
555.5555555555555,
555.5555555555555,
555.5555555555555,
588.2352941176471,
588.2352941176471,
588.2352941176471,
588.2352941176471,
588.2352941176471,
666.6666666666666,
666.6666666666666,
666.6666666666666,
666.6666666666666,
714.2857142857143,
714.2857142857143,
714.2857142857143,
714.2857142857143,
714.2857142857143,
769.2307692307693,
769.2307692307693,
769.2307692307693,
833.3333333333334,
833.3333333333334,
833.3333333333334,
833.3333333333334,
909.090909090909,
1000.0,
1111.111111111111,
1111.111111111111,
1111.111111111111,
1111.111111111111,
1111.111111111111,
1250.0,
1250.0,
1250.0,
1250.0,
1250.0,
1428.5714285714287,
1428.5714285714287,
1428.5714285714287,
1428.5714285714287,
1428.5714285714287,
1428.5714285714287,
1428.5714285714287,
1666.6666666666667,
1666.6666666666667,
1666.6666666666667,
1666.6666666666667,
1666.6666666666667,
1666.6666666666667,
1666.6666666666667,
1666.6666666666667,
1666.6666666666667,
1666.6666666666667,
1666.6666666666667,
2000.0,
2000.0,
2000.0,
2000.0,
2000.0,
2000.0,
2000.0,
2000.0,
2000.0,
2000.0,
2000.0,
2000.0,
2000.0,
2000.0,
2000.0,
2000.0,
2000.0,
2500.0,
2500.0,
2500.0,
2500.0,
2500.0,
2500.0,
2500.0,
2500.0,
2500.0,
2500.0,
2500.0,
2500.0,
2500.0,
3333.3333333333335,
3333.3333333333335,
3333.3333333333335,
3333.3333333333335,
3333.3333333333335,
3333.3333333333335,
3333.3333333333335,
3333.3333333333335,
3333.3333333333335,
3333.3333333333335,
3333.3333333333335,
3333.3333333333335,
3333.3333333333335,
5000.0,
5000.0,
5000.0]
}
================================================
FILE: annotator/lama/saicinpainting/training/losses/distance_weighting.py
================================================
import torch
import torch.nn as nn
import torch.nn.functional as F
import torchvision
from annotator.lama.saicinpainting.training.losses.perceptual import IMAGENET_STD, IMAGENET_MEAN
def dummy_distance_weighter(real_img, pred_img, mask):
return mask
def get_gauss_kernel(kernel_size, width_factor=1):
coords = torch.stack(torch.meshgrid(torch.arange(kernel_size),
torch.arange(kernel_size)),
dim=0).float()
diff = torch.exp(-((coords - kernel_size // 2) ** 2).sum(0) / kernel_size / width_factor)
diff /= diff.sum()
return diff
class BlurMask(nn.Module):
def __init__(self, kernel_size=5, width_factor=1):
super().__init__()
self.filter = nn.Conv2d(1, 1, kernel_size, padding=kernel_size // 2, padding_mode='replicate', bias=False)
self.filter.weight.data.copy_(get_gauss_kernel(kernel_size, width_factor=width_factor))
def forward(self, real_img, pred_img, mask):
with torch.no_grad():
result = self.filter(mask) * mask
return result
class EmulatedEDTMask(nn.Module):
def __init__(self, dilate_kernel_size=5, blur_kernel_size=5, width_factor=1):
super().__init__()
self.dilate_filter = nn.Conv2d(1, 1, dilate_kernel_size, padding=dilate_kernel_size// 2, padding_mode='replicate',
bias=False)
self.dilate_filter.weight.data.copy_(torch.ones(1, 1, dilate_kernel_size, dilate_kernel_size, dtype=torch.float))
self.blur_filter = nn.Conv2d(1, 1, blur_kernel_size, padding=blur_kernel_size // 2, padding_mode='replicate', bias=False)
self.blur_filter.weight.data.copy_(get_gauss_kernel(blur_kernel_size, width_factor=width_factor))
def forward(self, real_img, pred_img, mask):
with torch.no_grad():
known_mask = 1 - mask
dilated_known_mask = (self.dilate_filter(known_mask) > 1).float()
result = self.blur_filter(1 - dilated_known_mask) * mask
return result
class PropagatePerceptualSim(nn.Module):
def __init__(self, level=2, max_iters=10, temperature=500, erode_mask_size=3):
super().__init__()
vgg = torchvision.models.vgg19(pretrained=True).features
vgg_avg_pooling = []
for weights in vgg.parameters():
weights.requires_grad = False
cur_level_i = 0
for module in vgg.modules():
if module.__class__.__name__ == 'Sequential':
continue
elif module.__class__.__name__ == 'MaxPool2d':
vgg_avg_pooling.append(nn.AvgPool2d(kernel_size=2, stride=2, padding=0))
else:
vgg_avg_pooling.append(module)
if module.__class__.__name__ == 'ReLU':
cur_level_i += 1
if cur_level_i == level:
break
self.features = nn.Sequential(*vgg_avg_pooling)
self.max_iters = max_iters
self.temperature = temperature
self.do_erode = erode_mask_size > 0
if self.do_erode:
self.erode_mask = nn.Conv2d(1, 1, erode_mask_size, padding=erode_mask_size // 2, bias=False)
self.erode_mask.weight.data.fill_(1)
def forward(self, real_img, pred_img, mask):
with torch.no_grad():
real_img = (real_img - IMAGENET_MEAN.to(real_img)) / IMAGENET_STD.to(real_img)
real_feats = self.features(real_img)
vertical_sim = torch.exp(-(real_feats[:, :, 1:] - real_feats[:, :, :-1]).pow(2).sum(1, keepdim=True)
/ self.temperature)
horizontal_sim = torch.exp(-(real_feats[:, :, :, 1:] - real_feats[:, :, :, :-1]).pow(2).sum(1, keepdim=True)
/ self.temperature)
mask_scaled = F.interpolate(mask, size=real_feats.shape[-2:], mode='bilinear', align_corners=False)
if self.do_erode:
mask_scaled = (self.erode_mask(mask_scaled) > 1).float()
cur_knowness = 1 - mask_scaled
for iter_i in range(self.max_iters):
new_top_knowness = F.pad(cur_knowness[:, :, :-1] * vertical_sim, (0, 0, 1, 0), mode='replicate')
new_bottom_knowness = F.pad(cur_knowness[:, :, 1:] * vertical_sim, (0, 0, 0, 1), mode='replicate')
new_left_knowness = F.pad(cur_knowness[:, :, :, :-1] * horizontal_sim, (1, 0, 0, 0), mode='replicate')
new_right_knowness = F.pad(cur_knowness[:, :, :, 1:] * horizontal_sim, (0, 1, 0, 0), mode='replicate')
new_knowness = torch.stack([new_top_knowness, new_bottom_knowness,
new_left_knowness, new_right_knowness],
dim=0).max(0).values
cur_knowness = torch.max(cur_knowness, new_knowness)
cur_knowness = F.interpolate(cur_knowness, size=mask.shape[-2:], mode='bilinear')
result = torch.min(mask, 1 - cur_knowness)
return result
def make_mask_distance_weighter(kind='none', **kwargs):
if kind == 'none':
return dummy_distance_weighter
if kind == 'blur':
return BlurMask(**kwargs)
if kind == 'edt':
return EmulatedEDTMask(**kwargs)
if kind == 'pps':
return PropagatePerceptualSim(**kwargs)
raise ValueError(f'Unknown mask distance weighter kind {kind}')
================================================
FILE: annotator/lama/saicinpainting/training/losses/feature_matching.py
================================================
from typing import List
import torch
import torch.nn.functional as F
def masked_l2_loss(pred, target, mask, weight_known, weight_missing):
per_pixel_l2 = F.mse_loss(pred, target, reduction='none')
pixel_weights = mask * weight_missing + (1 - mask) * weight_known
return (pixel_weights * per_pixel_l2).mean()
def masked_l1_loss(pred, target, mask, weight_known, weight_missing):
per_pixel_l1 = F.l1_loss(pred, target, reduction='none')
pixel_weights = mask * weight_missing + (1 - mask) * weight_known
return (pixel_weights * per_pixel_l1).mean()
def feature_matching_loss(fake_features: List[torch.Tensor], target_features: List[torch.Tensor], mask=None):
if mask is None:
res = torch.stack([F.mse_loss(fake_feat, target_feat)
for fake_feat, target_feat in zip(fake_features, target_features)]).mean()
else:
res = 0
norm = 0
for fake_feat, target_feat in zip(fake_features, target_features):
cur_mask = F.interpolate(mask, size=fake_feat.shape[-2:], mode='bilinear', align_corners=False)
error_weights = 1 - cur_mask
cur_val = ((fake_feat - target_feat).pow(2) * error_weights).mean()
res = res + cur_val
norm += 1
res = res / norm
return res
================================================
FILE: annotator/lama/saicinpainting/training/losses/perceptual.py
================================================
import torch
import torch.nn as nn
import torch.nn.functional as F
import torchvision
# from models.ade20k import ModelBuilder
from annotator.lama.saicinpainting.utils import check_and_warn_input_range
IMAGENET_MEAN = torch.FloatTensor([0.485, 0.456, 0.406])[None, :, None, None]
IMAGENET_STD = torch.FloatTensor([0.229, 0.224, 0.225])[None, :, None, None]
class PerceptualLoss(nn.Module):
def __init__(self, normalize_inputs=True):
super(PerceptualLoss, self).__init__()
self.normalize_inputs = normalize_inputs
self.mean_ = IMAGENET_MEAN
self.std_ = IMAGENET_STD
vgg = torchvision.models.vgg19(pretrained=True).features
vgg_avg_pooling = []
for weights in vgg.parameters():
weights.requires_grad = False
for module in vgg.modules():
if module.__class__.__name__ == 'Sequential':
continue
elif module.__class__.__name__ == 'MaxPool2d':
vgg_avg_pooling.append(nn.AvgPool2d(kernel_size=2, stride=2, padding=0))
else:
vgg_avg_pooling.append(module)
self.vgg = nn.Sequential(*vgg_avg_pooling)
def do_normalize_inputs(self, x):
return (x - self.mean_.to(x.device)) / self.std_.to(x.device)
def partial_losses(self, input, target, mask=None):
check_and_warn_input_range(target, 0, 1, 'PerceptualLoss target in partial_losses')
# we expect input and target to be in [0, 1] range
losses = []
if self.normalize_inputs:
features_input = self.do_normalize_inputs(input)
features_target = self.do_normalize_inputs(target)
else:
features_input = input
features_target = target
for layer in self.vgg[:30]:
features_input = layer(features_input)
features_target = layer(features_target)
if layer.__class__.__name__ == 'ReLU':
loss = F.mse_loss(features_input, features_target, reduction='none')
if mask is not None:
cur_mask = F.interpolate(mask, size=features_input.shape[-2:],
mode='bilinear', align_corners=False)
loss = loss * (1 - cur_mask)
loss = loss.mean(dim=tuple(range(1, len(loss.shape))))
losses.append(loss)
return losses
def forward(self, input, target, mask=None):
losses = self.partial_losses(input, target, mask=mask)
return torch.stack(losses).sum(dim=0)
def get_global_features(self, input):
check_and_warn_input_range(input, 0, 1, 'PerceptualLoss input in get_global_features')
if self.normalize_inputs:
features_input = self.do_normalize_inputs(input)
else:
features_input = input
features_input = self.vgg(features_input)
return features_input
class ResNetPL(nn.Module):
def __init__(self, weight=1,
weights_path=None, arch_encoder='resnet50dilated', segmentation=True):
super().__init__()
self.impl = ModelBuilder.get_encoder(weights_path=weights_path,
arch_encoder=arch_encoder,
arch_decoder='ppm_deepsup',
fc_dim=2048,
segmentation=segmentation)
self.impl.eval()
for w in self.impl.parameters():
w.requires_grad_(False)
self.weight = weight
def forward(self, pred, target):
pred = (pred - IMAGENET_MEAN.to(pred)) / IMAGENET_STD.to(pred)
target = (target - IMAGENET_MEAN.to(target)) / IMAGENET_STD.to(target)
pred_feats = self.impl(pred, return_feature_maps=True)
target_feats = self.impl(target, return_feature_maps=True)
result = torch.stack([F.mse_loss(cur_pred, cur_target)
for cur_pred, cur_target
in zip(pred_feats, target_feats)]).sum() * self.weight
return result
================================================
FILE: annotator/lama/saicinpainting/training/losses/segmentation.py
================================================
import torch
import torch.nn as nn
import torch.nn.functional as F
from .constants import weights as constant_weights
from modules import devices
class CrossEntropy2d(nn.Module):
def __init__(self, reduction="mean", ignore_label=255, weights=None, *args, **kwargs):
"""
weight (Tensor, optional): a manual rescaling weight given to each class.
If given, has to be a Tensor of size "nclasses"
"""
super(CrossEntropy2d, self).__init__()
self.reduction = reduction
self.ignore_label = ignore_label
self.weights = weights
if self.weights is not None:
device = devices.get_device_for("controlnet") if torch.cuda.is_available() else torch.device('cpu')
self.weights = torch.FloatTensor(constant_weights[weights]).to(device)
def forward(self, predict, target):
"""
Args:
predict:(n, c, h, w)
target:(n, 1, h, w)
"""
target = target.long()
assert not target.requires_grad
assert predict.dim() == 4, "{0}".format(predict.size())
assert target.dim() == 4, "{0}".format(target.size())
assert predict.size(0) == target.size(0), "{0} vs {1} ".format(predict.size(0), target.size(0))
assert target.size(1) == 1, "{0}".format(target.size(1))
assert predict.size(2) == target.size(2), "{0} vs {1} ".format(predict.size(2), target.size(2))
assert predict.size(3) == target.size(3), "{0} vs {1} ".format(predict.size(3), target.size(3))
target = target.squeeze(1)
n, c, h, w = predict.size()
target_mask = (target >= 0) * (target != self.ignore_label)
target = target[target_mask]
predict = predict.transpose(1, 2).transpose(2, 3).contiguous()
predict = predict[target_mask.view(n, h, w, 1).repeat(1, 1, 1, c)].view(-1, c)
loss = F.cross_entropy(predict, target, weight=self.weights, reduction=self.reduction)
return loss
================================================
FILE: annotator/lama/saicinpainting/training/losses/style_loss.py
================================================
import torch
import torch.nn as nn
import torchvision.models as models
class PerceptualLoss(nn.Module):
r"""
Perceptual loss, VGG-based
https://arxiv.org/abs/1603.08155
https://github.com/dxyang/StyleTransfer/blob/master/utils.py
"""
def __init__(self, weights=[1.0, 1.0, 1.0, 1.0, 1.0]):
super(PerceptualLoss, self).__init__()
self.add_module('vgg', VGG19())
self.criterion = torch.nn.L1Loss()
self.weights = weights
def __call__(self, x, y):
# Compute features
x_vgg, y_vgg = self.vgg(x), self.vgg(y)
content_loss = 0.0
content_loss += self.weights[0] * self.criterion(x_vgg['relu1_1'], y_vgg['relu1_1'])
content_loss += self.weights[1] * self.criterion(x_vgg['relu2_1'], y_vgg['relu2_1'])
content_loss += self.weights[2] * self.criterion(x_vgg['relu3_1'], y_vgg['relu3_1'])
content_loss += self.weights[3] * self.criterion(x_vgg['relu4_1'], y_vgg['relu4_1'])
content_loss += self.weights[4] * self.criterion(x_vgg['relu5_1'], y_vgg['relu5_1'])
return content_loss
class VGG19(torch.nn.Module):
def __init__(self):
super(VGG19, self).__init__()
features = models.vgg19(pretrained=True).features
self.relu1_1 = torch.nn.Sequential()
self.relu1_2 = torch.nn.Sequential()
self.relu2_1 = torch.nn.Sequential()
self.relu2_2 = torch.nn.Sequential()
self.relu3_1 = torch.nn.Sequential()
self.relu3_2 = torch.nn.Sequential()
self.relu3_3 = torch.nn.Sequential()
self.relu3_4 = torch.nn.Sequential()
self.relu4_1 = torch.nn.Sequential()
self.relu4_2 = torch.nn.Sequential()
self.relu4_3 = torch.nn.Sequential()
self.relu4_4 = torch.nn.Sequential()
self.relu5_1 = torch.nn.Sequential()
self.relu5_2 = torch.nn.Sequential()
self.relu5_3 = torch.nn.Sequential()
self.relu5_4 = torch.nn.Sequential()
for x in range(2):
self.relu1_1.add_module(str(x), features[x])
for x in range(2, 4):
self.relu1_2.add_module(str(x), features[x])
for x in range(4, 7):
self.relu2_1.add_module(str(x), features[x])
for x in range(7, 9):
self.relu2_2.add_module(str(x), features[x])
for x in range(9, 12):
self.relu3_1.add_module(str(x), features[x])
for x in range(12, 14):
self.relu3_2.add_module(str(x), features[x])
for x in range(14, 16):
self.relu3_2.add_module(str(x), features[x])
for x in range(16, 18):
self.relu3_4.add_module(str(x), features[x])
for x in range(18, 21):
self.relu4_1.add_module(str(x), features[x])
for x in range(21, 23):
self.relu4_2.add_module(str(x), features[x])
for x in range(23, 25):
self.relu4_3.add_module(str(x), features[x])
for x in range(25, 27):
self.relu4_4.add_module(str(x), features[x])
for x in range(27, 30):
self.relu5_1.add_module(str(x), features[x])
for x in range(30, 32):
self.relu5_2.add_module(str(x), features[x])
for x in range(32, 34):
self.relu5_3.add_module(str(x), features[x])
for x in range(34, 36):
self.relu5_4.add_module(str(x), features[x])
# don't need the gradients, just want the features
for param in self.parameters():
param.requires_grad = False
def forward(self, x):
relu1_1 = self.relu1_1(x)
relu1_2 = self.relu1_2(relu1_1)
relu2_1 = self.relu2_1(relu1_2)
relu2_2 = self.relu2_2(relu2_1)
relu3_1 = self.relu3_1(relu2_2)
relu3_2 = self.relu3_2(relu3_1)
relu3_3 = self.relu3_3(relu3_2)
relu3_4 = self.relu3_4(relu3_3)
relu4_1 = self.relu4_1(relu3_4)
relu4_2 = self.relu4_2(relu4_1)
relu4_3 = self.relu4_3(relu4_2)
relu4_4 = self.relu4_4(relu4_3)
relu5_1 = self.relu5_1(relu4_4)
relu5_2 = self.relu5_2(relu5_1)
relu5_3 = self.relu5_3(relu5_2)
relu5_4 = self.relu5_4(relu5_3)
out = {
'relu1_1': relu1_1,
'relu1_2': relu1_2,
'relu2_1': relu2_1,
'relu2_2': relu2_2,
'relu3_1': relu3_1,
'relu3_2': relu3_2,
'relu3_3': relu3_3,
'relu3_4': relu3_4,
'relu4_1': relu4_1,
'relu4_2': relu4_2,
'relu4_3': relu4_3,
'relu4_4': relu4_4,
'relu5_1': relu5_1,
'relu5_2': relu5_2,
'relu5_3': relu5_3,
'relu5_4': relu5_4,
}
return out
================================================
FILE: annotator/lama/saicinpainting/training/modules/__init__.py
================================================
import logging
from annotator.lama.saicinpainting.training.modules.ffc import FFCResNetGenerator
from annotator.lama.saicinpainting.training.modules.pix2pixhd import GlobalGenerator, MultiDilatedGlobalGenerator, \
NLayerDiscriminator, MultidilatedNLayerDiscriminator
def make_generator(config, kind, **kwargs):
logging.info(f'Make generator {kind}')
if kind == 'pix2pixhd_multidilated':
return MultiDilatedGlobalGenerator(**kwargs)
if kind == 'pix2pixhd_global':
return GlobalGenerator(**kwargs)
if kind == 'ffc_resnet':
return FFCResNetGenerator(**kwargs)
raise ValueError(f'Unknown generator kind {kind}')
def make_discriminator(kind, **kwargs):
logging.info(f'Make discriminator {kind}')
if kind == 'pix2pixhd_nlayer_multidilated':
return MultidilatedNLayerDiscriminator(**kwargs)
if kind == 'pix2pixhd_nlayer':
return NLayerDiscriminator(**kwargs)
raise ValueError(f'Unknown discriminator kind {kind}')
================================================
FILE: annotator/lama/saicinpainting/training/modules/base.py
================================================
import abc
from typing import Tuple, List
import torch
import torch.nn as nn
from annotator.lama.saicinpainting.training.modules.depthwise_sep_conv import DepthWiseSeperableConv
from annotator.lama.saicinpainting.training.modules.multidilated_conv import MultidilatedConv
class BaseDiscriminator(nn.Module):
@abc.abstractmethod
def forward(self, x: torch.Tensor) -> Tuple[torch.Tensor, List[torch.Tensor]]:
"""
Predict scores and get intermediate activations. Useful for feature matching loss
:return tuple (scores, list of intermediate activations)
"""
raise NotImplemented()
def get_conv_block_ctor(kind='default'):
if not isinstance(kind, str):
return kind
if kind == 'default':
return nn.Conv2d
if kind == 'depthwise':
return DepthWiseSeperableConv
if kind == 'multidilated':
return MultidilatedConv
raise ValueError(f'Unknown convolutional block kind {kind}')
def get_norm_layer(kind='bn'):
if not isinstance(kind, str):
return kind
if kind == 'bn':
return nn.BatchNorm2d
if kind == 'in':
return nn.InstanceNorm2d
raise ValueError(f'Unknown norm block kind {kind}')
def get_activation(kind='tanh'):
if kind == 'tanh':
return nn.Tanh()
if kind == 'sigmoid':
return nn.Sigmoid()
if kind is False:
return nn.Identity()
raise ValueError(f'Unknown activation kind {kind}')
class SimpleMultiStepGenerator(nn.Module):
def __init__(self, steps: List[nn.Module]):
super().__init__()
self.steps = nn.ModuleList(steps)
def forward(self, x):
cur_in = x
outs = []
for step in self.steps:
cur_out = step(cur_in)
outs.append(cur_out)
cur_in = torch.cat((cur_in, cur_out), dim=1)
return torch.cat(outs[::-1], dim=1)
def deconv_factory(kind, ngf, mult, norm_layer, activation, max_features):
if kind == 'convtranspose':
return [nn.ConvTranspose2d(min(max_features, ngf * mult),
min(max_features, int(ngf * mult / 2)),
kernel_size=3, stride=2, padding=1, output_padding=1),
norm_layer(min(max_features, int(ngf * mult / 2))), activation]
elif kind == 'bilinear':
return [nn.Upsample(scale_factor=2, mode='bilinear'),
DepthWiseSeperableConv(min(max_features, ngf * mult),
min(max_features, int(ngf * mult / 2)),
kernel_size=3, stride=1, padding=1),
norm_layer(min(max_features, int(ngf * mult / 2))), activation]
else:
raise Exception(f"Invalid deconv kind: {kind}")
================================================
FILE: annotator/lama/saicinpainting/training/modules/depthwise_sep_conv.py
================================================
import torch
import torch.nn as nn
class DepthWiseSeperableConv(nn.Module):
def __init__(self, in_dim, out_dim, *args, **kwargs):
super().__init__()
if 'groups' in kwargs:
# ignoring groups for Depthwise Sep Conv
del kwargs['groups']
self.depthwise = nn.Conv2d(in_dim, in_dim, *args, groups=in_dim, **kwargs)
self.pointwise = nn.Conv2d(in_dim, out_dim, kernel_size=1)
def forward(self, x):
out = self.depthwise(x)
out = self.pointwise(out)
return out
================================================
FILE: annotator/lama/saicinpainting/training/modules/fake_fakes.py
================================================
import torch
from kornia import SamplePadding
from kornia.augmentation import RandomAffine, CenterCrop
class FakeFakesGenerator:
def __init__(self, aug_proba=0.5, img_aug_degree=30, img_aug_translate=0.2):
self.grad_aug = RandomAffine(degrees=360,
translate=0.2,
padding_mode=SamplePadding.REFLECTION,
keepdim=False,
p=1)
self.img_aug = RandomAffine(degrees=img_aug_degree,
translate=img_aug_translate,
padding_mode=SamplePadding.REFLECTION,
keepdim=True,
p=1)
self.aug_proba = aug_proba
def __call__(self, input_images, masks):
blend_masks = self._fill_masks_with_gradient(masks)
blend_target = self._make_blend_target(input_images)
result = input_images * (1 - blend_masks) + blend_target * blend_masks
return result, blend_masks
def _make_blend_target(self, input_images):
batch_size = input_images.shape[0]
permuted = input_images[torch.randperm(batch_size)]
augmented = self.img_aug(input_images)
is_aug = (torch.rand(batch_size, device=input_images.device)[:, None, None, None] < self.aug_proba).float()
result = augmented * is_aug + permuted * (1 - is_aug)
return result
def _fill_masks_with_gradient(self, masks):
batch_size, _, height, width = masks.shape
grad = torch.linspace(0, 1, steps=width * 2, device=masks.device, dtype=masks.dtype) \
.view(1, 1, 1, -1).expand(batch_size, 1, height * 2, width * 2)
grad = self.grad_aug(grad)
grad = CenterCrop((height, width))(grad)
grad *= masks
grad_for_min = grad + (1 - masks) * 10
grad -= grad_for_min.view(batch_size, -1).min(-1).values[:, None, None, None]
grad /= grad.view(batch_size, -1).max(-1).values[:, None, None, None] + 1e-6
grad.clamp_(min=0, max=1)
return grad
================================================
FILE: annotator/lama/saicinpainting/training/modules/ffc.py
================================================
# Fast Fourier Convolution NeurIPS 2020
# original implementation https://github.com/pkumivision/FFC/blob/main/model_zoo/ffc.py
# paper https://proceedings.neurips.cc/paper/2020/file/2fd5d41ec6cfab47e32164d5624269b1-Paper.pdf
import numpy as np
import torch
import torch.nn as nn
import torch.nn.functional as F
from annotator.lama.saicinpainting.training.modules.base import get_activation, BaseDiscriminator
from annotator.lama.saicinpainting.training.modules.spatial_transform import LearnableSpatialTransformWrapper
from annotator.lama.saicinpainting.training.modules.squeeze_excitation import SELayer
from annotator.lama.saicinpainting.utils import get_shape
class FFCSE_block(nn.Module):
def __init__(self, channels, ratio_g):
super(FFCSE_block, self).__init__()
in_cg = int(channels * ratio_g)
in_cl = channels - in_cg
r = 16
self.avgpool = nn.AdaptiveAvgPool2d((1, 1))
self.conv1 = nn.Conv2d(channels, channels // r,
kernel_size=1, bias=True)
self.relu1 = nn.ReLU(inplace=True)
self.conv_a2l = None if in_cl == 0 else nn.Conv2d(
channels // r, in_cl, kernel_size=1, bias=True)
self.conv_a2g = None if in_cg == 0 else nn.Conv2d(
channels // r, in_cg, kernel_size=1, bias=True)
self.sigmoid = nn.Sigmoid()
def forward(self, x):
x = x if type(x) is tuple else (x, 0)
id_l, id_g = x
x = id_l if type(id_g) is int else torch.cat([id_l, id_g], dim=1)
x = self.avgpool(x)
x = self.relu1(self.conv1(x))
x_l = 0 if self.conv_a2l is None else id_l * \
self.sigmoid(self.conv_a2l(x))
x_g = 0 if self.conv_a2g is None else id_g * \
self.sigmoid(self.conv_a2g(x))
return x_l, x_g
class FourierUnit(nn.Module):
def __init__(self, in_channels, out_channels, groups=1, spatial_scale_factor=None, spatial_scale_mode='bilinear',
spectral_pos_encoding=False, use_se=False, se_kwargs=None, ffc3d=False, fft_norm='ortho'):
# bn_layer not used
super(FourierUnit, self).__init__()
self.groups = groups
self.conv_layer = torch.nn.Conv2d(in_channels=in_channels * 2 + (2 if spectral_pos_encoding else 0),
out_channels=out_channels * 2,
kernel_size=1, stride=1, padding=0, groups=self.groups, bias=False)
self.bn = torch.nn.BatchNorm2d(out_channels * 2)
self.relu = torch.nn.ReLU(inplace=True)
# squeeze and excitation block
self.use_se = use_se
if use_se:
if se_kwargs is None:
se_kwargs = {}
self.se = SELayer(self.conv_layer.in_channels, **se_kwargs)
self.spatial_scale_factor = spatial_scale_factor
self.spatial_scale_mode = spatial_scale_mode
self.spectral_pos_encoding = spectral_pos_encoding
self.ffc3d = ffc3d
self.fft_norm = fft_norm
def forward(self, x):
batch = x.shape[0]
if self.spatial_scale_factor is not None:
orig_size = x.shape[-2:]
x = F.interpolate(x, scale_factor=self.spatial_scale_factor, mode=self.spatial_scale_mode, align_corners=False)
r_size = x.size()
# (batch, c, h, w/2+1, 2)
fft_dim = (-3, -2, -1) if self.ffc3d else (-2, -1)
ffted = torch.fft.rfftn(x, dim=fft_dim, norm=self.fft_norm)
ffted = torch.stack((ffted.real, ffted.imag), dim=-1)
ffted = ffted.permute(0, 1, 4, 2, 3).contiguous() # (batch, c, 2, h, w/2+1)
ffted = ffted.view((batch, -1,) + ffted.size()[3:])
if self.spectral_pos_encoding:
height, width = ffted.shape[-2:]
coords_vert = torch.linspace(0, 1, height)[None, None, :, None].expand(batch, 1, height, width).to(ffted)
coords_hor = torch.linspace(0, 1, width)[None, None, None, :].expand(batch, 1, height, width).to(ffted)
ffted = torch.cat((coords_vert, coords_hor, ffted), dim=1)
if self.use_se:
ffted = self.se(ffted)
ffted = self.conv_layer(ffted) # (batch, c*2, h, w/2+1)
ffted = self.relu(self.bn(ffted))
ffted = ffted.view((batch, -1, 2,) + ffted.size()[2:]).permute(
0, 1, 3, 4, 2).contiguous() # (batch,c, t, h, w/2+1, 2)
ffted = torch.complex(ffted[..., 0], ffted[..., 1])
ifft_shape_slice = x.shape[-3:] if self.ffc3d else x.shape[-2:]
output = torch.fft.irfftn(ffted, s=ifft_shape_slice, dim=fft_dim, norm=self.fft_norm)
if self.spatial_scale_factor is not None:
output = F.interpolate(output, size=orig_size, mode=self.spatial_scale_mode, align_corners=False)
return output
class SeparableFourierUnit(nn.Module):
def __init__(self, in_channels, out_channels, groups=1, kernel_size=3):
# bn_layer not used
super(SeparableFourierUnit, self).__init__()
self.groups = groups
row_out_channels = out_channels // 2
col_out_channels = out_channels - row_out_channels
self.row_conv = torch.nn.Conv2d(in_channels=in_channels * 2,
out_channels=row_out_channels * 2,
kernel_size=(kernel_size, 1), # kernel size is always like this, but the data will be transposed
stride=1, padding=(kernel_size // 2, 0),
padding_mode='reflect',
groups=self.groups, bias=False)
self.col_conv = torch.nn.Conv2d(in_channels=in_channels * 2,
out_channels=col_out_channels * 2,
kernel_size=(kernel_size, 1), # kernel size is always like this, but the data will be transposed
stride=1, padding=(kernel_size // 2, 0),
padding_mode='reflect',
groups=self.groups, bias=False)
self.row_bn = torch.nn.BatchNorm2d(row_out_channels * 2)
self.col_bn = torch.nn.BatchNorm2d(col_out_channels * 2)
self.relu = torch.nn.ReLU(inplace=True)
def process_branch(self, x, conv, bn):
batch = x.shape[0]
r_size = x.size()
# (batch, c, h, w/2+1, 2)
ffted = torch.fft.rfft(x, norm="ortho")
ffted = torch.stack((ffted.real, ffted.imag), dim=-1)
ffted = ffted.permute(0, 1, 4, 2, 3).contiguous() # (batch, c, 2, h, w/2+1)
ffted = ffted.view((batch, -1,) + ffted.size()[3:])
ffted = self.relu(bn(conv(ffted)))
ffted = ffted.view((batch, -1, 2,) + ffted.size()[2:]).permute(
0, 1, 3, 4, 2).contiguous() # (batch,c, t, h, w/2+1, 2)
ffted = torch.complex(ffted[..., 0], ffted[..., 1])
output = torch.fft.irfft(ffted, s=x.shape[-1:], norm="ortho")
return output
def forward(self, x):
rowwise = self.process_branch(x, self.row_conv, self.row_bn)
colwise = self.process_branch(x.permute(0, 1, 3, 2), self.col_conv, self.col_bn).permute(0, 1, 3, 2)
out = torch.cat((rowwise, colwise), dim=1)
return out
class SpectralTransform(nn.Module):
def __init__(self, in_channels, out_channels, stride=1, groups=1, enable_lfu=True, separable_fu=False, **fu_kwargs):
# bn_layer not used
super(SpectralTransform, self).__init__()
self.enable_lfu = enable_lfu
if stride == 2:
self.downsample = nn.AvgPool2d(kernel_size=(2, 2), stride=2)
else:
self.downsample = nn.Identity()
self.stride = stride
self.conv1 = nn.Sequential(
nn.Conv2d(in_channels, out_channels //
2, kernel_size=1, groups=groups, bias=False),
nn.BatchNorm2d(out_channels // 2),
nn.ReLU(inplace=True)
)
fu_class = SeparableFourierUnit if separable_fu else FourierUnit
self.fu = fu_class(
out_channels // 2, out_channels // 2, groups, **fu_kwargs)
if self.enable_lfu:
self.lfu = fu_class(
out_channels // 2, out_channels // 2, groups)
self.conv2 = torch.nn.Conv2d(
out_channels // 2, out_channels, kernel_size=1, groups=groups, bias=False)
def forward(self, x):
x = self.downsample(x)
x = self.conv1(x)
output = self.fu(x)
if self.enable_lfu:
n, c, h, w = x.shape
split_no = 2
split_s = h // split_no
xs = torch.cat(torch.split(
x[:, :c // 4], split_s, dim=-2), dim=1).contiguous()
xs = torch.cat(torch.split(xs, split_s, dim=-1),
dim=1).contiguous()
xs = self.lfu(xs)
xs = xs.repeat(1, 1, split_no, split_no).contiguous()
else:
xs = 0
output = self.conv2(x + output + xs)
return output
class FFC(nn.Module):
def __init__(self, in_channels, out_channels, kernel_size,
ratio_gin, ratio_gout, stride=1, padding=0,
dilation=1, groups=1, bias=False, enable_lfu=True,
padding_type='reflect', gated=False, **spectral_kwargs):
super(FFC, self).__init__()
assert stride == 1 or stride == 2, "Stride should be 1 or 2."
self.stride = stride
in_cg = int(in_channels * ratio_gin)
in_cl = in_channels - in_cg
out_cg = int(out_channels * ratio_gout)
out_cl = out_channels - out_cg
#groups_g = 1 if groups == 1 else int(groups * ratio_gout)
#groups_l = 1 if groups == 1 else groups - groups_g
self.ratio_gin = ratio_gin
self.ratio_gout = ratio_gout
self.global_in_num = in_cg
module = nn.Identity if in_cl == 0 or out_cl == 0 else nn.Conv2d
self.convl2l = module(in_cl, out_cl, kernel_size,
stride, padding, dilation, groups, bias, padding_mode=padding_type)
module = nn.Identity if in_cl == 0 or out_cg == 0 else nn.Conv2d
self.convl2g = module(in_cl, out_cg, kernel_size,
stride, padding, dilation, groups, bias, padding_mode=padding_type)
module = nn.Identity if in_cg == 0 or out_cl == 0 else nn.Conv2d
self.convg2l = module(in_cg, out_cl, kernel_size,
stride, padding, dilation, groups, bias, padding_mode=padding_type)
module = nn.Identity if in_cg == 0 or out_cg == 0 else SpectralTransform
self.convg2g = module(
in_cg, out_cg, stride, 1 if groups == 1 else groups // 2, enable_lfu, **spectral_kwargs)
self.gated = gated
module = nn.Identity if in_cg == 0 or out_cl == 0 or not self.gated else nn.Conv2d
self.gate = module(in_channels, 2, 1)
def forward(self, x):
x_l, x_g = x if type(x) is tuple else (x, 0)
out_xl, out_xg = 0, 0
if self.gated:
total_input_parts = [x_l]
if torch.is_tensor(x_g):
total_input_parts.append(x_g)
total_input = torch.cat(total_input_parts, dim=1)
gates = torch.sigmoid(self.gate(total_input))
g2l_gate, l2g_gate = gates.chunk(2, dim=1)
else:
g2l_gate, l2g_gate = 1, 1
if self.ratio_gout != 1:
out_xl = self.convl2l(x_l) + self.convg2l(x_g) * g2l_gate
if self.ratio_gout != 0:
out_xg = self.convl2g(x_l) * l2g_gate + self.convg2g(x_g)
return out_xl, out_xg
class FFC_BN_ACT(nn.Module):
def __init__(self, in_channels, out_channels,
kernel_size, ratio_gin, ratio_gout,
stride=1, padding=0, dilation=1, groups=1, bias=False,
norm_layer=nn.BatchNorm2d, activation_layer=nn.Identity,
padding_type='reflect',
enable_lfu=True, **kwargs):
super(FFC_BN_ACT, self).__init__()
self.ffc = FFC(in_channels, out_channels, kernel_size,
ratio_gin, ratio_gout, stride, padding, dilation,
groups, bias, enable_lfu, padding_type=padding_type, **kwargs)
lnorm = nn.Identity if ratio_gout == 1 else norm_layer
gnorm = nn.Identity if ratio_gout == 0 else norm_layer
global_channels = int(out_channels * ratio_gout)
self.bn_l = lnorm(out_channels - global_channels)
self.bn_g = gnorm(global_channels)
lact = nn.Identity if ratio_gout == 1 else activation_layer
gact = nn.Identity if ratio_gout == 0 else activation_layer
self.act_l = lact(inplace=True)
self.act_g = gact(inplace=True)
def forward(self, x):
x_l, x_g = self.ffc(x)
x_l = self.act_l(self.bn_l(x_l))
x_g = self.act_g(self.bn_g(x_g))
return x_l, x_g
class FFCResnetBlock(nn.Module):
def __init__(self, dim, padding_type, norm_layer, activation_layer=nn.ReLU, dilation=1,
spatial_transform_kwargs=None, inline=False, **conv_kwargs):
super().__init__()
self.conv1 = FFC_BN_ACT(dim, dim, kernel_size=3, padding=dilation, dilation=dilation,
norm_layer=norm_layer,
activation_layer=activation_layer,
padding_type=padding_type,
**conv_kwargs)
self.conv2 = FFC_BN_ACT(dim, dim, kernel_size=3, padding=dilation, dilation=dilation,
norm_layer=norm_layer,
activation_layer=activation_layer,
padding_type=padding_type,
**conv_kwargs)
if spatial_transform_kwargs is not None:
self.conv1 = LearnableSpatialTransformWrapper(self.conv1, **spatial_transform_kwargs)
self.conv2 = LearnableSpatialTransformWrapper(self.conv2, **spatial_transform_kwargs)
self.inline = inline
def forward(self, x):
if self.inline:
x_l, x_g = x[:, :-self.conv1.ffc.global_in_num], x[:, -self.conv1.ffc.global_in_num:]
else:
x_l, x_g = x if type(x) is tuple else (x, 0)
id_l, id_g = x_l, x_g
x_l, x_g = self.conv1((x_l, x_g))
x_l, x_g = self.conv2((x_l, x_g))
x_l, x_g = id_l + x_l, id_g + x_g
out = x
gitextract_wjd3xpkj/
├── .github/
│ ├── ISSUE_TEMPLATE/
│ │ ├── bug_report.yml
│ │ └── config.yml
│ └── workflows/
│ ├── lint.yaml
│ └── tests.yml
├── .gitignore
├── LICENSE
├── README.md
├── annotator/
│ ├── __init__.py
│ ├── anime_face_segment/
│ │ ├── LICENSE
│ │ └── __init__.py
│ ├── annotator_path.py
│ ├── binary/
│ │ └── __init__.py
│ ├── canny/
│ │ └── __init__.py
│ ├── clipvision/
│ │ ├── __init__.py
│ │ ├── clip_vision_h_uc.data
│ │ └── clip_vision_vith_uc.data
│ ├── color/
│ │ └── __init__.py
│ ├── densepose/
│ │ ├── __init__.py
│ │ └── densepose.py
│ ├── depth_anything.py
│ ├── depth_anything_v2.py
│ ├── hed/
│ │ └── __init__.py
│ ├── keypose/
│ │ ├── __init__.py
│ │ ├── faster_rcnn_r50_fpn_coco.py
│ │ └── hrnet_w48_coco_256x192.py
│ ├── lama/
│ │ ├── __init__.py
│ │ ├── config.yaml
│ │ └── saicinpainting/
│ │ ├── __init__.py
│ │ ├── training/
│ │ │ ├── __init__.py
│ │ │ ├── data/
│ │ │ │ ├── __init__.py
│ │ │ │ └── masks.py
│ │ │ ├── losses/
│ │ │ │ ├── __init__.py
│ │ │ │ ├── adversarial.py
│ │ │ │ ├── constants.py
│ │ │ │ ├── distance_weighting.py
│ │ │ │ ├── feature_matching.py
│ │ │ │ ├── perceptual.py
│ │ │ │ ├── segmentation.py
│ │ │ │ └── style_loss.py
│ │ │ ├── modules/
│ │ │ │ ├── __init__.py
│ │ │ │ ├── base.py
│ │ │ │ ├── depthwise_sep_conv.py
│ │ │ │ ├── fake_fakes.py
│ │ │ │ ├── ffc.py
│ │ │ │ ├── multidilated_conv.py
│ │ │ │ ├── multiscale.py
│ │ │ │ ├── pix2pixhd.py
│ │ │ │ ├── spatial_transform.py
│ │ │ │ └── squeeze_excitation.py
│ │ │ ├── trainers/
│ │ │ │ ├── __init__.py
│ │ │ │ ├── base.py
│ │ │ │ └── default.py
│ │ │ └── visualizers/
│ │ │ ├── __init__.py
│ │ │ ├── base.py
│ │ │ ├── colors.py
│ │ │ ├── directory.py
│ │ │ └── noop.py
│ │ └── utils.py
│ ├── leres/
│ │ ├── __init__.py
│ │ ├── leres/
│ │ │ ├── LICENSE
│ │ │ ├── Resnet.py
│ │ │ ├── Resnext_torch.py
│ │ │ ├── depthmap.py
│ │ │ ├── multi_depth_model_woauxi.py
│ │ │ ├── net_tools.py
│ │ │ └── network_auxi.py
│ │ └── pix2pix/
│ │ ├── LICENSE
│ │ ├── models/
│ │ │ ├── __init__.py
│ │ │ ├── base_model.py
│ │ │ ├── base_model_hg.py
│ │ │ ├── networks.py
│ │ │ └── pix2pix4depth_model.py
│ │ ├── options/
│ │ │ ├── __init__.py
│ │ │ ├── base_options.py
│ │ │ └── test_options.py
│ │ └── util/
│ │ ├── __init__.py
│ │ ├── get_data.py
│ │ ├── guidedfilter.py
│ │ ├── html.py
│ │ ├── image_pool.py
│ │ ├── util.py
│ │ └── visualizer.py
│ ├── lineart/
│ │ ├── LICENSE
│ │ └── __init__.py
│ ├── lineart_anime/
│ │ ├── LICENSE
│ │ └── __init__.py
│ ├── manga_line/
│ │ ├── LICENSE
│ │ └── __init__.py
│ ├── mediapipe_face/
│ │ ├── __init__.py
│ │ └── mediapipe_face_common.py
│ ├── midas/
│ │ ├── LICENSE
│ │ ├── __init__.py
│ │ ├── api.py
│ │ ├── midas/
│ │ │ ├── __init__.py
│ │ │ ├── base_model.py
│ │ │ ├── blocks.py
│ │ │ ├── dpt_depth.py
│ │ │ ├── midas_net.py
│ │ │ ├── midas_net_custom.py
│ │ │ ├── transforms.py
│ │ │ └── vit.py
│ │ └── utils.py
│ ├── mlsd/
│ │ ├── LICENSE
│ │ ├── __init__.py
│ │ ├── models/
│ │ │ ├── mbv2_mlsd_large.py
│ │ │ └── mbv2_mlsd_tiny.py
│ │ └── utils.py
│ ├── mmpkg/
│ │ ├── mmcv/
│ │ │ ├── __init__.py
│ │ │ ├── arraymisc/
│ │ │ │ ├── __init__.py
│ │ │ │ └── quantization.py
│ │ │ ├── cnn/
│ │ │ │ ├── __init__.py
│ │ │ │ ├── alexnet.py
│ │ │ │ ├── bricks/
│ │ │ │ │ ├── __init__.py
│ │ │ │ │ ├── activation.py
│ │ │ │ │ ├── context_block.py
│ │ │ │ │ ├── conv.py
│ │ │ │ │ ├── conv2d_adaptive_padding.py
│ │ │ │ │ ├── conv_module.py
│ │ │ │ │ ├── conv_ws.py
│ │ │ │ │ ├── depthwise_separable_conv_module.py
│ │ │ │ │ ├── drop.py
│ │ │ │ │ ├── generalized_attention.py
│ │ │ │ │ ├── hsigmoid.py
│ │ │ │ │ ├── hswish.py
│ │ │ │ │ ├── non_local.py
│ │ │ │ │ ├── norm.py
│ │ │ │ │ ├── padding.py
│ │ │ │ │ ├── plugin.py
│ │ │ │ │ ├── registry.py
│ │ │ │ │ ├── scale.py
│ │ │ │ │ ├── swish.py
│ │ │ │ │ ├── transformer.py
│ │ │ │ │ ├── upsample.py
│ │ │ │ │ └── wrappers.py
│ │ │ │ ├── builder.py
│ │ │ │ ├── resnet.py
│ │ │ │ ├── utils/
│ │ │ │ │ ├── __init__.py
│ │ │ │ │ ├── flops_counter.py
│ │ │ │ │ ├── fuse_conv_bn.py
│ │ │ │ │ ├── sync_bn.py
│ │ │ │ │ └── weight_init.py
│ │ │ │ └── vgg.py
│ │ │ ├── engine/
│ │ │ │ ├── __init__.py
│ │ │ │ └── test.py
│ │ │ ├── fileio/
│ │ │ │ ├── __init__.py
│ │ │ │ ├── file_client.py
│ │ │ │ ├── handlers/
│ │ │ │ │ ├── __init__.py
│ │ │ │ │ ├── base.py
│ │ │ │ │ ├── json_handler.py
│ │ │ │ │ ├── pickle_handler.py
│ │ │ │ │ └── yaml_handler.py
│ │ │ │ ├── io.py
│ │ │ │ └── parse.py
│ │ │ ├── image/
│ │ │ │ ├── __init__.py
│ │ │ │ ├── colorspace.py
│ │ │ │ ├── geometric.py
│ │ │ │ ├── io.py
│ │ │ │ ├── misc.py
│ │ │ │ └── photometric.py
│ │ │ ├── model_zoo/
│ │ │ │ ├── deprecated.json
│ │ │ │ ├── mmcls.json
│ │ │ │ └── open_mmlab.json
│ │ │ ├── ops/
│ │ │ │ ├── __init__.py
│ │ │ │ ├── assign_score_withk.py
│ │ │ │ ├── ball_query.py
│ │ │ │ ├── bbox.py
│ │ │ │ ├── border_align.py
│ │ │ │ ├── box_iou_rotated.py
│ │ │ │ ├── carafe.py
│ │ │ │ ├── cc_attention.py
│ │ │ │ ├── contour_expand.py
│ │ │ │ ├── corner_pool.py
│ │ │ │ ├── correlation.py
│ │ │ │ ├── deform_conv.py
│ │ │ │ ├── deform_roi_pool.py
│ │ │ │ ├── deprecated_wrappers.py
│ │ │ │ ├── focal_loss.py
│ │ │ │ ├── furthest_point_sample.py
│ │ │ │ ├── fused_bias_leakyrelu.py
│ │ │ │ ├── gather_points.py
│ │ │ │ ├── group_points.py
│ │ │ │ ├── info.py
│ │ │ │ ├── iou3d.py
│ │ │ │ ├── knn.py
│ │ │ │ ├── masked_conv.py
│ │ │ │ ├── merge_cells.py
│ │ │ │ ├── modulated_deform_conv.py
│ │ │ │ ├── multi_scale_deform_attn.py
│ │ │ │ ├── nms.py
│ │ │ │ ├── pixel_group.py
│ │ │ │ ├── point_sample.py
│ │ │ │ ├── points_in_boxes.py
│ │ │ │ ├── points_sampler.py
│ │ │ │ ├── psa_mask.py
│ │ │ │ ├── roi_align.py
│ │ │ │ ├── roi_align_rotated.py
│ │ │ │ ├── roi_pool.py
│ │ │ │ ├── roiaware_pool3d.py
│ │ │ │ ├── roipoint_pool3d.py
│ │ │ │ ├── saconv.py
│ │ │ │ ├── scatter_points.py
│ │ │ │ ├── sync_bn.py
│ │ │ │ ├── three_interpolate.py
│ │ │ │ ├── three_nn.py
│ │ │ │ ├── tin_shift.py
│ │ │ │ ├── upfirdn2d.py
│ │ │ │ └── voxelize.py
│ │ │ ├── parallel/
│ │ │ │ ├── __init__.py
│ │ │ │ ├── _functions.py
│ │ │ │ ├── collate.py
│ │ │ │ ├── data_container.py
│ │ │ │ ├── data_parallel.py
│ │ │ │ ├── distributed.py
│ │ │ │ ├── distributed_deprecated.py
│ │ │ │ ├── registry.py
│ │ │ │ ├── scatter_gather.py
│ │ │ │ └── utils.py
│ │ │ ├── runner/
│ │ │ │ ├── __init__.py
│ │ │ │ ├── base_module.py
│ │ │ │ ├── base_runner.py
│ │ │ │ ├── builder.py
│ │ │ │ ├── checkpoint.py
│ │ │ │ ├── default_constructor.py
│ │ │ │ ├── dist_utils.py
│ │ │ │ ├── epoch_based_runner.py
│ │ │ │ ├── fp16_utils.py
│ │ │ │ ├── hooks/
│ │ │ │ │ ├── __init__.py
│ │ │ │ │ ├── checkpoint.py
│ │ │ │ │ ├── closure.py
│ │ │ │ │ ├── ema.py
│ │ │ │ │ ├── evaluation.py
│ │ │ │ │ ├── hook.py
│ │ │ │ │ ├── iter_timer.py
│ │ │ │ │ ├── logger/
│ │ │ │ │ │ ├── __init__.py
│ │ │ │ │ │ ├── base.py
│ │ │ │ │ │ ├── dvclive.py
│ │ │ │ │ │ ├── mlflow.py
│ │ │ │ │ │ ├── neptune.py
│ │ │ │ │ │ ├── pavi.py
│ │ │ │ │ │ ├── tensorboard.py
│ │ │ │ │ │ ├── text.py
│ │ │ │ │ │ └── wandb.py
│ │ │ │ │ ├── lr_updater.py
│ │ │ │ │ ├── memory.py
│ │ │ │ │ ├── momentum_updater.py
│ │ │ │ │ ├── optimizer.py
│ │ │ │ │ ├── profiler.py
│ │ │ │ │ ├── sampler_seed.py
│ │ │ │ │ └── sync_buffer.py
│ │ │ │ ├── iter_based_runner.py
│ │ │ │ ├── log_buffer.py
│ │ │ │ ├── optimizer/
│ │ │ │ │ ├── __init__.py
│ │ │ │ │ ├── builder.py
│ │ │ │ │ └── default_constructor.py
│ │ │ │ ├── priority.py
│ │ │ │ └── utils.py
│ │ │ ├── utils/
│ │ │ │ ├── __init__.py
│ │ │ │ ├── config.py
│ │ │ │ ├── env.py
│ │ │ │ ├── ext_loader.py
│ │ │ │ ├── logging.py
│ │ │ │ ├── misc.py
│ │ │ │ ├── parrots_jit.py
│ │ │ │ ├── parrots_wrapper.py
│ │ │ │ ├── path.py
│ │ │ │ ├── progressbar.py
│ │ │ │ ├── registry.py
│ │ │ │ ├── testing.py
│ │ │ │ ├── timer.py
│ │ │ │ ├── trace.py
│ │ │ │ └── version_utils.py
│ │ │ ├── version.py
│ │ │ ├── video/
│ │ │ │ ├── __init__.py
│ │ │ │ ├── io.py
│ │ │ │ ├── optflow.py
│ │ │ │ └── processing.py
│ │ │ └── visualization/
│ │ │ ├── __init__.py
│ │ │ ├── color.py
│ │ │ ├── image.py
│ │ │ └── optflow.py
│ │ └── mmseg/
│ │ ├── apis/
│ │ │ ├── __init__.py
│ │ │ ├── inference.py
│ │ │ ├── test.py
│ │ │ └── train.py
│ │ ├── core/
│ │ │ ├── __init__.py
│ │ │ ├── evaluation/
│ │ │ │ ├── __init__.py
│ │ │ │ ├── class_names.py
│ │ │ │ ├── eval_hooks.py
│ │ │ │ └── metrics.py
│ │ │ ├── seg/
│ │ │ │ ├── __init__.py
│ │ │ │ ├── builder.py
│ │ │ │ └── sampler/
│ │ │ │ ├── __init__.py
│ │ │ │ ├── base_pixel_sampler.py
│ │ │ │ └── ohem_pixel_sampler.py
│ │ │ └── utils/
│ │ │ ├── __init__.py
│ │ │ └── misc.py
│ │ ├── datasets/
│ │ │ ├── __init__.py
│ │ │ ├── ade.py
│ │ │ ├── builder.py
│ │ │ ├── chase_db1.py
│ │ │ ├── cityscapes.py
│ │ │ ├── custom.py
│ │ │ ├── dataset_wrappers.py
│ │ │ ├── drive.py
│ │ │ ├── hrf.py
│ │ │ ├── pascal_context.py
│ │ │ ├── pipelines/
│ │ │ │ ├── __init__.py
│ │ │ │ ├── compose.py
│ │ │ │ ├── formating.py
│ │ │ │ ├── loading.py
│ │ │ │ ├── test_time_aug.py
│ │ │ │ └── transforms.py
│ │ │ ├── stare.py
│ │ │ └── voc.py
│ │ ├── models/
│ │ │ ├── __init__.py
│ │ │ ├── backbones/
│ │ │ │ ├── __init__.py
│ │ │ │ ├── cgnet.py
│ │ │ │ ├── fast_scnn.py
│ │ │ │ ├── hrnet.py
│ │ │ │ ├── mobilenet_v2.py
│ │ │ │ ├── mobilenet_v3.py
│ │ │ │ ├── resnest.py
│ │ │ │ ├── resnet.py
│ │ │ │ ├── resnext.py
│ │ │ │ ├── unet.py
│ │ │ │ └── vit.py
│ │ │ ├── builder.py
│ │ │ ├── decode_heads/
│ │ │ │ ├── __init__.py
│ │ │ │ ├── ann_head.py
│ │ │ │ ├── apc_head.py
│ │ │ │ ├── aspp_head.py
│ │ │ │ ├── cascade_decode_head.py
│ │ │ │ ├── cc_head.py
│ │ │ │ ├── da_head.py
│ │ │ │ ├── decode_head.py
│ │ │ │ ├── dm_head.py
│ │ │ │ ├── dnl_head.py
│ │ │ │ ├── ema_head.py
│ │ │ │ ├── enc_head.py
│ │ │ │ ├── fcn_head.py
│ │ │ │ ├── fpn_head.py
│ │ │ │ ├── gc_head.py
│ │ │ │ ├── lraspp_head.py
│ │ │ │ ├── nl_head.py
│ │ │ │ ├── ocr_head.py
│ │ │ │ ├── point_head.py
│ │ │ │ ├── psa_head.py
│ │ │ │ ├── psp_head.py
│ │ │ │ ├── sep_aspp_head.py
│ │ │ │ ├── sep_fcn_head.py
│ │ │ │ └── uper_head.py
│ │ │ ├── losses/
│ │ │ │ ├── __init__.py
│ │ │ │ ├── accuracy.py
│ │ │ │ ├── cross_entropy_loss.py
│ │ │ │ ├── dice_loss.py
│ │ │ │ ├── lovasz_loss.py
│ │ │ │ └── utils.py
│ │ │ ├── necks/
│ │ │ │ ├── __init__.py
│ │ │ │ ├── fpn.py
│ │ │ │ └── multilevel_neck.py
│ │ │ ├── segmentors/
│ │ │ │ ├── __init__.py
│ │ │ │ ├── base.py
│ │ │ │ ├── cascade_encoder_decoder.py
│ │ │ │ └── encoder_decoder.py
│ │ │ └── utils/
│ │ │ ├── __init__.py
│ │ │ ├── drop.py
│ │ │ ├── inverted_residual.py
│ │ │ ├── make_divisible.py
│ │ │ ├── res_layer.py
│ │ │ ├── se_layer.py
│ │ │ ├── self_attention_block.py
│ │ │ ├── up_conv_block.py
│ │ │ └── weight_init.py
│ │ ├── ops/
│ │ │ ├── __init__.py
│ │ │ ├── encoding.py
│ │ │ └── wrappers.py
│ │ └── utils/
│ │ ├── __init__.py
│ │ ├── collect_env.py
│ │ └── logger.py
│ ├── mobile_sam/
│ │ └── __init__.py
│ ├── normalbae/
│ │ ├── LICENSE
│ │ ├── __init__.py
│ │ └── models/
│ │ ├── NNET.py
│ │ ├── baseline.py
│ │ └── submodules/
│ │ ├── decoder.py
│ │ ├── efficientnet_repo/
│ │ │ ├── .gitignore
│ │ │ ├── BENCHMARK.md
│ │ │ ├── LICENSE
│ │ │ ├── README.md
│ │ │ ├── caffe2_benchmark.py
│ │ │ ├── caffe2_validate.py
│ │ │ ├── geffnet/
│ │ │ │ ├── __init__.py
│ │ │ │ ├── activations/
│ │ │ │ │ ├── __init__.py
│ │ │ │ │ ├── activations.py
│ │ │ │ │ ├── activations_jit.py
│ │ │ │ │ └── activations_me.py
│ │ │ │ ├── config.py
│ │ │ │ ├── conv2d_layers.py
│ │ │ │ ├── efficientnet_builder.py
│ │ │ │ ├── gen_efficientnet.py
│ │ │ │ ├── helpers.py
│ │ │ │ ├── mobilenetv3.py
│ │ │ │ ├── model_factory.py
│ │ │ │ └── version.py
│ │ │ ├── hubconf.py
│ │ │ ├── onnx_export.py
│ │ │ ├── onnx_optimize.py
│ │ │ ├── onnx_to_caffe.py
│ │ │ ├── onnx_validate.py
│ │ │ ├── requirements.txt
│ │ │ ├── setup.py
│ │ │ ├── utils.py
│ │ │ └── validate.py
│ │ ├── encoder.py
│ │ └── submodules.py
│ ├── normaldsine/
│ │ ├── LICENSE
│ │ └── __init__.py
│ ├── oneformer/
│ │ ├── LICENSE
│ │ ├── __init__.py
│ │ ├── api.py
│ │ ├── configs/
│ │ │ ├── ade20k/
│ │ │ │ ├── Base-ADE20K-UnifiedSegmentation.yaml
│ │ │ │ ├── oneformer_R50_bs16_160k.yaml
│ │ │ │ └── oneformer_swin_large_IN21k_384_bs16_160k.yaml
│ │ │ └── coco/
│ │ │ ├── Base-COCO-UnifiedSegmentation.yaml
│ │ │ ├── oneformer_R50_bs16_50ep.yaml
│ │ │ └── oneformer_swin_large_IN21k_384_bs16_100ep.yaml
│ │ ├── detectron2/
│ │ │ ├── __init__.py
│ │ │ ├── checkpoint/
│ │ │ │ ├── __init__.py
│ │ │ │ ├── c2_model_loading.py
│ │ │ │ ├── catalog.py
│ │ │ │ └── detection_checkpoint.py
│ │ │ ├── config/
│ │ │ │ ├── __init__.py
│ │ │ │ ├── compat.py
│ │ │ │ ├── config.py
│ │ │ │ ├── defaults.py
│ │ │ │ ├── instantiate.py
│ │ │ │ └── lazy.py
│ │ │ ├── data/
│ │ │ │ ├── __init__.py
│ │ │ │ ├── benchmark.py
│ │ │ │ ├── build.py
│ │ │ │ ├── catalog.py
│ │ │ │ ├── common.py
│ │ │ │ ├── dataset_mapper.py
│ │ │ │ ├── datasets/
│ │ │ │ │ ├── README.md
│ │ │ │ │ ├── __init__.py
│ │ │ │ │ ├── builtin.py
│ │ │ │ │ ├── builtin_meta.py
│ │ │ │ │ ├── cityscapes.py
│ │ │ │ │ ├── cityscapes_panoptic.py
│ │ │ │ │ ├── coco.py
│ │ │ │ │ ├── coco_panoptic.py
│ │ │ │ │ ├── lvis.py
│ │ │ │ │ ├── lvis_v0_5_categories.py
│ │ │ │ │ ├── lvis_v1_categories.py
│ │ │ │ │ ├── lvis_v1_category_image_count.py
│ │ │ │ │ ├── pascal_voc.py
│ │ │ │ │ └── register_coco.py
│ │ │ │ ├── detection_utils.py
│ │ │ │ ├── samplers/
│ │ │ │ │ ├── __init__.py
│ │ │ │ │ ├── distributed_sampler.py
│ │ │ │ │ └── grouped_batch_sampler.py
│ │ │ │ └── transforms/
│ │ │ │ ├── __init__.py
│ │ │ │ ├── augmentation.py
│ │ │ │ ├── augmentation_impl.py
│ │ │ │ └── transform.py
│ │ │ ├── engine/
│ │ │ │ ├── __init__.py
│ │ │ │ ├── defaults.py
│ │ │ │ ├── hooks.py
│ │ │ │ ├── launch.py
│ │ │ │ └── train_loop.py
│ │ │ ├── evaluation/
│ │ │ │ ├── __init__.py
│ │ │ │ ├── cityscapes_evaluation.py
│ │ │ │ ├── coco_evaluation.py
│ │ │ │ ├── evaluator.py
│ │ │ │ ├── fast_eval_api.py
│ │ │ │ ├── lvis_evaluation.py
│ │ │ │ ├── panoptic_evaluation.py
│ │ │ │ ├── pascal_voc_evaluation.py
│ │ │ │ ├── rotated_coco_evaluation.py
│ │ │ │ ├── sem_seg_evaluation.py
│ │ │ │ └── testing.py
│ │ │ ├── export/
│ │ │ │ ├── README.md
│ │ │ │ ├── __init__.py
│ │ │ │ ├── api.py
│ │ │ │ ├── c10.py
│ │ │ │ ├── caffe2_export.py
│ │ │ │ ├── caffe2_inference.py
│ │ │ │ ├── caffe2_modeling.py
│ │ │ │ ├── caffe2_patch.py
│ │ │ │ ├── flatten.py
│ │ │ │ ├── shared.py
│ │ │ │ ├── torchscript.py
│ │ │ │ └── torchscript_patch.py
│ │ │ ├── layers/
│ │ │ │ ├── __init__.py
│ │ │ │ ├── aspp.py
│ │ │ │ ├── batch_norm.py
│ │ │ │ ├── blocks.py
│ │ │ │ ├── csrc/
│ │ │ │ │ ├── README.md
│ │ │ │ │ ├── ROIAlignRotated/
│ │ │ │ │ │ ├── ROIAlignRotated.h
│ │ │ │ │ │ ├── ROIAlignRotated_cpu.cpp
│ │ │ │ │ │ └── ROIAlignRotated_cuda.cu
│ │ │ │ │ ├── box_iou_rotated/
│ │ │ │ │ │ ├── box_iou_rotated.h
│ │ │ │ │ │ ├── box_iou_rotated_cpu.cpp
│ │ │ │ │ │ ├── box_iou_rotated_cuda.cu
│ │ │ │ │ │ └── box_iou_rotated_utils.h
│ │ │ │ │ ├── cocoeval/
│ │ │ │ │ │ ├── cocoeval.cpp
│ │ │ │ │ │ └── cocoeval.h
│ │ │ │ │ ├── cuda_version.cu
│ │ │ │ │ ├── deformable/
│ │ │ │ │ │ ├── deform_conv.h
│ │ │ │ │ │ ├── deform_conv_cuda.cu
│ │ │ │ │ │ └── deform_conv_cuda_kernel.cu
│ │ │ │ │ ├── nms_rotated/
│ │ │ │ │ │ ├── nms_rotated.h
│ │ │ │ │ │ ├── nms_rotated_cpu.cpp
│ │ │ │ │ │ └── nms_rotated_cuda.cu
│ │ │ │ │ └── vision.cpp
│ │ │ │ ├── deform_conv.py
│ │ │ │ ├── losses.py
│ │ │ │ ├── mask_ops.py
│ │ │ │ ├── nms.py
│ │ │ │ ├── roi_align.py
│ │ │ │ ├── roi_align_rotated.py
│ │ │ │ ├── rotated_boxes.py
│ │ │ │ ├── shape_spec.py
│ │ │ │ └── wrappers.py
│ │ │ ├── model_zoo/
│ │ │ │ ├── __init__.py
│ │ │ │ └── model_zoo.py
│ │ │ ├── modeling/
│ │ │ │ ├── __init__.py
│ │ │ │ ├── anchor_generator.py
│ │ │ │ ├── backbone/
│ │ │ │ │ ├── __init__.py
│ │ │ │ │ ├── backbone.py
│ │ │ │ │ ├── build.py
│ │ │ │ │ ├── fpn.py
│ │ │ │ │ ├── mvit.py
│ │ │ │ │ ├── regnet.py
│ │ │ │ │ ├── resnet.py
│ │ │ │ │ ├── swin.py
│ │ │ │ │ ├── utils.py
│ │ │ │ │ └── vit.py
│ │ │ │ ├── box_regression.py
│ │ │ │ ├── matcher.py
│ │ │ │ ├── meta_arch/
│ │ │ │ │ ├── __init__.py
│ │ │ │ │ ├── build.py
│ │ │ │ │ ├── dense_detector.py
│ │ │ │ │ ├── fcos.py
│ │ │ │ │ ├── panoptic_fpn.py
│ │ │ │ │ ├── rcnn.py
│ │ │ │ │ ├── retinanet.py
│ │ │ │ │ └── semantic_seg.py
│ │ │ │ ├── mmdet_wrapper.py
│ │ │ │ ├── poolers.py
│ │ │ │ ├── postprocessing.py
│ │ │ │ ├── proposal_generator/
│ │ │ │ │ ├── __init__.py
│ │ │ │ │ ├── build.py
│ │ │ │ │ ├── proposal_utils.py
│ │ │ │ │ ├── rpn.py
│ │ │ │ │ └── rrpn.py
│ │ │ │ ├── roi_heads/
│ │ │ │ │ ├── __init__.py
│ │ │ │ │ ├── box_head.py
│ │ │ │ │ ├── cascade_rcnn.py
│ │ │ │ │ ├── fast_rcnn.py
│ │ │ │ │ ├── keypoint_head.py
│ │ │ │ │ ├── mask_head.py
│ │ │ │ │ ├── roi_heads.py
│ │ │ │ │ └── rotated_fast_rcnn.py
│ │ │ │ ├── sampling.py
│ │ │ │ └── test_time_augmentation.py
│ │ │ ├── projects/
│ │ │ │ ├── README.md
│ │ │ │ ├── __init__.py
│ │ │ │ └── deeplab/
│ │ │ │ ├── __init__.py
│ │ │ │ ├── build_solver.py
│ │ │ │ ├── config.py
│ │ │ │ ├── loss.py
│ │ │ │ ├── lr_scheduler.py
│ │ │ │ ├── resnet.py
│ │ │ │ └── semantic_seg.py
│ │ │ ├── solver/
│ │ │ │ ├── __init__.py
│ │ │ │ ├── build.py
│ │ │ │ └── lr_scheduler.py
│ │ │ ├── structures/
│ │ │ │ ├── __init__.py
│ │ │ │ ├── boxes.py
│ │ │ │ ├── image_list.py
│ │ │ │ ├── instances.py
│ │ │ │ ├── keypoints.py
│ │ │ │ ├── masks.py
│ │ │ │ └── rotated_boxes.py
│ │ │ ├── tracking/
│ │ │ │ ├── __init__.py
│ │ │ │ ├── base_tracker.py
│ │ │ │ ├── bbox_iou_tracker.py
│ │ │ │ ├── hungarian_tracker.py
│ │ │ │ ├── iou_weighted_hungarian_bbox_iou_tracker.py
│ │ │ │ ├── utils.py
│ │ │ │ └── vanilla_hungarian_bbox_iou_tracker.py
│ │ │ └── utils/
│ │ │ ├── README.md
│ │ │ ├── __init__.py
│ │ │ ├── analysis.py
│ │ │ ├── collect_env.py
│ │ │ ├── colormap.py
│ │ │ ├── comm.py
│ │ │ ├── develop.py
│ │ │ ├── env.py
│ │ │ ├── events.py
│ │ │ ├── file_io.py
│ │ │ ├── logger.py
│ │ │ ├── memory.py
│ │ │ ├── registry.py
│ │ │ ├── serialize.py
│ │ │ ├── testing.py
│ │ │ ├── tracing.py
│ │ │ ├── video_visualizer.py
│ │ │ └── visualizer.py
│ │ ├── oneformer/
│ │ │ ├── __init__.py
│ │ │ ├── config.py
│ │ │ ├── data/
│ │ │ │ ├── __init__.py
│ │ │ │ ├── build.py
│ │ │ │ ├── dataset_mappers/
│ │ │ │ │ ├── __init__.py
│ │ │ │ │ ├── coco_unified_new_baseline_dataset_mapper.py
│ │ │ │ │ ├── dataset_mapper.py
│ │ │ │ │ └── oneformer_unified_dataset_mapper.py
│ │ │ │ ├── datasets/
│ │ │ │ │ ├── __init__.py
│ │ │ │ │ ├── register_ade20k_instance.py
│ │ │ │ │ ├── register_ade20k_panoptic.py
│ │ │ │ │ ├── register_cityscapes_panoptic.py
│ │ │ │ │ ├── register_coco_panoptic2instance.py
│ │ │ │ │ └── register_coco_panoptic_annos_semseg.py
│ │ │ │ └── tokenizer.py
│ │ │ ├── demo/
│ │ │ │ ├── colormap.py
│ │ │ │ ├── defaults.py
│ │ │ │ ├── predictor.py
│ │ │ │ └── visualizer.py
│ │ │ ├── evaluation/
│ │ │ │ ├── __init__.py
│ │ │ │ ├── cityscapes_evaluation.py
│ │ │ │ ├── coco_evaluator.py
│ │ │ │ ├── detection_coco_evaluator.py
│ │ │ │ ├── evaluator.py
│ │ │ │ └── instance_evaluation.py
│ │ │ ├── modeling/
│ │ │ │ ├── __init__.py
│ │ │ │ ├── backbone/
│ │ │ │ │ ├── __init__.py
│ │ │ │ │ ├── dinat.py
│ │ │ │ │ └── swin.py
│ │ │ │ ├── matcher.py
│ │ │ │ ├── meta_arch/
│ │ │ │ │ ├── __init__.py
│ │ │ │ │ └── oneformer_head.py
│ │ │ │ ├── pixel_decoder/
│ │ │ │ │ ├── __init__.py
│ │ │ │ │ ├── fpn.py
│ │ │ │ │ ├── msdeformattn.py
│ │ │ │ │ └── ops/
│ │ │ │ │ ├── functions/
│ │ │ │ │ │ ├── __init__.py
│ │ │ │ │ │ └── ms_deform_attn_func.py
│ │ │ │ │ ├── make.sh
│ │ │ │ │ ├── modules/
│ │ │ │ │ │ ├── __init__.py
│ │ │ │ │ │ └── ms_deform_attn.py
│ │ │ │ │ ├── setup.py
│ │ │ │ │ ├── src/
│ │ │ │ │ │ ├── cpu/
│ │ │ │ │ │ │ ├── ms_deform_attn_cpu.cpp
│ │ │ │ │ │ │ └── ms_deform_attn_cpu.h
│ │ │ │ │ │ ├── cuda/
│ │ │ │ │ │ │ ├── ms_deform_attn_cuda.cu
│ │ │ │ │ │ │ ├── ms_deform_attn_cuda.h
│ │ │ │ │ │ │ └── ms_deform_im2col_cuda.cuh
│ │ │ │ │ │ ├── ms_deform_attn.h
│ │ │ │ │ │ └── vision.cpp
│ │ │ │ │ └── test.py
│ │ │ │ └── transformer_decoder/
│ │ │ │ ├── __init__.py
│ │ │ │ ├── oneformer_transformer_decoder.py
│ │ │ │ ├── position_encoding.py
│ │ │ │ ├── text_transformer.py
│ │ │ │ └── transformer.py
│ │ │ ├── oneformer_model.py
│ │ │ └── utils/
│ │ │ ├── __init__.py
│ │ │ ├── box_ops.py
│ │ │ ├── events.py
│ │ │ ├── misc.py
│ │ │ └── pos_embed.py
│ │ └── pycocotools/
│ │ ├── __init__.py
│ │ ├── coco.py
│ │ ├── cocoeval.py
│ │ └── mask.py
│ ├── openpose/
│ │ ├── LICENSE
│ │ ├── __init__.py
│ │ ├── animalpose.py
│ │ ├── body.py
│ │ ├── cv_ox_det.py
│ │ ├── cv_ox_pose.py
│ │ ├── face.py
│ │ ├── hand.py
│ │ ├── model.py
│ │ ├── types.py
│ │ ├── util.py
│ │ └── wholebody.py
│ ├── pidinet/
│ │ ├── LICENSE
│ │ ├── __init__.py
│ │ └── model.py
│ ├── shuffle/
│ │ └── __init__.py
│ ├── teed/
│ │ ├── Fmish.py
│ │ ├── Fsmish.py
│ │ ├── LICENSE.txt
│ │ ├── Xmish.py
│ │ ├── Xsmish.py
│ │ ├── __init__.py
│ │ └── ted.py
│ ├── uniformer/
│ │ ├── LICENSE
│ │ ├── __init__.py
│ │ ├── configs/
│ │ │ └── _base_/
│ │ │ ├── datasets/
│ │ │ │ ├── ade20k.py
│ │ │ │ ├── chase_db1.py
│ │ │ │ ├── cityscapes.py
│ │ │ │ ├── cityscapes_769x769.py
│ │ │ │ ├── drive.py
│ │ │ │ ├── hrf.py
│ │ │ │ ├── pascal_context.py
│ │ │ │ ├── pascal_context_59.py
│ │ │ │ ├── pascal_voc12.py
│ │ │ │ ├── pascal_voc12_aug.py
│ │ │ │ └── stare.py
│ │ │ ├── default_runtime.py
│ │ │ ├── models/
│ │ │ │ ├── ann_r50-d8.py
│ │ │ │ ├── apcnet_r50-d8.py
│ │ │ │ ├── ccnet_r50-d8.py
│ │ │ │ ├── cgnet.py
│ │ │ │ ├── danet_r50-d8.py
│ │ │ │ ├── deeplabv3_r50-d8.py
│ │ │ │ ├── deeplabv3_unet_s5-d16.py
│ │ │ │ ├── deeplabv3plus_r50-d8.py
│ │ │ │ ├── dmnet_r50-d8.py
│ │ │ │ ├── dnl_r50-d8.py
│ │ │ │ ├── emanet_r50-d8.py
│ │ │ │ ├── encnet_r50-d8.py
│ │ │ │ ├── fast_scnn.py
│ │ │ │ ├── fcn_hr18.py
│ │ │ │ ├── fcn_r50-d8.py
│ │ │ │ ├── fcn_unet_s5-d16.py
│ │ │ │ ├── fpn_r50.py
│ │ │ │ ├── fpn_uniformer.py
│ │ │ │ ├── gcnet_r50-d8.py
│ │ │ │ ├── lraspp_m-v3-d8.py
│ │ │ │ ├── nonlocal_r50-d8.py
│ │ │ │ ├── ocrnet_hr18.py
│ │ │ │ ├── ocrnet_r50-d8.py
│ │ │ │ ├── pointrend_r50.py
│ │ │ │ ├── psanet_r50-d8.py
│ │ │ │ ├── pspnet_r50-d8.py
│ │ │ │ ├── pspnet_unet_s5-d16.py
│ │ │ │ ├── upernet_r50.py
│ │ │ │ └── upernet_uniformer.py
│ │ │ └── schedules/
│ │ │ ├── schedule_160k.py
│ │ │ ├── schedule_20k.py
│ │ │ ├── schedule_40k.py
│ │ │ └── schedule_80k.py
│ │ ├── inference.py
│ │ ├── mmcv_custom/
│ │ │ ├── __init__.py
│ │ │ └── checkpoint.py
│ │ ├── uniformer.py
│ │ └── upernet_global_small.py
│ ├── util.py
│ └── zoe/
│ ├── LICENSE
│ ├── __init__.py
│ └── zoedepth/
│ ├── models/
│ │ ├── __init__.py
│ │ ├── base_models/
│ │ │ ├── __init__.py
│ │ │ ├── midas.py
│ │ │ └── midas_repo/
│ │ │ ├── .gitignore
│ │ │ ├── Dockerfile
│ │ │ ├── LICENSE
│ │ │ ├── README.md
│ │ │ ├── environment.yaml
│ │ │ ├── hubconf.py
│ │ │ ├── input/
│ │ │ │ └── .placeholder
│ │ │ ├── midas/
│ │ │ │ ├── backbones/
│ │ │ │ │ ├── beit.py
│ │ │ │ │ ├── levit.py
│ │ │ │ │ ├── next_vit.py
│ │ │ │ │ ├── swin.py
│ │ │ │ │ ├── swin2.py
│ │ │ │ │ ├── swin_common.py
│ │ │ │ │ ├── utils.py
│ │ │ │ │ └── vit.py
│ │ │ │ ├── base_model.py
│ │ │ │ ├── blocks.py
│ │ │ │ ├── dpt_depth.py
│ │ │ │ ├── midas_net.py
│ │ │ │ ├── midas_net_custom.py
│ │ │ │ ├── model_loader.py
│ │ │ │ └── transforms.py
│ │ │ ├── output/
│ │ │ │ └── .placeholder
│ │ │ ├── ros/
│ │ │ │ ├── LICENSE
│ │ │ │ ├── README.md
│ │ │ │ ├── additions/
│ │ │ │ │ ├── do_catkin_make.sh
│ │ │ │ │ ├── downloads.sh
│ │ │ │ │ ├── install_ros_melodic_ubuntu_17_18.sh
│ │ │ │ │ ├── install_ros_noetic_ubuntu_20.sh
│ │ │ │ │ └── make_package_cpp.sh
│ │ │ │ ├── launch_midas_cpp.sh
│ │ │ │ ├── midas_cpp/
│ │ │ │ │ ├── CMakeLists.txt
│ │ │ │ │ ├── launch/
│ │ │ │ │ │ ├── midas_cpp.launch
│ │ │ │ │ │ └── midas_talker_listener.launch
│ │ │ │ │ ├── package.xml
│ │ │ │ │ ├── scripts/
│ │ │ │ │ │ ├── listener.py
│ │ │ │ │ │ ├── listener_original.py
│ │ │ │ │ │ └── talker.py
│ │ │ │ │ └── src/
│ │ │ │ │ └── main.cpp
│ │ │ │ └── run_talker_listener_test.sh
│ │ │ ├── run.py
│ │ │ ├── tf/
│ │ │ │ ├── README.md
│ │ │ │ ├── input/
│ │ │ │ │ └── .placeholder
│ │ │ │ ├── make_onnx_model.py
│ │ │ │ ├── output/
│ │ │ │ │ └── .placeholder
│ │ │ │ ├── run_onnx.py
│ │ │ │ ├── run_pb.py
│ │ │ │ ├── transforms.py
│ │ │ │ └── utils.py
│ │ │ ├── utils.py
│ │ │ └── weights/
│ │ │ └── .placeholder
│ │ ├── builder.py
│ │ ├── depth_model.py
│ │ ├── layers/
│ │ │ ├── attractor.py
│ │ │ ├── dist_layers.py
│ │ │ ├── localbins_layers.py
│ │ │ └── patch_transformer.py
│ │ ├── model_io.py
│ │ ├── zoedepth/
│ │ │ ├── __init__.py
│ │ │ ├── config_zoedepth.json
│ │ │ ├── config_zoedepth_kitti.json
│ │ │ └── zoedepth_v1.py
│ │ └── zoedepth_nk/
│ │ ├── __init__.py
│ │ ├── config_zoedepth_nk.json
│ │ └── zoedepth_nk_v1.py
│ └── utils/
│ ├── __init__.py
│ ├── arg_utils.py
│ ├── config.py
│ ├── easydict/
│ │ └── __init__.py
│ ├── geometry.py
│ └── misc.py
├── example/
│ ├── advanced_weighting_example/
│ │ └── api_advanced_weighting.py
│ ├── chatgpt.py
│ ├── inpaint_example/
│ │ └── api_inpaint.py
│ ├── txt2img_example/
│ │ └── api_txt2img.py
│ └── visual_chatgpt.ipynb
├── extract_controlnet.py
├── extract_controlnet_diff.py
├── install.py
├── internal_controlnet/
│ ├── __init__.py
│ ├── args.py
│ └── external_code.py
├── javascript/
│ ├── canvas.js
│ ├── controlnet_unit.mjs
│ ├── index.mjs
│ ├── modal.mjs
│ ├── openpose_editor.mjs
│ └── photopea.mjs
├── models/
│ └── put_controlnet_models_here.txt
├── patch_version.py
├── preload.py
├── pyproject.toml
├── requirements.txt
├── scripts/
│ ├── adapter.py
│ ├── animate_diff/
│ │ └── batch.py
│ ├── api.py
│ ├── batch_hijack.py
│ ├── cldm.py
│ ├── controlnet.py
│ ├── controlnet_core/
│ │ └── controlnet_union.py
│ ├── controlnet_diffusers.py
│ ├── controlnet_lllite.py
│ ├── controlnet_lora.py
│ ├── controlnet_model_guess.py
│ ├── controlnet_sparsectrl.py
│ ├── controlnet_ui/
│ │ ├── advanced_weight_control.py
│ │ ├── controlnet_ui_group.py
│ │ ├── modal.py
│ │ ├── openpose_editor.py
│ │ └── photopea.py
│ ├── controlnet_version.py
│ ├── enums.py
│ ├── external_code.py
│ ├── global_state.py
│ ├── hook.py
│ ├── infotext.py
│ ├── ipadapter/
│ │ ├── __init__.py
│ │ ├── image_proj_models.py
│ │ ├── ipadapter_model.py
│ │ ├── plugable_ipadapter.py
│ │ ├── presets.py
│ │ ├── pulid_attn.py
│ │ └── weight.py
│ ├── logging.py
│ ├── lvminthin.py
│ ├── movie2movie.py
│ ├── preprocessor/
│ │ ├── __init__.py
│ │ ├── inpaint.py
│ │ ├── ip_adapter_auto.py
│ │ ├── lama_inpaint.py
│ │ ├── legacy/
│ │ │ ├── legacy_preprocessors.py
│ │ │ ├── preprocessor_compiled.py
│ │ │ └── processor.py
│ │ ├── mobile_sam.py
│ │ ├── model_free_preprocessors.py
│ │ ├── normal_dsine.py
│ │ ├── pulid.py
│ │ └── teed.py
│ ├── supported_preprocessor.py
│ ├── utils.py
│ └── xyz_grid_support.py
├── style.css
├── tests/
│ ├── README.md
│ ├── annotator_tests/
│ │ └── openpose_tests/
│ │ ├── body_test.py
│ │ ├── detection_test.py
│ │ ├── json_encode_test.py
│ │ └── openpose_e2e_test_disabled.py
│ ├── cn_script/
│ │ ├── __init__.py
│ │ ├── batch_hijack_test.py
│ │ ├── cn_script_test.py
│ │ └── utils_test.py
│ ├── conftest.py
│ ├── external_code_api/
│ │ ├── __init__.py
│ │ └── external_code_test.py
│ ├── utils.py
│ └── web_api/
│ ├── __init__.py
│ ├── animal_pose.json
│ ├── clip_mask_test.py
│ ├── detect_test.py
│ ├── effective_region_test.py
│ ├── full_coverage/
│ │ ├── README.md
│ │ ├── __init__.py
│ │ ├── depth_test.py
│ │ ├── inpaint_test.py
│ │ ├── ipadapter_test.py
│ │ └── template.py
│ ├── generation_test.py
│ ├── ipadapter_advanced_weighting.py
│ ├── ipadapter_clip_api.py
│ ├── modules_test.py
│ ├── pose.json
│ ├── render_openpose_json.py
│ └── template.py
├── unit_tests/
│ ├── __init__.py
│ └── args_test.py
└── web_tests/
├── README.md
└── main.py
Showing preview only (529K chars total). Download the full file or copy to clipboard to get everything.
SYMBOL INDEX (6571 symbols across 680 files)
FILE: annotator/anime_face_segment/__init__.py
class UNet (line 29) | class UNet(nn.Module):
method __init__ (line 30) | def __init__(self):
method forward (line 102) | def forward(self, x):
class AnimeFaceSegment (line 129) | class AnimeFaceSegment:
method __init__ (line 133) | def __init__(self):
method load_model (line 137) | def load_model(self):
method unload_model (line 153) | def unload_model(self):
method __call__ (line 157) | def __call__(self, input_image):
FILE: annotator/binary/__init__.py
function apply_binary (line 4) | def apply_binary(img, bin_threshold):
FILE: annotator/canny/__init__.py
function apply_canny (line 4) | def apply_canny(img, low_threshold, high_threshold):
FILE: annotator/clipvision/__init__.py
class ClipVisionDetector (line 94) | class ClipVisionDetector:
method __init__ (line 95) | def __init__(self, config, low_vram: bool):
method unload_model (line 127) | def unload_model(self):
method __call__ (line 131) | def __call__(self, input_image: np.ndarray):
FILE: annotator/color/__init__.py
function cv2_resize_shortest_edge (line 3) | def cv2_resize_shortest_edge(image, size):
function apply_color (line 14) | def apply_color(img, res=512):
FILE: annotator/densepose/__init__.py
function apply_densepose (line 22) | def apply_densepose(input_image, cmap="viridis"):
function unload_model (line 54) | def unload_model():
FILE: annotator/densepose/densepose.py
class BoxMode (line 17) | class BoxMode(IntEnum):
method convert (line 48) | def convert(box: _RawBoxType, from_mode: "BoxMode", to_mode: "BoxMode"...
class MatrixVisualizer (line 133) | class MatrixVisualizer:
method __init__ (line 138) | def __init__(
method visualize (line 154) | def visualize(self, image_bgr, mask, matrix, bbox_xywh):
method _resize (line 181) | def _resize(self, mask, matrix, w, h):
method _check_image (line 188) | def _check_image(self, image_rgb):
method _check_mask_matrix (line 193) | def _check_mask_matrix(self, mask, matrix):
class DensePoseResultsVisualizer (line 198) | class DensePoseResultsVisualizer:
method visualize (line 199) | def visualize(
method create_visualization_context (line 214) | def create_visualization_context(self, image_bgr: Image):
method visualize_iuv_arr (line 217) | def visualize_iuv_arr(self, context, iuv_arr: np.ndarray, bbox_xywh) -...
method context_to_image_bgr (line 220) | def context_to_image_bgr(self, context):
method get_image_bgr_from_context (line 223) | def get_image_bgr_from_context(self, context):
class DensePoseMaskedColormapResultsVisualizer (line 226) | class DensePoseMaskedColormapResultsVisualizer(DensePoseResultsVisualizer):
method __init__ (line 227) | def __init__(
method context_to_image_bgr (line 243) | def context_to_image_bgr(self, context):
method visualize_iuv_arr (line 246) | def visualize_iuv_arr(self, context, iuv_arr: np.ndarray, bbox_xywh) -...
function _extract_i_from_iuvarr (line 255) | def _extract_i_from_iuvarr(iuv_arr):
function _extract_u_from_iuvarr (line 259) | def _extract_u_from_iuvarr(iuv_arr):
function _extract_v_from_iuvarr (line 263) | def _extract_v_from_iuvarr(iuv_arr):
function make_int_box (line 266) | def make_int_box(box: torch.Tensor) -> IntTupleBox:
function densepose_chart_predictor_output_to_result_with_confidences (line 271) | def densepose_chart_predictor_output_to_result_with_confidences(
function resample_fine_and_coarse_segm_tensors_to_bbox (line 287) | def resample_fine_and_coarse_segm_tensors_to_bbox(
function resample_uv_tensors_to_bbox (line 319) | def resample_uv_tensors_to_bbox(
FILE: annotator/depth_anything.py
class DepthAnythingDetector (line 31) | class DepthAnythingDetector:
method __init__ (line 36) | def __init__(self, device: torch.device):
method __call__ (line 57) | def __call__(self, image: np.ndarray, colored: bool = True) -> np.ndar...
method unload_model (line 78) | def unload_model(self):
FILE: annotator/depth_anything_v2.py
class DepthAnythingV2Detector (line 30) | class DepthAnythingV2Detector:
method __init__ (line 35) | def __init__(self, device: torch.device):
method __call__ (line 55) | def __call__(self, image: np.ndarray, colored: bool = True) -> np.ndar...
method unload_model (line 77) | def unload_model(self):
FILE: annotator/hed/__init__.py
class DoubleConvBlock (line 20) | class DoubleConvBlock(torch.nn.Module):
method __init__ (line 21) | def __init__(self, input_channel, output_channel, layer_number):
method __call__ (line 29) | def __call__(self, x, down_sampling=False):
class ControlNetHED_Apache2 (line 39) | class ControlNetHED_Apache2(torch.nn.Module):
method __init__ (line 40) | def __init__(self):
method __call__ (line 49) | def __call__(self, x):
function apply_hed (line 65) | def apply_hed(input_image, is_safe=False):
function unload_hed_model (line 95) | def unload_hed_model():
FILE: annotator/keypose/__init__.py
function preprocessing (line 15) | def preprocessing(image, device):
function imshow_keypoints (line 38) | def imshow_keypoints(img,
function find_download_model (line 143) | def find_download_model(checkpoint, remote_path):
function apply_keypose (line 155) | def apply_keypose(input_image):
function unload_hed_model (line 209) | def unload_hed_model():
FILE: annotator/lama/__init__.py
class LamaInpainting (line 15) | class LamaInpainting:
method __init__ (line 18) | def __init__(self):
method load_model (line 22) | def load_model(self):
method unload_model (line 37) | def unload_model(self):
method __call__ (line 41) | def __call__(self, input_image):
FILE: annotator/lama/saicinpainting/training/data/masks.py
class DrawMethod (line 16) | class DrawMethod(Enum):
function make_random_irregular_mask (line 22) | def make_random_irregular_mask(shape, max_angle=4, max_len=60, max_width...
class RandomIrregularMaskGenerator (line 51) | class RandomIrregularMaskGenerator:
method __init__ (line 52) | def __init__(self, max_angle=4, max_len=60, max_width=20, min_times=0,...
method __call__ (line 62) | def __call__(self, img, iter_i=None, raw_image=None):
function make_random_rectangle_mask (line 72) | def make_random_rectangle_mask(shape, margin=10, bbox_min_size=30, bbox_...
class RandomRectangleMaskGenerator (line 86) | class RandomRectangleMaskGenerator:
method __init__ (line 87) | def __init__(self, margin=10, bbox_min_size=30, bbox_max_size=100, min...
method __call__ (line 95) | def __call__(self, img, iter_i=None, raw_image=None):
class RandomSegmentationMaskGenerator (line 104) | class RandomSegmentationMaskGenerator:
method __init__ (line 105) | def __init__(self, **kwargs):
method __call__ (line 109) | def __call__(self, img, iter_i=None, raw_image=None):
function make_random_superres_mask (line 118) | def make_random_superres_mask(shape, min_step=2, max_step=4, min_width=1...
class RandomSuperresMaskGenerator (line 136) | class RandomSuperresMaskGenerator:
method __init__ (line 137) | def __init__(self, **kwargs):
method __call__ (line 140) | def __call__(self, img, iter_i=None):
class DumbAreaMaskGenerator (line 144) | class DumbAreaMaskGenerator:
method __init__ (line 149) | def __init__(self, is_training):
method _random_vector (line 154) | def _random_vector(self, dimension):
method __call__ (line 167) | def __call__(self, img, iter_i=None, raw_image=None):
class OutpaintingMaskGenerator (line 176) | class OutpaintingMaskGenerator:
method __init__ (line 177) | def __init__(self, min_padding_percent:float=0.04, max_padding_percent...
method apply_padding (line 195) | def apply_padding(self, mask, coord):
method get_padding (line 200) | def get_padding(self, size):
method _img2rs (line 206) | def _img2rs(img):
method __call__ (line 212) | def __call__(self, img, iter_i=None, raw_image=None):
class MixedMaskGenerator (line 252) | class MixedMaskGenerator:
method __init__ (line 253) | def __init__(self, irregular_proba=1/3, irregular_kwargs=None,
method __call__ (line 309) | def __call__(self, img, iter_i=None, raw_image=None):
function get_mask_generator (line 318) | def get_mask_generator(kind, kwargs):
FILE: annotator/lama/saicinpainting/training/losses/adversarial.py
class BaseAdversarialLoss (line 8) | class BaseAdversarialLoss:
method pre_generator_step (line 9) | def pre_generator_step(self, real_batch: torch.Tensor, fake_batch: tor...
method pre_discriminator_step (line 20) | def pre_discriminator_step(self, real_batch: torch.Tensor, fake_batch:...
method generator_loss (line 31) | def generator_loss(self, real_batch: torch.Tensor, fake_batch: torch.T...
method discriminator_loss (line 46) | def discriminator_loss(self, real_batch: torch.Tensor, fake_batch: tor...
method interpolate_mask (line 61) | def interpolate_mask(self, mask, shape):
function make_r1_gp (line 71) | def make_r1_gp(discr_real_pred, real_batch):
class NonSaturatingWithR1 (line 81) | class NonSaturatingWithR1(BaseAdversarialLoss):
method __init__ (line 82) | def __init__(self, gp_coef=5, weight=1, mask_as_fake_target=False, all...
method generator_loss (line 101) | def generator_loss(self, real_batch: torch.Tensor, fake_batch: torch.T...
method pre_discriminator_step (line 117) | def pre_discriminator_step(self, real_batch: torch.Tensor, fake_batch:...
method discriminator_loss (line 121) | def discriminator_loss(self, real_batch: torch.Tensor, fake_batch: tor...
class BCELoss (line 145) | class BCELoss(BaseAdversarialLoss):
method __init__ (line 146) | def __init__(self, weight):
method generator_loss (line 150) | def generator_loss(self, discr_fake_pred: torch.Tensor) -> Tuple[torch...
method pre_discriminator_step (line 155) | def pre_discriminator_step(self, real_batch: torch.Tensor, fake_batch:...
method discriminator_loss (line 159) | def discriminator_loss(self,
function make_discrim_loss (line 172) | def make_discrim_loss(kind, **kwargs):
FILE: annotator/lama/saicinpainting/training/losses/distance_weighting.py
function dummy_distance_weighter (line 9) | def dummy_distance_weighter(real_img, pred_img, mask):
function get_gauss_kernel (line 13) | def get_gauss_kernel(kernel_size, width_factor=1):
class BlurMask (line 22) | class BlurMask(nn.Module):
method __init__ (line 23) | def __init__(self, kernel_size=5, width_factor=1):
method forward (line 28) | def forward(self, real_img, pred_img, mask):
class EmulatedEDTMask (line 34) | class EmulatedEDTMask(nn.Module):
method __init__ (line 35) | def __init__(self, dilate_kernel_size=5, blur_kernel_size=5, width_fac...
method forward (line 43) | def forward(self, real_img, pred_img, mask):
class PropagatePerceptualSim (line 51) | class PropagatePerceptualSim(nn.Module):
method __init__ (line 52) | def __init__(self, level=2, max_iters=10, temperature=500, erode_mask_...
method forward (line 82) | def forward(self, real_img, pred_img, mask):
function make_mask_distance_weighter (line 117) | def make_mask_distance_weighter(kind='none', **kwargs):
FILE: annotator/lama/saicinpainting/training/losses/feature_matching.py
function masked_l2_loss (line 7) | def masked_l2_loss(pred, target, mask, weight_known, weight_missing):
function masked_l1_loss (line 13) | def masked_l1_loss(pred, target, mask, weight_known, weight_missing):
function feature_matching_loss (line 19) | def feature_matching_loss(fake_features: List[torch.Tensor], target_feat...
FILE: annotator/lama/saicinpainting/training/losses/perceptual.py
class PerceptualLoss (line 14) | class PerceptualLoss(nn.Module):
method __init__ (line 15) | def __init__(self, normalize_inputs=True):
method do_normalize_inputs (line 38) | def do_normalize_inputs(self, x):
method partial_losses (line 41) | def partial_losses(self, input, target, mask=None):
method forward (line 72) | def forward(self, input, target, mask=None):
method get_global_features (line 76) | def get_global_features(self, input):
class ResNetPL (line 88) | class ResNetPL(nn.Module):
method __init__ (line 89) | def __init__(self, weight=1,
method forward (line 103) | def forward(self, pred, target):
FILE: annotator/lama/saicinpainting/training/losses/segmentation.py
class CrossEntropy2d (line 10) | class CrossEntropy2d(nn.Module):
method __init__ (line 11) | def __init__(self, reduction="mean", ignore_label=255, weights=None, *...
method forward (line 24) | def forward(self, predict, target):
FILE: annotator/lama/saicinpainting/training/losses/style_loss.py
class PerceptualLoss (line 6) | class PerceptualLoss(nn.Module):
method __init__ (line 13) | def __init__(self, weights=[1.0, 1.0, 1.0, 1.0, 1.0]):
method __call__ (line 19) | def __call__(self, x, y):
class VGG19 (line 34) | class VGG19(torch.nn.Module):
method __init__ (line 35) | def __init__(self):
method forward (line 111) | def forward(self, x):
FILE: annotator/lama/saicinpainting/training/modules/__init__.py
function make_generator (line 7) | def make_generator(config, kind, **kwargs):
function make_discriminator (line 22) | def make_discriminator(kind, **kwargs):
FILE: annotator/lama/saicinpainting/training/modules/base.py
class BaseDiscriminator (line 11) | class BaseDiscriminator(nn.Module):
method forward (line 13) | def forward(self, x: torch.Tensor) -> Tuple[torch.Tensor, List[torch.T...
function get_conv_block_ctor (line 21) | def get_conv_block_ctor(kind='default'):
function get_norm_layer (line 33) | def get_norm_layer(kind='bn'):
function get_activation (line 43) | def get_activation(kind='tanh'):
class SimpleMultiStepGenerator (line 53) | class SimpleMultiStepGenerator(nn.Module):
method __init__ (line 54) | def __init__(self, steps: List[nn.Module]):
method forward (line 58) | def forward(self, x):
function deconv_factory (line 67) | def deconv_factory(kind, ngf, mult, norm_layer, activation, max_features):
FILE: annotator/lama/saicinpainting/training/modules/depthwise_sep_conv.py
class DepthWiseSeperableConv (line 4) | class DepthWiseSeperableConv(nn.Module):
method __init__ (line 5) | def __init__(self, in_dim, out_dim, *args, **kwargs):
method forward (line 14) | def forward(self, x):
FILE: annotator/lama/saicinpainting/training/modules/fake_fakes.py
class FakeFakesGenerator (line 6) | class FakeFakesGenerator:
method __init__ (line 7) | def __init__(self, aug_proba=0.5, img_aug_degree=30, img_aug_translate...
method __call__ (line 20) | def __call__(self, input_images, masks):
method _make_blend_target (line 26) | def _make_blend_target(self, input_images):
method _fill_masks_with_gradient (line 34) | def _fill_masks_with_gradient(self, masks):
FILE: annotator/lama/saicinpainting/training/modules/ffc.py
class FFCSE_block (line 16) | class FFCSE_block(nn.Module):
method __init__ (line 18) | def __init__(self, channels, ratio_g):
method forward (line 34) | def forward(self, x):
class FourierUnit (line 49) | class FourierUnit(nn.Module):
method __init__ (line 51) | def __init__(self, in_channels, out_channels, groups=1, spatial_scale_...
method forward (line 76) | def forward(self, x):
class SeparableFourierUnit (line 116) | class SeparableFourierUnit(nn.Module):
method __init__ (line 118) | def __init__(self, in_channels, out_channels, groups=1, kernel_size=3):
method process_branch (line 140) | def process_branch(self, x, conv, bn):
method forward (line 160) | def forward(self, x):
class SpectralTransform (line 167) | class SpectralTransform(nn.Module):
method __init__ (line 169) | def __init__(self, in_channels, out_channels, stride=1, groups=1, enab...
method forward (line 194) | def forward(self, x):
class FFC (line 218) | class FFC(nn.Module):
method __init__ (line 220) | def __init__(self, in_channels, out_channels, kernel_size,
method forward (line 257) | def forward(self, x):
class FFC_BN_ACT (line 280) | class FFC_BN_ACT(nn.Module):
method __init__ (line 282) | def __init__(self, in_channels, out_channels,
method forward (line 303) | def forward(self, x):
class FFCResnetBlock (line 310) | class FFCResnetBlock(nn.Module):
method __init__ (line 311) | def __init__(self, dim, padding_type, norm_layer, activation_layer=nn....
method forward (line 329) | def forward(self, x):
class ConcatTupleLayer (line 347) | class ConcatTupleLayer(nn.Module):
method forward (line 348) | def forward(self, x):
class FFCResNetGenerator (line 357) | class FFCResNetGenerator(nn.Module):
method __init__ (line 358) | def __init__(self, input_nc, output_nc, ngf=64, n_downsampling=3, n_bl...
method forward (line 418) | def forward(self, input):
class FFCNLayerDiscriminator (line 422) | class FFCNLayerDiscriminator(BaseDiscriminator):
method __init__ (line 423) | def __init__(self, input_nc, ndf=64, n_layers=3, norm_layer=nn.BatchNo...
method get_all_activations (line 468) | def get_all_activations(self, x):
method forward (line 475) | def forward(self, x):
FILE: annotator/lama/saicinpainting/training/modules/multidilated_conv.py
class MultidilatedConv (line 6) | class MultidilatedConv(nn.Module):
method __init__ (line 7) | def __init__(self, in_dim, out_dim, kernel_size, dilation_num=3, comb_...
method forward (line 73) | def forward(self, x):
FILE: annotator/lama/saicinpainting/training/modules/multiscale.py
class ResNetHead (line 11) | class ResNetHead(nn.Module):
method __init__ (line 12) | def __init__(self, input_nc, ngf=64, n_downsampling=3, n_blocks=9, nor...
method forward (line 40) | def forward(self, input):
class ResNetTail (line 44) | class ResNetTail(nn.Module):
method __init__ (line 45) | def __init__(self, output_nc, ngf=64, n_downsampling=3, n_blocks=9, no...
method forward (line 86) | def forward(self, input, return_last_act=False):
class MultiscaleResNet (line 95) | class MultiscaleResNet(nn.Module):
method __init__ (line 96) | def __init__(self, input_nc, output_nc, ngf=64, n_downsampling=2, n_bl...
method num_scales (line 120) | def num_scales(self):
method forward (line 123) | def forward(self, ms_inputs: List[torch.Tensor], smallest_scales_num: ...
class MultiscaleDiscriminatorSimple (line 173) | class MultiscaleDiscriminatorSimple(nn.Module):
method __init__ (line 174) | def __init__(self, ms_impl):
method num_scales (line 179) | def num_scales(self):
method forward (line 182) | def forward(self, ms_inputs: List[torch.Tensor], smallest_scales_num: ...
class SingleToMultiScaleInputMixin (line 199) | class SingleToMultiScaleInputMixin:
method forward (line 200) | def forward(self, x: torch.Tensor) -> List:
class GeneratorMultiToSingleOutputMixin (line 208) | class GeneratorMultiToSingleOutputMixin:
method forward (line 209) | def forward(self, x):
class DiscriminatorMultiToSingleOutputMixin (line 213) | class DiscriminatorMultiToSingleOutputMixin:
method forward (line 214) | def forward(self, x):
class DiscriminatorMultiToSingleOutputStackedMixin (line 219) | class DiscriminatorMultiToSingleOutputStackedMixin:
method __init__ (line 220) | def __init__(self, *args, return_feats_only_levels=None, **kwargs):
method forward (line 224) | def forward(self, x):
class MultiscaleDiscrSingleInput (line 239) | class MultiscaleDiscrSingleInput(SingleToMultiScaleInputMixin, Discrimin...
class MultiscaleResNetSingle (line 243) | class MultiscaleResNetSingle(GeneratorMultiToSingleOutputMixin, SingleTo...
FILE: annotator/lama/saicinpainting/training/modules/pix2pixhd.py
class DotDict (line 15) | class DotDict(defaultdict):
class Identity (line 22) | class Identity(nn.Module):
method __init__ (line 23) | def __init__(self):
method forward (line 26) | def forward(self, x):
class ResnetBlock (line 30) | class ResnetBlock(nn.Module):
method __init__ (line 31) | def __init__(self, dim, padding_type, norm_layer, activation=nn.ReLU(T...
method build_conv_block (line 47) | def build_conv_block(self, dim, padding_type, norm_layer, activation, ...
method forward (line 85) | def forward(self, x):
class ResnetBlock5x5 (line 92) | class ResnetBlock5x5(nn.Module):
method __init__ (line 93) | def __init__(self, dim, padding_type, norm_layer, activation=nn.ReLU(T...
method build_conv_block (line 109) | def build_conv_block(self, dim, padding_type, norm_layer, activation, ...
method forward (line 147) | def forward(self, x):
class MultidilatedResnetBlock (line 155) | class MultidilatedResnetBlock(nn.Module):
method __init__ (line 156) | def __init__(self, dim, padding_type, conv_layer, norm_layer, activati...
method build_conv_block (line 160) | def build_conv_block(self, dim, padding_type, conv_layer, norm_layer, ...
method forward (line 173) | def forward(self, x):
class MultiDilatedGlobalGenerator (line 178) | class MultiDilatedGlobalGenerator(nn.Module):
method __init__ (line 179) | def __init__(self, input_nc, output_nc, ngf=64, n_downsampling=3,
method forward (line 236) | def forward(self, input):
class ConfigGlobalGenerator (line 239) | class ConfigGlobalGenerator(nn.Module):
method __init__ (line 240) | def __init__(self, input_nc, output_nc, ngf=64, n_downsampling=3,
method forward (line 325) | def forward(self, input):
function make_dil_blocks (line 329) | def make_dil_blocks(dilated_blocks_n, dilation_block_kind, dilated_block...
class GlobalGenerator (line 341) | class GlobalGenerator(nn.Module):
method __init__ (line 342) | def __init__(self, input_nc, output_nc, ngf=64, n_downsampling=3, n_bl...
method forward (line 435) | def forward(self, input):
class GlobalGeneratorGated (line 439) | class GlobalGeneratorGated(GlobalGenerator):
method __init__ (line 440) | def __init__(self, *args, **kwargs):
class GlobalGeneratorFromSuperChannels (line 450) | class GlobalGeneratorFromSuperChannels(nn.Module):
method __init__ (line 451) | def __init__(self, input_nc, output_nc, n_downsampling, n_blocks, supe...
method convert_super_channels (line 517) | def convert_super_channels(self, super_channels):
method forward (line 560) | def forward(self, input):
class NLayerDiscriminator (line 565) | class NLayerDiscriminator(BaseDiscriminator):
method __init__ (line 566) | def __init__(self, input_nc, ndf=64, n_layers=3, norm_layer=nn.BatchNo...
method get_all_activations (line 604) | def get_all_activations(self, x):
method forward (line 611) | def forward(self, x):
class MultidilatedNLayerDiscriminator (line 616) | class MultidilatedNLayerDiscriminator(BaseDiscriminator):
method __init__ (line 617) | def __init__(self, input_nc, ndf=64, n_layers=3, norm_layer=nn.BatchNo...
method get_all_activations (line 655) | def get_all_activations(self, x):
method forward (line 662) | def forward(self, x):
class NLayerDiscriminatorAsGen (line 667) | class NLayerDiscriminatorAsGen(NLayerDiscriminator):
method forward (line 668) | def forward(self, x):
FILE: annotator/lama/saicinpainting/training/modules/spatial_transform.py
class LearnableSpatialTransformWrapper (line 7) | class LearnableSpatialTransformWrapper(nn.Module):
method __init__ (line 8) | def __init__(self, impl, pad_coef=0.5, angle_init_range=80, train_angl...
method forward (line 16) | def forward(self, x):
method transform (line 26) | def transform(self, x):
method inverse_transform (line 33) | def inverse_transform(self, y_padded_rotated, orig_x):
FILE: annotator/lama/saicinpainting/training/modules/squeeze_excitation.py
class SELayer (line 4) | class SELayer(nn.Module):
method __init__ (line 5) | def __init__(self, channel, reduction=16):
method forward (line 15) | def forward(self, x):
FILE: annotator/lama/saicinpainting/training/trainers/__init__.py
function get_training_model_class (line 6) | def get_training_model_class(kind):
function make_training_model (line 13) | def make_training_model(config):
function load_checkpoint (line 25) | def load_checkpoint(train_config, path, map_location='cuda', strict=True):
FILE: annotator/lama/saicinpainting/training/trainers/base.py
function make_optimizer (line 24) | def make_optimizer(parameters, kind='adamw', **kwargs):
function update_running_average (line 34) | def update_running_average(result: nn.Module, new_iterate_model: nn.Modu...
function make_multiscale_noise (line 43) | def make_multiscale_noise(base_tensor, scales=6, scale_mode='bilinear'):
class BaseInpaintingTrainingModule (line 57) | class BaseInpaintingTrainingModule(ptl.LightningModule):
method __init__ (line 58) | def __init__(self, config, use_ddp, *args, predict_only=False, visual...
method configure_optimizers (line 119) | def configure_optimizers(self):
method train_dataloader (line 126) | def train_dataloader(self):
method val_dataloader (line 135) | def val_dataloader(self):
method training_step (line 149) | def training_step(self, batch, batch_idx, optimizer_idx=None):
method validation_step (line 153) | def validation_step(self, batch, batch_idx, dataloader_idx):
method training_step_end (line 165) | def training_step_end(self, batch_parts_outputs):
method validation_epoch_end (line 182) | def validation_epoch_end(self, outputs):
method _do_step (line 226) | def _do_step(self, batch, batch_idx, mode='train', optimizer_idx=None,...
method get_current_generator (line 269) | def get_current_generator(self, no_average=False):
method forward (line 274) | def forward(self, batch: Dict[str, torch.Tensor]) -> Dict[str, torch.T...
method generator_loss (line 278) | def generator_loss(self, batch) -> Tuple[torch.Tensor, Dict[str, torch...
method discriminator_loss (line 281) | def discriminator_loss(self, batch) -> Tuple[torch.Tensor, Dict[str, t...
method store_discr_outputs (line 284) | def store_discr_outputs(self, batch):
method get_ddp_rank (line 292) | def get_ddp_rank(self):
FILE: annotator/lama/saicinpainting/training/trainers/default.py
function make_constant_area_crop_batch (line 17) | def make_constant_area_crop_batch(batch, **kwargs):
class DefaultInpaintingTrainingModule (line 26) | class DefaultInpaintingTrainingModule(BaseInpaintingTrainingModule):
method __init__ (line 27) | def __init__(self, *args, concat_mask=True, rescale_scheduler_kwargs=N...
method forward (line 47) | def forward(self, batch):
method generator_loss (line 88) | def generator_loss(self, batch):
method discriminator_loss (line 140) | def discriminator_loss(self, batch):
FILE: annotator/lama/saicinpainting/training/visualizers/__init__.py
function make_visualizer (line 7) | def make_visualizer(kind, **kwargs):
FILE: annotator/lama/saicinpainting/training/visualizers/base.py
class BaseVisualizer (line 14) | class BaseVisualizer:
method __call__ (line 16) | def __call__(self, epoch_i, batch_i, batch, suffix='', rank=None):
function visualize_mask_and_images (line 23) | def visualize_mask_and_images(images_dict: Dict[str, np.ndarray], keys: ...
function visualize_mask_and_images_batch (line 61) | def visualize_mask_and_images_batch(batch: Dict[str, torch.Tensor], keys...
FILE: annotator/lama/saicinpainting/training/visualizers/colors.py
function generate_colors (line 11) | def generate_colors(nlabels, type='bright', first_color_black=False, las...
FILE: annotator/lama/saicinpainting/training/visualizers/directory.py
class DirectoryVisualizer (line 10) | class DirectoryVisualizer(BaseVisualizer):
method __init__ (line 13) | def __init__(self, outdir, key_order=DEFAULT_KEY_ORDER, max_items_in_b...
method __call__ (line 22) | def __call__(self, epoch_i, batch_i, batch, suffix='', rank=None):
FILE: annotator/lama/saicinpainting/training/visualizers/noop.py
class NoopVisualizer (line 4) | class NoopVisualizer(BaseVisualizer):
method __init__ (line 5) | def __init__(self, *args, **kwargs):
method __call__ (line 8) | def __call__(self, epoch_i, batch_i, batch, suffix='', rank=None):
FILE: annotator/lama/saicinpainting/utils.py
function check_and_warn_input_range (line 17) | def check_and_warn_input_range(tensor, min_value, max_value, name):
function sum_dict_with_prefix (line 24) | def sum_dict_with_prefix(target, cur_dict, prefix, default=0):
function average_dicts (line 30) | def average_dicts(dict_list):
function add_prefix_to_keys (line 41) | def add_prefix_to_keys(dct, prefix):
function set_requires_grad (line 45) | def set_requires_grad(module, value):
function flatten_dict (line 50) | def flatten_dict(dct):
class LinearRamp (line 63) | class LinearRamp:
method __init__ (line 64) | def __init__(self, start_value=0, end_value=1, start_iter=-1, end_iter...
method __call__ (line 70) | def __call__(self, i):
class LadderRamp (line 79) | class LadderRamp:
method __init__ (line 80) | def __init__(self, start_iters, values):
method __call__ (line 85) | def __call__(self, i):
function get_ramp (line 90) | def get_ramp(kind='ladder', **kwargs):
function print_traceback_handler (line 98) | def print_traceback_handler(sig, frame):
function register_debug_signal_handlers (line 104) | def register_debug_signal_handlers(sig=None, handler=print_traceback_han...
function handle_deterministic_config (line 109) | def handle_deterministic_config(config):
function get_shape (line 118) | def get_shape(t):
function get_has_ddp_rank (line 131) | def get_has_ddp_rank():
function handle_ddp_subprocess (line 140) | def handle_ddp_subprocess():
function handle_ddp_parent_process (line 165) | def handle_ddp_parent_process():
FILE: annotator/leres/__init__.py
function unload_leres_model (line 27) | def unload_leres_model():
function apply_leres (line 35) | def apply_leres(input_image, thr_a, thr_b, boost=False):
FILE: annotator/leres/leres/Resnet.py
function conv3x3 (line 17) | def conv3x3(in_planes, out_planes, stride=1):
class BasicBlock (line 23) | class BasicBlock(nn.Module):
method __init__ (line 26) | def __init__(self, inplanes, planes, stride=1, downsample=None):
method forward (line 36) | def forward(self, x):
class Bottleneck (line 55) | class Bottleneck(nn.Module):
method __init__ (line 58) | def __init__(self, inplanes, planes, stride=1, downsample=None):
method forward (line 71) | def forward(self, x):
class ResNet (line 94) | class ResNet(nn.Module):
method __init__ (line 96) | def __init__(self, block, layers, num_classes=1000):
method _make_layer (line 118) | def _make_layer(self, block, planes, blocks, stride=1):
method forward (line 135) | def forward(self, x):
function resnet18 (line 155) | def resnet18(pretrained=True, **kwargs):
function resnet34 (line 164) | def resnet34(pretrained=True, **kwargs):
function resnet50 (line 173) | def resnet50(pretrained=True, **kwargs):
function resnet101 (line 183) | def resnet101(pretrained=True, **kwargs):
function resnet152 (line 193) | def resnet152(pretrained=True, **kwargs):
FILE: annotator/leres/leres/Resnext_torch.py
function conv3x3 (line 19) | def conv3x3(in_planes, out_planes, stride=1, groups=1, dilation=1):
function conv1x1 (line 25) | def conv1x1(in_planes, out_planes, stride=1):
class BasicBlock (line 30) | class BasicBlock(nn.Module):
method __init__ (line 33) | def __init__(self, inplanes, planes, stride=1, downsample=None, groups=1,
method forward (line 51) | def forward(self, x):
class Bottleneck (line 70) | class Bottleneck(nn.Module):
method __init__ (line 79) | def __init__(self, inplanes, planes, stride=1, downsample=None, groups=1,
method forward (line 96) | def forward(self, x):
class ResNet (line 119) | class ResNet(nn.Module):
method __init__ (line 121) | def __init__(self, block, layers, num_classes=1000, zero_init_residual...
method _make_layer (line 172) | def _make_layer(self, block, planes, blocks, stride=1, dilate=False):
method _forward_impl (line 196) | def _forward_impl(self, x):
method forward (line 222) | def forward(self, x):
function resnext101_32x8d (line 227) | def resnext101_32x8d(pretrained=True, **kwargs):
FILE: annotator/leres/leres/depthmap.py
function scale_torch (line 17) | def scale_torch(img):
function estimateleres (line 34) | def estimateleres(img, model, w, h):
function generatemask (line 50) | def generatemask(size):
function resizewithpool (line 61) | def resizewithpool(img, size):
function rgb2gray (line 68) | def rgb2gray(rgb):
function calculateprocessingres (line 72) | def calculateprocessingres(img, basesize, confidence=0.1, scale_threshol...
function doubleestimate (line 130) | def doubleestimate(img, size1, size2, pix2pixsize, model, net_type, pix2...
function singleestimate (line 154) | def singleestimate(img, msize, model, net_type):
function applyGridpatch (line 160) | def applyGridpatch(blsize, stride, img, box):
function generatepatchs (line 176) | def generatepatchs(img, base_size):
function getGF_fromintegral (line 208) | def getGF_fromintegral(integralimage, rect):
function adaptiveselection (line 218) | def adaptiveselection(integral_grad, patch_bound_list, gf):
function impatch (line 268) | def impatch(image, rect):
class ImageandPatchs (line 277) | class ImageandPatchs:
method __init__ (line 278) | def __init__(self, root_dir, name, patchsinfo, rgb_image, scale=1):
method __len__ (line 292) | def __len__(self):
method set_base_estimate (line 295) | def set_base_estimate(self, est):
method set_updated_estimate (line 300) | def set_updated_estimate(self, est):
method __getitem__ (line 305) | def __getitem__(self, index):
method print_options (line 325) | def print_options(self, opt):
method parse (line 352) | def parse(self):
function estimateboost (line 378) | def estimateboost(img, model, model_type, pix2pixmodel, max_res=512):
FILE: annotator/leres/leres/multi_depth_model_woauxi.py
class RelDepthModel (line 7) | class RelDepthModel(nn.Module):
method __init__ (line 8) | def __init__(self, backbone='resnet50'):
method inference (line 16) | def inference(self, rgb):
class DepthModel (line 24) | class DepthModel(nn.Module):
method __init__ (line 25) | def __init__(self, encoder):
method forward (line 31) | def forward(self, x):
FILE: annotator/leres/leres/net_tools.py
function get_func (line 7) | def get_func(func_name):
function load_ckpt (line 27) | def load_ckpt(args, depth_model, shift_model, focal_model):
function strip_prefix_if_present (line 47) | def strip_prefix_if_present(state_dict, prefix):
FILE: annotator/leres/leres/network_auxi.py
function resnet50_stride32 (line 8) | def resnet50_stride32():
function resnext101_stride32x8d (line 11) | def resnext101_stride32x8d():
class Decoder (line 15) | class Decoder(nn.Module):
method __init__ (line 16) | def __init__(self):
method _init_params (line 34) | def _init_params(self):
method forward (line 52) | def forward(self, features):
class DepthNet (line 64) | class DepthNet(nn.Module):
method __init__ (line 72) | def __init__(self,
method forward (line 95) | def forward(self, x):
class FTB (line 100) | class FTB(nn.Module):
method __init__ (line 101) | def __init__(self, inchannels, midchannels=512):
method forward (line 119) | def forward(self, x):
method init_params (line 126) | def init_params(self):
class ATA (line 147) | class ATA(nn.Module):
method __init__ (line 148) | def __init__(self, inchannels, reduction=8):
method forward (line 158) | def forward(self, low_x, high_x):
method init_params (line 168) | def init_params(self):
class FFM (line 191) | class FFM(nn.Module):
method __init__ (line 192) | def __init__(self, inchannels, midchannels, outchannels, upfactor=2):
method forward (line 207) | def forward(self, low_x, high_x):
method init_params (line 215) | def init_params(self):
class AO (line 238) | class AO(nn.Module):
method __init__ (line 240) | def __init__(self, inchannels, outchannels, upfactor=2):
method forward (line 257) | def forward(self, x):
method init_params (line 261) | def init_params(self):
class ResidualConv (line 288) | class ResidualConv(nn.Module):
method __init__ (line 289) | def __init__(self, inchannels):
method forward (line 306) | def forward(self, x):
method init_params (line 310) | def init_params(self):
class FeatureFusion (line 333) | class FeatureFusion(nn.Module):
method __init__ (line 334) | def __init__(self, inchannels, outchannels):
method forward (line 344) | def forward(self, lowfeat, highfeat):
method init_params (line 347) | def init_params(self):
class SenceUnderstand (line 370) | class SenceUnderstand(nn.Module):
method __init__ (line 371) | def __init__(self, channels):
method forward (line 384) | def forward(self, x):
method initial_params (line 395) | def initial_params(self, dev=0.01):
FILE: annotator/leres/pix2pix/models/__init__.py
function find_model_using_name (line 25) | def find_model_using_name(model_name):
function get_option_setter (line 48) | def get_option_setter(model_name):
function create_model (line 54) | def create_model(opt):
FILE: annotator/leres/pix2pix/models/base_model.py
class BaseModel (line 9) | class BaseModel(ABC):
method __init__ (line 19) | def __init__(self, opt):
method modify_commandline_options (line 48) | def modify_commandline_options(parser, is_train):
method set_input (line 61) | def set_input(self, input):
method forward (line 70) | def forward(self):
method optimize_parameters (line 75) | def optimize_parameters(self):
method setup (line 79) | def setup(self, opt):
method eval (line 92) | def eval(self):
method test (line 99) | def test(self):
method compute_visuals (line 109) | def compute_visuals(self):
method get_image_paths (line 113) | def get_image_paths(self):
method update_learning_rate (line 117) | def update_learning_rate(self):
method get_current_visuals (line 129) | def get_current_visuals(self):
method get_current_losses (line 137) | def get_current_losses(self):
method save_networks (line 145) | def save_networks(self, epoch):
method unload_network (line 163) | def unload_network(self, name):
method __patch_instance_norm_state_dict (line 173) | def __patch_instance_norm_state_dict(self, state_dict, module, keys, i...
method load_networks (line 187) | def load_networks(self, epoch):
method print_networks (line 212) | def print_networks(self, verbose):
method set_requires_grad (line 230) | def set_requires_grad(self, nets, requires_grad=False):
FILE: annotator/leres/pix2pix/models/base_model_hg.py
class BaseModelHG (line 4) | class BaseModelHG():
method name (line 5) | def name(self):
method initialize (line 8) | def initialize(self, opt):
method set_input (line 15) | def set_input(self, input):
method forward (line 18) | def forward(self):
method test (line 22) | def test(self):
method get_image_paths (line 25) | def get_image_paths(self):
method optimize_parameters (line 28) | def optimize_parameters(self):
method get_current_visuals (line 31) | def get_current_visuals(self):
method get_current_errors (line 34) | def get_current_errors(self):
method save (line 37) | def save(self, label):
method save_network (line 41) | def save_network(self, network, network_label, epoch_label, gpu_ids):
method load_network (line 49) | def load_network(self, network, network_label, epoch_label):
method update_learning_rate (line 57) | def update_learning_rate():
FILE: annotator/leres/pix2pix/models/networks.py
class Identity (line 13) | class Identity(nn.Module):
method forward (line 14) | def forward(self, x):
function get_norm_layer (line 18) | def get_norm_layer(norm_type='instance'):
function get_scheduler (line 38) | def get_scheduler(optimizer, opt):
function init_weights (line 67) | def init_weights(net, init_type='normal', init_gain=0.02):
function init_net (line 101) | def init_net(net, init_type='normal', init_gain=0.02, gpu_ids=[]):
function define_G (line 119) | def define_G(input_nc, output_nc, ngf, netG, norm='batch', use_dropout=F...
function define_D (line 170) | def define_D(input_nc, ndf, netD, n_layers_D=3, norm='batch', init_type=...
class GANLoss (line 217) | class GANLoss(nn.Module):
method __init__ (line 224) | def __init__(self, gan_mode, target_real_label=1.0, target_fake_label=...
method get_target_tensor (line 248) | def get_target_tensor(self, prediction, target_is_real):
method __call__ (line 265) | def __call__(self, prediction, target_is_real):
function cal_gradient_penalty (line 286) | def cal_gradient_penalty(netD, real_data, fake_data, device, type='mixed...
class ResnetGenerator (line 323) | class ResnetGenerator(nn.Module):
method __init__ (line 329) | def __init__(self, input_nc, output_nc, ngf=64, norm_layer=nn.BatchNor...
method forward (line 379) | def forward(self, input):
class ResnetBlock (line 384) | class ResnetBlock(nn.Module):
method __init__ (line 387) | def __init__(self, dim, padding_type, norm_layer, use_dropout, use_bias):
method build_conv_block (line 398) | def build_conv_block(self, dim, padding_type, norm_layer, use_dropout,...
method forward (line 438) | def forward(self, x):
class UnetGenerator (line 444) | class UnetGenerator(nn.Module):
method __init__ (line 447) | def __init__(self, input_nc, output_nc, num_downs, ngf=64, norm_layer=...
method forward (line 471) | def forward(self, input):
class UnetSkipConnectionBlock (line 476) | class UnetSkipConnectionBlock(nn.Module):
method __init__ (line 482) | def __init__(self, outer_nc, inner_nc, input_nc=None,
method forward (line 539) | def forward(self, x):
class NLayerDiscriminator (line 546) | class NLayerDiscriminator(nn.Module):
method __init__ (line 549) | def __init__(self, input_nc, ndf=64, n_layers=3, norm_layer=nn.BatchNo...
method forward (line 589) | def forward(self, input):
class PixelDiscriminator (line 594) | class PixelDiscriminator(nn.Module):
method __init__ (line 597) | def __init__(self, input_nc, ndf=64, norm_layer=nn.BatchNorm2d):
method forward (line 621) | def forward(self, input):
FILE: annotator/leres/pix2pix/models/pix2pix4depth_model.py
class Pix2Pix4DepthModel (line 6) | class Pix2Pix4DepthModel(BaseModel):
method modify_commandline_options (line 17) | def modify_commandline_options(parser, is_train=True):
method __init__ (line 38) | def __init__(self, opt):
method set_input_train (line 80) | def set_input_train(self, input):
method set_input (line 96) | def set_input(self, outer, inner):
method normalize (line 109) | def normalize(self, input):
method forward (line 114) | def forward(self):
method backward_D (line 118) | def backward_D(self):
method backward_G (line 132) | def backward_G(self):
method optimize_parameters (line 144) | def optimize_parameters(self):
FILE: annotator/leres/pix2pix/options/base_options.py
class BaseOptions (line 9) | class BaseOptions():
method __init__ (line 16) | def __init__(self):
method initialize (line 20) | def initialize(self, parser):
method gather_options (line 79) | def gather_options(self):
method print_options (line 108) | def print_options(self, opt):
method parse (line 133) | def parse(self):
FILE: annotator/leres/pix2pix/options/test_options.py
class TestOptions (line 4) | class TestOptions(BaseOptions):
method initialize (line 10) | def initialize(self, parser):
FILE: annotator/leres/pix2pix/util/get_data.py
class GetData (line 11) | class GetData(object):
method __init__ (line 27) | def __init__(self, technique='cyclegan', verbose=True):
method _print (line 35) | def _print(self, text):
method _get_options (line 40) | def _get_options(r):
method _present_options (line 46) | def _present_options(self):
method _download_data (line 56) | def _download_data(self, dataset_url, save_path):
method get (line 79) | def get(self, save_path, dataset=None):
FILE: annotator/leres/pix2pix/util/guidedfilter.py
class GuidedFilter (line 3) | class GuidedFilter():
method __init__ (line 4) | def __init__(self, source, reference, r=64, eps= 0.05**2):
method boxfilter (line 12) | def boxfilter(self,img, r):
method guidedfilter (line 28) | def guidedfilter(self,I, p, r, eps):
FILE: annotator/leres/pix2pix/util/html.py
class HTML (line 6) | class HTML:
method __init__ (line 14) | def __init__(self, web_dir, title, refresh=0):
method get_image_dir (line 35) | def get_image_dir(self):
method add_header (line 39) | def add_header(self, text):
method add_images (line 48) | def add_images(self, ims, txts, links, width=400):
method save (line 68) | def save(self):
FILE: annotator/leres/pix2pix/util/image_pool.py
class ImagePool (line 5) | class ImagePool():
method __init__ (line 12) | def __init__(self, pool_size):
method query (line 23) | def query(self, images):
FILE: annotator/leres/pix2pix/util/util.py
function tensor2im (line 9) | def tensor2im(input_image, imtype=np.uint16):
function diagnose_network (line 28) | def diagnose_network(net, name='network'):
function save_image (line 47) | def save_image(image_numpy, image_path, aspect_ratio=1.0):
function print_numpy (line 69) | def print_numpy(x, val=True, shp=False):
function mkdirs (line 85) | def mkdirs(paths):
function mkdir (line 98) | def mkdir(path):
FILE: annotator/leres/pix2pix/util/visualizer.py
function save_images (line 17) | def save_images(webpage, visuals, image_path, aspect_ratio=1.0, width=256):
class Visualizer (line 47) | class Visualizer():
method __init__ (line 53) | def __init__(self, opt):
method reset (line 82) | def reset(self):
method create_visdom_connections (line 86) | def create_visdom_connections(self):
method display_current_results (line 93) | def display_current_results(self, visuals, epoch, save_result):
method print_current_losses (line 150) | def print_current_losses(self, epoch, iters, losses, t_comp, t_data):
FILE: annotator/lineart/__init__.py
class ResidualBlock (line 15) | class ResidualBlock(nn.Module):
method __init__ (line 16) | def __init__(self, in_features):
method forward (line 30) | def forward(self, x):
class Generator (line 34) | class Generator(nn.Module):
method __init__ (line 35) | def __init__(self, input_nc, output_nc, n_residual_blocks=9, sigmoid=T...
method forward (line 82) | def forward(self, x, cond=None):
class LineartDetector (line 92) | class LineartDetector:
method __init__ (line 97) | def __init__(self, model_name):
method load_model (line 102) | def load_model(self, name):
method unload_model (line 113) | def unload_model(self):
method __call__ (line 117) | def __call__(self, input_image):
FILE: annotator/lineart_anime/__init__.py
class UnetGenerator (line 13) | class UnetGenerator(nn.Module):
method __init__ (line 16) | def __init__(self, input_nc, output_nc, num_downs, ngf=64, norm_layer=...
method forward (line 39) | def forward(self, input):
class UnetSkipConnectionBlock (line 44) | class UnetSkipConnectionBlock(nn.Module):
method __init__ (line 50) | def __init__(self, outer_nc, inner_nc, input_nc=None,
method forward (line 106) | def forward(self, x):
class LineartAnimeDetector (line 113) | class LineartAnimeDetector:
method __init__ (line 116) | def __init__(self):
method load_model (line 120) | def load_model(self):
method unload_model (line 137) | def unload_model(self):
method __call__ (line 141) | def __call__(self, input_image):
FILE: annotator/manga_line/__init__.py
class _bn_relu_conv (line 16) | class _bn_relu_conv(nn.Module):
method __init__ (line 17) | def __init__(self, in_filters, nb_filters, fw, fh, subsample=1):
method forward (line 25) | def forward(self, x):
class _u_bn_relu_conv (line 40) | class _u_bn_relu_conv(nn.Module):
method __init__ (line 41) | def __init__(self, in_filters, nb_filters, fw, fh, subsample=1):
method forward (line 50) | def forward(self, x):
class _shortcut (line 55) | class _shortcut(nn.Module):
method __init__ (line 56) | def __init__(self, in_filters, nb_filters, subsample=1):
method forward (line 66) | def forward(self, x, y):
class _u_shortcut (line 76) | class _u_shortcut(nn.Module):
method __init__ (line 77) | def __init__(self, in_filters, nb_filters, subsample):
method forward (line 88) | def forward(self, x, y):
class basic_block (line 95) | class basic_block(nn.Module):
method __init__ (line 96) | def __init__(self, in_filters, nb_filters, init_subsample=1):
method forward (line 102) | def forward(self, x):
class _u_basic_block (line 107) | class _u_basic_block(nn.Module):
method __init__ (line 108) | def __init__(self, in_filters, nb_filters, init_subsample=1):
method forward (line 114) | def forward(self, x):
class _residual_block (line 119) | class _residual_block(nn.Module):
method __init__ (line 120) | def __init__(self, in_filters, nb_filters, repetitions, is_first_layer...
method forward (line 135) | def forward(self, x):
class _upsampling_residual_block (line 139) | class _upsampling_residual_block(nn.Module):
method __init__ (line 140) | def __init__(self, in_filters, nb_filters, repetitions):
method forward (line 153) | def forward(self, x):
class res_skip (line 157) | class res_skip(nn.Module):
method __init__ (line 159) | def __init__(self):
method forward (line 182) | def forward(self, x):
class MangaLineExtration (line 207) | class MangaLineExtration:
method __init__ (line 210) | def __init__(self):
method load_model (line 214) | def load_model(self):
method unload_model (line 231) | def unload_model(self):
method __call__ (line 235) | def __call__(self, input_image):
FILE: annotator/mediapipe_face/__init__.py
function apply_mediapipe_face (line 4) | def apply_mediapipe_face(image, max_faces: int = 1, min_confidence: floa...
FILE: annotator/mediapipe_face/mediapipe_face_common.py
function draw_pupils (line 51) | def draw_pupils(image, landmark_list, drawing_spec, halfwidth: int = 2):
function reverse_channels (line 80) | def reverse_channels(image):
function generate_annotation (line 87) | def generate_annotation(
FILE: annotator/midas/__init__.py
function unload_midas_model (line 11) | def unload_midas_model():
function apply_midas (line 16) | def apply_midas(input_image, a=np.pi * 2.0, bg_th=0.1):
FILE: annotator/midas/api.py
function disabled_train (line 35) | def disabled_train(self, mode=True):
function load_midas_transform (line 41) | def load_midas_transform(model_type):
function load_model (line 86) | def load_model(model_type):
class MiDaSInference (line 157) | class MiDaSInference(nn.Module):
method __init__ (line 170) | def __init__(self, model_type):
method forward (line 177) | def forward(self, x):
FILE: annotator/midas/midas/base_model.py
class BaseModel (line 4) | class BaseModel(torch.nn.Module):
method load (line 5) | def load(self, path):
FILE: annotator/midas/midas/blocks.py
function _make_encoder (line 11) | def _make_encoder(backbone, features, use_pretrained, groups=1, expand=F...
function _make_scratch (line 49) | def _make_scratch(in_shape, out_shape, groups=1, expand=False):
function _make_pretrained_efficientnet_lite3 (line 78) | def _make_pretrained_efficientnet_lite3(use_pretrained, exportable=False):
function _make_efficientnet_backbone (line 88) | def _make_efficientnet_backbone(effnet):
function _make_resnet_backbone (line 101) | def _make_resnet_backbone(resnet):
function _make_pretrained_resnext101_wsl (line 114) | def _make_pretrained_resnext101_wsl(use_pretrained):
class Interpolate (line 120) | class Interpolate(nn.Module):
method __init__ (line 124) | def __init__(self, scale_factor, mode, align_corners=False):
method forward (line 138) | def forward(self, x):
class ResidualConvUnit (line 155) | class ResidualConvUnit(nn.Module):
method __init__ (line 159) | def __init__(self, features):
method forward (line 177) | def forward(self, x):
class FeatureFusionBlock (line 194) | class FeatureFusionBlock(nn.Module):
method __init__ (line 198) | def __init__(self, features):
method forward (line 209) | def forward(self, *xs):
class ResidualConvUnit_custom (line 231) | class ResidualConvUnit_custom(nn.Module):
method __init__ (line 235) | def __init__(self, features, activation, bn):
method forward (line 263) | def forward(self, x):
class FeatureFusionBlock_custom (line 291) | class FeatureFusionBlock_custom(nn.Module):
method __init__ (line 295) | def __init__(self, features, activation, deconv=False, bn=False, expan...
method forward (line 320) | def forward(self, *xs):
FILE: annotator/midas/midas/dpt_depth.py
function _make_fusion_block (line 15) | def _make_fusion_block(features, use_bn):
class DPT (line 26) | class DPT(BaseModel):
method __init__ (line 27) | def __init__(
method forward (line 67) | def forward(self, x):
class DPTDepthModel (line 88) | class DPTDepthModel(DPT):
method __init__ (line 89) | def __init__(self, path=None, non_negative=True, **kwargs):
method forward (line 107) | def forward(self, x):
FILE: annotator/midas/midas/midas_net.py
class MidasNet (line 12) | class MidasNet(BaseModel):
method __init__ (line 16) | def __init__(self, path=None, features=256, non_negative=True):
method forward (line 49) | def forward(self, x):
FILE: annotator/midas/midas/midas_net_custom.py
class MidasNet_small (line 12) | class MidasNet_small(BaseModel):
method __init__ (line 16) | def __init__(self, path=None, features=64, backbone="efficientnet_lite...
method forward (line 73) | def forward(self, x):
function fuse_model (line 109) | def fuse_model(m):
FILE: annotator/midas/midas/transforms.py
function apply_min_size (line 6) | def apply_min_size(sample, size, image_interpolation_method=cv2.INTER_AR...
class Resize (line 48) | class Resize(object):
method __init__ (line 52) | def __init__(
method constrain_to_multiple_of (line 94) | def constrain_to_multiple_of(self, x, min_val=0, max_val=None):
method get_size (line 105) | def get_size(self, width, height):
method __call__ (line 162) | def __call__(self, sample):
class NormalizeImage (line 197) | class NormalizeImage(object):
method __init__ (line 201) | def __init__(self, mean, std):
method __call__ (line 205) | def __call__(self, sample):
class PrepareForNet (line 211) | class PrepareForNet(object):
method __init__ (line 215) | def __init__(self):
method __call__ (line 218) | def __call__(self, sample):
FILE: annotator/midas/midas/vit.py
class Slice (line 9) | class Slice(nn.Module):
method __init__ (line 10) | def __init__(self, start_index=1):
method forward (line 14) | def forward(self, x):
class AddReadout (line 18) | class AddReadout(nn.Module):
method __init__ (line 19) | def __init__(self, start_index=1):
method forward (line 23) | def forward(self, x):
class ProjectReadout (line 31) | class ProjectReadout(nn.Module):
method __init__ (line 32) | def __init__(self, in_features, start_index=1):
method forward (line 38) | def forward(self, x):
class Transpose (line 45) | class Transpose(nn.Module):
method __init__ (line 46) | def __init__(self, dim0, dim1):
method forward (line 51) | def forward(self, x):
function forward_vit (line 56) | def forward_vit(pretrained, x):
function _resize_pos_embed (line 100) | def _resize_pos_embed(self, posemb, gs_h, gs_w):
function forward_flex (line 117) | def forward_flex(self, x):
function get_activation (line 159) | def get_activation(name):
function get_readout_oper (line 166) | def get_readout_oper(vit_features, features, use_readout, start_index=1):
function _make_vit_b16_backbone (line 183) | def _make_vit_b16_backbone(
function _make_pretrained_vitl16_384 (line 297) | def _make_pretrained_vitl16_384(pretrained, use_readout="ignore", hooks=...
function _make_pretrained_vitb16_384 (line 310) | def _make_pretrained_vitb16_384(pretrained, use_readout="ignore", hooks=...
function _make_pretrained_deitb16_384 (line 319) | def _make_pretrained_deitb16_384(pretrained, use_readout="ignore", hooks...
function _make_pretrained_deitb16_distil_384 (line 328) | def _make_pretrained_deitb16_distil_384(pretrained, use_readout="ignore"...
function _make_vit_b_rn50_backbone (line 343) | def _make_vit_b_rn50_backbone(
function _make_pretrained_vitb_rn50_384 (line 478) | def _make_pretrained_vitb_rn50_384(
FILE: annotator/midas/utils.py
function read_pfm (line 9) | def read_pfm(path):
function write_pfm (line 58) | def write_pfm(path, image, scale=1):
function read_image (line 97) | def read_image(path):
function resize_image (line 116) | def resize_image(img):
function resize_depth (line 146) | def resize_depth(depth, width, height):
function write_depth (line 165) | def write_depth(path, depth, bits=1):
FILE: annotator/mlsd/__init__.py
function unload_mlsd_model (line 18) | def unload_mlsd_model():
function apply_mlsd (line 23) | def apply_mlsd(input_image, thr_v, thr_d):
FILE: annotator/mlsd/models/mbv2_mlsd_large.py
class BlockTypeA (line 9) | class BlockTypeA(nn.Module):
method __init__ (line 10) | def __init__(self, in_c1, in_c2, out_c1, out_c2, upscale = True):
method forward (line 24) | def forward(self, a, b):
class BlockTypeB (line 32) | class BlockTypeB(nn.Module):
method __init__ (line 33) | def __init__(self, in_c, out_c):
method forward (line 46) | def forward(self, x):
class BlockTypeC (line 51) | class BlockTypeC(nn.Module):
method __init__ (line 52) | def __init__(self, in_c, out_c):
method forward (line 66) | def forward(self, x):
function _make_divisible (line 72) | def _make_divisible(v, divisor, min_value=None):
class ConvBNReLU (line 92) | class ConvBNReLU(nn.Sequential):
method __init__ (line 93) | def __init__(self, in_planes, out_planes, kernel_size=3, stride=1, gro...
method forward (line 112) | def forward(self, x):
class InvertedResidual (line 124) | class InvertedResidual(nn.Module):
method __init__ (line 125) | def __init__(self, inp, oup, stride, expand_ratio):
method forward (line 146) | def forward(self, x):
class MobileNetV2 (line 153) | class MobileNetV2(nn.Module):
method __init__ (line 154) | def __init__(self, pretrained=True):
method _forward_impl (line 218) | def _forward_impl(self, x):
method forward (line 233) | def forward(self, x):
method _load_pretrained_model (line 236) | def _load_pretrained_model(self):
class MobileV2_MLSD_Large (line 247) | class MobileV2_MLSD_Large(nn.Module):
method __init__ (line 248) | def __init__(self):
method forward (line 275) | def forward(self, x):
FILE: annotator/mlsd/models/mbv2_mlsd_tiny.py
class BlockTypeA (line 9) | class BlockTypeA(nn.Module):
method __init__ (line 10) | def __init__(self, in_c1, in_c2, out_c1, out_c2, upscale = True):
method forward (line 24) | def forward(self, a, b):
class BlockTypeB (line 31) | class BlockTypeB(nn.Module):
method __init__ (line 32) | def __init__(self, in_c, out_c):
method forward (line 45) | def forward(self, x):
class BlockTypeC (line 50) | class BlockTypeC(nn.Module):
method __init__ (line 51) | def __init__(self, in_c, out_c):
method forward (line 65) | def forward(self, x):
function _make_divisible (line 71) | def _make_divisible(v, divisor, min_value=None):
class ConvBNReLU (line 91) | class ConvBNReLU(nn.Sequential):
method __init__ (line 92) | def __init__(self, in_planes, out_planes, kernel_size=3, stride=1, gro...
method forward (line 111) | def forward(self, x):
class InvertedResidual (line 123) | class InvertedResidual(nn.Module):
method __init__ (line 124) | def __init__(self, inp, oup, stride, expand_ratio):
method forward (line 145) | def forward(self, x):
class MobileNetV2 (line 152) | class MobileNetV2(nn.Module):
method __init__ (line 153) | def __init__(self, pretrained=True):
method _forward_impl (line 218) | def _forward_impl(self, x):
method forward (line 233) | def forward(self, x):
method _load_pretrained_model (line 236) | def _load_pretrained_model(self):
class MobileV2_MLSD_Tiny (line 247) | class MobileV2_MLSD_Tiny(nn.Module):
method __init__ (line 248) | def __init__(self):
method forward (line 263) | def forward(self, x):
FILE: annotator/mlsd/utils.py
function deccode_output_score_and_ptss (line 20) | def deccode_output_score_and_ptss(tpMap, topk_n = 200, ksize = 5):
function pred_lines (line 48) | def pred_lines(image, model,
function pred_squares (line 90) | def pred_squares(image,
FILE: annotator/mmpkg/mmcv/arraymisc/quantization.py
function quantize (line 5) | def quantize(arr, min_val, max_val, levels, dtype=np.int64):
function dequantize (line 32) | def dequantize(arr, min_val, max_val, levels, dtype=np.float64):
FILE: annotator/mmpkg/mmcv/cnn/alexnet.py
class AlexNet (line 7) | class AlexNet(nn.Module):
method __init__ (line 14) | def __init__(self, num_classes=-1):
method init_weights (line 43) | def init_weights(self, pretrained=None):
method forward (line 54) | def forward(self, x):
FILE: annotator/mmpkg/mmcv/cnn/bricks/activation.py
class Clamp (line 18) | class Clamp(nn.Module):
method __init__ (line 31) | def __init__(self, min=-1., max=1.):
method forward (line 36) | def forward(self, x):
class GELU (line 48) | class GELU(nn.Module):
method forward (line 70) | def forward(self, input):
function build_activation_layer (line 81) | def build_activation_layer(cfg):
FILE: annotator/mmpkg/mmcv/cnn/bricks/context_block.py
function last_zero_init (line 9) | def last_zero_init(m):
class ContextBlock (line 17) | class ContextBlock(nn.Module):
method __init__ (line 36) | def __init__(self,
method reset_parameters (line 75) | def reset_parameters(self):
method spatial_pool (line 85) | def spatial_pool(self, x):
method forward (line 111) | def forward(self, x):
FILE: annotator/mmpkg/mmcv/cnn/bricks/conv.py
function build_conv_layer (line 12) | def build_conv_layer(cfg, *args, **kwargs):
FILE: annotator/mmpkg/mmcv/cnn/bricks/conv2d_adaptive_padding.py
class Conv2dAdaptivePadding (line 11) | class Conv2dAdaptivePadding(nn.Conv2d):
method __init__ (line 33) | def __init__(self,
method forward (line 45) | def forward(self, x):
FILE: annotator/mmpkg/mmcv/cnn/bricks/conv_module.py
class ConvModule (line 16) | class ConvModule(nn.Module):
method __init__ (line 70) | def __init__(self,
method norm (line 169) | def norm(self):
method init_weights (line 175) | def init_weights(self):
method forward (line 196) | def forward(self, x, activate=True, norm=True):
FILE: annotator/mmpkg/mmcv/cnn/bricks/conv_ws.py
function conv_ws_2d (line 9) | def conv_ws_2d(input,
class ConvWS2d (line 26) | class ConvWS2d(nn.Conv2d):
method __init__ (line 28) | def __init__(self,
method forward (line 49) | def forward(self, x):
class ConvAWS2d (line 55) | class ConvAWS2d(nn.Conv2d):
method __init__ (line 78) | def __init__(self,
method _get_weight (line 101) | def _get_weight(self, weight):
method forward (line 109) | def forward(self, x):
method _load_from_state_dict (line 114) | def _load_from_state_dict(self, state_dict, prefix, local_metadata, st...
FILE: annotator/mmpkg/mmcv/cnn/bricks/depthwise_separable_conv_module.py
class DepthwiseSeparableConvModule (line 7) | class DepthwiseSeparableConvModule(nn.Module):
method __init__ (line 48) | def __init__(self,
method forward (line 93) | def forward(self, x):
FILE: annotator/mmpkg/mmcv/cnn/bricks/drop.py
function drop_path (line 9) | def drop_path(x, drop_prob=0., training=False):
class DropPath (line 28) | class DropPath(nn.Module):
method __init__ (line 39) | def __init__(self, drop_prob=0.1):
method forward (line 43) | def forward(self, x):
class Dropout (line 48) | class Dropout(nn.Dropout):
method __init__ (line 59) | def __init__(self, drop_prob=0.5, inplace=False):
function build_dropout (line 63) | def build_dropout(cfg, default_args=None):
FILE: annotator/mmpkg/mmcv/cnn/bricks/generalized_attention.py
class GeneralizedAttention (line 14) | class GeneralizedAttention(nn.Module):
method __init__ (line 47) | def __init__(self,
method get_position_embedding (line 166) | def get_position_embedding(self,
method forward (line 216) | def forward(self, x_input):
method init_weights (line 403) | def init_weights(self):
FILE: annotator/mmpkg/mmcv/cnn/bricks/hsigmoid.py
class HSigmoid (line 8) | class HSigmoid(nn.Module):
method __init__ (line 23) | def __init__(self, bias=1.0, divisor=2.0, min_value=0.0, max_value=1.0):
method forward (line 31) | def forward(self, x):
FILE: annotator/mmpkg/mmcv/cnn/bricks/hswish.py
class HSwish (line 8) | class HSwish(nn.Module):
method __init__ (line 24) | def __init__(self, inplace=False):
method forward (line 28) | def forward(self, x):
FILE: annotator/mmpkg/mmcv/cnn/bricks/non_local.py
class _NonLocalNd (line 12) | class _NonLocalNd(nn.Module, metaclass=ABCMeta):
method __init__ (line 35) | def __init__(self,
method init_weights (line 99) | def init_weights(self, std=0.01, zeros_init=True):
method gaussian (line 116) | def gaussian(self, theta_x, phi_x):
method embedded_gaussian (line 124) | def embedded_gaussian(self, theta_x, phi_x):
method dot_product (line 135) | def dot_product(self, theta_x, phi_x):
method concatenation (line 143) | def concatenation(self, theta_x, phi_x):
method forward (line 160) | def forward(self, x):
class NonLocal1d (line 214) | class NonLocal1d(_NonLocalNd):
method __init__ (line 226) | def __init__(self,
class NonLocal2d (line 246) | class NonLocal2d(_NonLocalNd):
method __init__ (line 260) | def __init__(self,
class NonLocal3d (line 279) | class NonLocal3d(_NonLocalNd):
method __init__ (line 291) | def __init__(self,
FILE: annotator/mmpkg/mmcv/cnn/bricks/norm.py
function infer_abbr (line 23) | def infer_abbr(class_type):
function build_norm_layer (line 72) | def build_norm_layer(cfg, num_features, postfix=''):
function is_norm (line 122) | def is_norm(layer, exclude=None):
FILE: annotator/mmpkg/mmcv/cnn/bricks/padding.py
function build_padding_layer (line 11) | def build_padding_layer(cfg, *args, **kwargs):
FILE: annotator/mmpkg/mmcv/cnn/bricks/plugin.py
function infer_abbr (line 12) | def infer_abbr(class_type):
function build_plugin_layer (line 55) | def build_plugin_layer(cfg, postfix='', **kwargs):
FILE: annotator/mmpkg/mmcv/cnn/bricks/scale.py
class Scale (line 6) | class Scale(nn.Module):
method __init__ (line 16) | def __init__(self, scale=1.0):
method forward (line 20) | def forward(self, x):
FILE: annotator/mmpkg/mmcv/cnn/bricks/swish.py
class Swish (line 9) | class Swish(nn.Module):
method __init__ (line 21) | def __init__(self):
method forward (line 24) | def forward(self, x):
FILE: annotator/mmpkg/mmcv/cnn/bricks/transformer.py
function build_positional_encoding (line 33) | def build_positional_encoding(cfg, default_args=None):
function build_attention (line 38) | def build_attention(cfg, default_args=None):
function build_feedforward_network (line 43) | def build_feedforward_network(cfg, default_args=None):
function build_transformer_layer (line 48) | def build_transformer_layer(cfg, default_args=None):
function build_transformer_layer_sequence (line 53) | def build_transformer_layer_sequence(cfg, default_args=None):
class MultiheadAttention (line 59) | class MultiheadAttention(BaseModule):
method __init__ (line 81) | def __init__(self,
method forward (line 112) | def forward(self,
class FFN (line 206) | class FFN(BaseModule):
method __init__ (line 234) | def __init__(self,
method forward (line 269) | def forward(self, x, identity=None):
class BaseTransformerLayer (line 283) | class BaseTransformerLayer(BaseModule):
method __init__ (line 319) | def __init__(self,
method forward (line 412) | def forward(self,
class TransformerLayerSequence (line 514) | class TransformerLayerSequence(BaseModule):
method __init__ (line 533) | def __init__(self, transformerlayers=None, num_layers=None, init_cfg=N...
method forward (line 549) | def forward(self,
FILE: annotator/mmpkg/mmcv/cnn/bricks/upsample.py
class PixelShufflePack (line 13) | class PixelShufflePack(nn.Module):
method __init__ (line 27) | def __init__(self, in_channels, out_channels, scale_factor,
method init_weights (line 41) | def init_weights(self):
method forward (line 44) | def forward(self, x):
function build_upsample_layer (line 50) | def build_upsample_layer(cfg, *args, **kwargs):
FILE: annotator/mmpkg/mmcv/cnn/bricks/wrappers.py
function obsolete_torch_version (line 24) | def obsolete_torch_version(torch_version, version_threshold):
class NewEmptyTensorOp (line 28) | class NewEmptyTensorOp(torch.autograd.Function):
method forward (line 31) | def forward(ctx, x, new_shape):
method backward (line 36) | def backward(ctx, grad):
class Conv2d (line 42) | class Conv2d(nn.Conv2d):
method forward (line 44) | def forward(self, x):
class Conv3d (line 63) | class Conv3d(nn.Conv3d):
method forward (line 65) | def forward(self, x):
class ConvTranspose2d (line 86) | class ConvTranspose2d(nn.ConvTranspose2d):
method forward (line 88) | def forward(self, x):
class ConvTranspose3d (line 109) | class ConvTranspose3d(nn.ConvTranspose3d):
method forward (line 111) | def forward(self, x):
class MaxPool2d (line 129) | class MaxPool2d(nn.MaxPool2d):
method forward (line 131) | def forward(self, x):
class MaxPool3d (line 147) | class MaxPool3d(nn.MaxPool3d):
method forward (line 149) | def forward(self, x):
class Linear (line 166) | class Linear(torch.nn.Linear):
method forward (line 168) | def forward(self, x):
FILE: annotator/mmpkg/mmcv/cnn/builder.py
function build_model_from_cfg (line 6) | def build_model_from_cfg(cfg, registry, default_args=None):
FILE: annotator/mmpkg/mmcv/cnn/resnet.py
function conv3x3 (line 10) | def conv3x3(in_planes, out_planes, stride=1, dilation=1):
class BasicBlock (line 22) | class BasicBlock(nn.Module):
method __init__ (line 25) | def __init__(self,
method forward (line 45) | def forward(self, x):
class Bottleneck (line 64) | class Bottleneck(nn.Module):
method __init__ (line 67) | def __init__(self,
method forward (line 110) | def forward(self, x):
function make_res_layer (line 143) | def make_res_layer(block,
class ResNet (line 181) | class ResNet(nn.Module):
method __init__ (line 210) | def __init__(self,
method init_weights (line 265) | def init_weights(self, pretrained=None):
method forward (line 279) | def forward(self, x):
method train (line 295) | def train(self, mode=True):
FILE: annotator/mmpkg/mmcv/cnn/utils/flops_counter.py
function get_model_complexity_info (line 36) | def get_model_complexity_info(model,
function flops_to_string (line 118) | def flops_to_string(flops, units='GFLOPs', precision=2):
function params_to_string (line 161) | def params_to_string(num_params, units=None, precision=2):
function print_model_with_flops (line 198) | def print_model_with_flops(model,
function get_model_parameters_number (line 307) | def get_model_parameters_number(model):
function add_flops_counting_methods (line 320) | def add_flops_counting_methods(net_main_module):
function compute_average_flops_cost (line 337) | def compute_average_flops_cost(self):
function start_flops_count (line 355) | def start_flops_count(self):
function stop_flops_count (line 378) | def stop_flops_count(self):
function reset_flops_count (line 389) | def reset_flops_count(self):
function empty_flops_counter_hook (line 400) | def empty_flops_counter_hook(module, input, output):
function upsample_flops_counter_hook (line 404) | def upsample_flops_counter_hook(module, input, output):
function relu_flops_counter_hook (line 413) | def relu_flops_counter_hook(module, input, output):
function linear_flops_counter_hook (line 418) | def linear_flops_counter_hook(module, input, output):
function pool_flops_counter_hook (line 425) | def pool_flops_counter_hook(module, input, output):
function norm_flops_counter_hook (line 430) | def norm_flops_counter_hook(module, input, output):
function deconv_flops_counter_hook (line 440) | def deconv_flops_counter_hook(conv_module, input, output):
function conv_flops_counter_hook (line 467) | def conv_flops_counter_hook(conv_module, input, output):
function batch_counter_hook (line 498) | def batch_counter_hook(module, input, output):
function add_batch_counter_variables_or_reset (line 511) | def add_batch_counter_variables_or_reset(module):
function add_batch_counter_hook_function (line 516) | def add_batch_counter_hook_function(module):
function remove_batch_counter_hook_function (line 524) | def remove_batch_counter_hook_function(module):
function add_flops_counter_variable_or_reset (line 530) | def add_flops_counter_variable_or_reset(module):
function is_supported_instance (line 540) | def is_supported_instance(module):
function remove_flops_counter_hook_function (line 546) | def remove_flops_counter_hook_function(module):
function get_modules_mapping (line 553) | def get_modules_mapping():
FILE: annotator/mmpkg/mmcv/cnn/utils/fuse_conv_bn.py
function _fuse_conv_bn (line 6) | def _fuse_conv_bn(conv, bn):
function fuse_conv_bn (line 27) | def fuse_conv_bn(module):
FILE: annotator/mmpkg/mmcv/cnn/utils/sync_bn.py
class _BatchNormXd (line 6) | class _BatchNormXd(torch.nn.modules.batchnorm._BatchNorm):
method _check_input_dim (line 17) | def _check_input_dim(self, input):
function revert_sync_batchnorm (line 21) | def revert_sync_batchnorm(module):
FILE: annotator/mmpkg/mmcv/cnn/utils/weight_init.py
function update_init_info (line 16) | def update_init_info(module, init_info):
function constant_init (line 48) | def constant_init(module, val, bias=0):
function xavier_init (line 55) | def xavier_init(module, gain=1, bias=0, distribution='normal'):
function normal_init (line 66) | def normal_init(module, mean=0, std=1, bias=0):
function trunc_normal_init (line 73) | def trunc_normal_init(module: nn.Module,
function uniform_init (line 85) | def uniform_init(module, a=0, b=1, bias=0):
function kaiming_init (line 92) | def kaiming_init(module,
function caffe2_xavier_init (line 110) | def caffe2_xavier_init(module, bias=0):
function bias_init_with_prob (line 122) | def bias_init_with_prob(prior_prob):
function _get_bases_name (line 128) | def _get_bases_name(m):
class BaseInit (line 132) | class BaseInit(object):
method __init__ (line 134) | def __init__(self, *, bias=0, bias_prob=None, layer=None):
method _get_init_info (line 157) | def _get_init_info(self):
class ConstantInit (line 163) | class ConstantInit(BaseInit):
method __init__ (line 175) | def __init__(self, val, **kwargs):
method __call__ (line 179) | def __call__(self, module):
method _get_init_info (line 194) | def _get_init_info(self):
class XavierInit (line 200) | class XavierInit(BaseInit):
method __init__ (line 217) | def __init__(self, gain=1, distribution='normal', **kwargs):
method __call__ (line 222) | def __call__(self, module):
method _get_init_info (line 237) | def _get_init_info(self):
class NormalInit (line 244) | class NormalInit(BaseInit):
method __init__ (line 260) | def __init__(self, mean=0, std=1, **kwargs):
method __call__ (line 265) | def __call__(self, module):
method _get_init_info (line 280) | def _get_init_info(self):
class TruncNormalInit (line 287) | class TruncNormalInit(BaseInit):
method __init__ (line 306) | def __init__(self,
method __call__ (line 318) | def __call__(self, module: nn.Module) -> None:
method _get_init_info (line 335) | def _get_init_info(self):
class UniformInit (line 342) | class UniformInit(BaseInit):
method __init__ (line 358) | def __init__(self, a=0, b=1, **kwargs):
method __call__ (line 363) | def __call__(self, module):
method _get_init_info (line 378) | def _get_init_info(self):
class KaimingInit (line 385) | class KaimingInit(BaseInit):
method __init__ (line 411) | def __init__(self,
method __call__ (line 423) | def __call__(self, module):
method _get_init_info (line 440) | def _get_init_info(self):
class Caffe2XavierInit (line 448) | class Caffe2XavierInit(KaimingInit):
method __init__ (line 451) | def __init__(self, **kwargs):
method __call__ (line 459) | def __call__(self, module):
class PretrainedInit (line 464) | class PretrainedInit(object):
method __init__ (line 478) | def __init__(self, checkpoint, prefix=None, map_location=None):
method __call__ (line 483) | def __call__(self, module):
method _get_init_info (line 506) | def _get_init_info(self):
function _initialize (line 511) | def _initialize(module, cfg, wholemodule=False):
function _initialize_override (line 520) | def _initialize_override(module, override, cfg):
function initialize (line 550) | def initialize(module, init_cfg):
function _no_grad_trunc_normal_ (line 622) | def _no_grad_trunc_normal_(tensor: Tensor, mean: float, std: float, a: f...
function trunc_normal_ (line 662) | def trunc_normal_(tensor: Tensor,
FILE: annotator/mmpkg/mmcv/cnn/vgg.py
function conv3x3 (line 9) | def conv3x3(in_planes, out_planes, dilation=1):
function make_vgg_layer (line 19) | def make_vgg_layer(inplanes,
class VGG (line 37) | class VGG(nn.Module):
method __init__ (line 61) | def __init__(self,
method init_weights (line 125) | def init_weights(self, pretrained=None):
method forward (line 141) | def forward(self, x):
method train (line 159) | def train(self, mode=True):
FILE: annotator/mmpkg/mmcv/engine/test.py
function single_gpu_test (line 15) | def single_gpu_test(model, data_loader):
function multi_gpu_test (line 44) | def multi_gpu_test(model, data_loader, tmpdir=None, gpu_collect=False):
function collect_results_cpu (line 91) | def collect_results_cpu(result_part, size, tmpdir=None):
function collect_results_gpu (line 155) | def collect_results_gpu(result_part, size):
FILE: annotator/mmpkg/mmcv/fileio/file_client.py
class BaseStorageBackend (line 19) | class BaseStorageBackend(metaclass=ABCMeta):
method name (line 31) | def name(self):
method allow_symlink (line 35) | def allow_symlink(self):
method get (line 39) | def get(self, filepath):
method get_text (line 43) | def get_text(self, filepath):
class CephBackend (line 47) | class CephBackend(BaseStorageBackend):
method __init__ (line 60) | def __init__(self, path_mapping=None):
method get (line 72) | def get(self, filepath):
method get_text (line 81) | def get_text(self, filepath, encoding=None):
class PetrelBackend (line 85) | class PetrelBackend(BaseStorageBackend):
method __init__ (line 108) | def __init__(self,
method _map_path (line 121) | def _map_path(self, filepath: Union[str, Path]) -> str:
method _format_path (line 134) | def _format_path(self, filepath: str) -> str:
method get (line 147) | def get(self, filepath: Union[str, Path]) -> memoryview:
method get_text (line 164) | def get_text(self,
method put (line 179) | def put(self, obj: bytes, filepath: Union[str, Path]) -> None:
method put_text (line 190) | def put_text(self,
method remove (line 204) | def remove(self, filepath: Union[str, Path]) -> None:
method exists (line 220) | def exists(self, filepath: Union[str, Path]) -> bool:
method isdir (line 240) | def isdir(self, filepath: Union[str, Path]) -> bool:
method isfile (line 261) | def isfile(self, filepath: Union[str, Path]) -> bool:
method join_path (line 281) | def join_path(self, filepath: Union[str, Path],
method get_local_path (line 300) | def get_local_path(self, filepath: Union[str, Path]) -> Iterable[str]:
method list_dir_or_file (line 331) | def list_dir_or_file(self,
class MemcachedBackend (line 413) | class MemcachedBackend(BaseStorageBackend):
method __init__ (line 423) | def __init__(self, server_list_cfg, client_cfg, sys_path=None):
method get (line 440) | def get(self, filepath):
method get_text (line 447) | def get_text(self, filepath, encoding=None):
class LmdbBackend (line 451) | class LmdbBackend(BaseStorageBackend):
method __init__ (line 469) | def __init__(self,
method get (line 488) | def get(self, filepath):
method get_text (line 499) | def get_text(self, filepath, encoding=None):
class HardDiskBackend (line 503) | class HardDiskBackend(BaseStorageBackend):
method get (line 508) | def get(self, filepath: Union[str, Path]) -> bytes:
method get_text (line 521) | def get_text(self,
method put (line 538) | def put(self, obj: bytes, filepath: Union[str, Path]) -> None:
method put_text (line 553) | def put_text(self,
method remove (line 573) | def remove(self, filepath: Union[str, Path]) -> None:
method exists (line 581) | def exists(self, filepath: Union[str, Path]) -> bool:
method isdir (line 592) | def isdir(self, filepath: Union[str, Path]) -> bool:
method isfile (line 605) | def isfile(self, filepath: Union[str, Path]) -> bool:
method join_path (line 617) | def join_path(self, filepath: Union[str, Path],
method get_local_path (line 633) | def get_local_path(
method list_dir_or_file (line 638) | def list_dir_or_file(self,
class HTTPBackend (line 691) | class HTTPBackend(BaseStorageBackend):
method get (line 694) | def get(self, filepath):
method get_text (line 698) | def get_text(self, filepath, encoding='utf-8'):
method get_local_path (line 703) | def get_local_path(self, filepath: str) -> Iterable[str]:
class FileClient (line 729) | class FileClient:
method __new__ (line 787) | def __new__(cls, backend=None, prefix=None, **kwargs):
method name (line 823) | def name(self):
method allow_symlink (line 827) | def allow_symlink(self):
method parse_uri_prefix (line 831) | def parse_uri_prefix(uri: Union[str, Path]) -> Optional[str]:
method infer_client (line 858) | def infer_client(cls,
method _register_backend (line 886) | def _register_backend(cls, name, backend, force=False, prefixes=None):
method register_backend (line 922) | def register_backend(cls, name, backend=None, force=False, prefixes=No...
method get (line 976) | def get(self, filepath: Union[str, Path]) -> Union[bytes, memoryview]:
method get_text (line 994) | def get_text(self, filepath: Union[str, Path], encoding='utf-8') -> str:
method put (line 1007) | def put(self, obj: bytes, filepath: Union[str, Path]) -> None:
method put_text (line 1020) | def put_text(self, obj: str, filepath: Union[str, Path]) -> None:
method remove (line 1035) | def remove(self, filepath: Union[str, Path]) -> None:
method exists (line 1043) | def exists(self, filepath: Union[str, Path]) -> bool:
method isdir (line 1054) | def isdir(self, filepath: Union[str, Path]) -> bool:
method isfile (line 1067) | def isfile(self, filepath: Union[str, Path]) -> bool:
method join_path (line 1079) | def join_path(self, filepath: Union[str, Path],
method get_local_path (line 1095) | def get_local_path(self, filepath: Union[str, Path]) -> Iterable[str]:
method list_dir_or_file (line 1123) | def list_dir_or_file(self,
FILE: annotator/mmpkg/mmcv/fileio/handlers/base.py
class BaseFileHandler (line 5) | class BaseFileHandler(metaclass=ABCMeta):
method load_from_fileobj (line 13) | def load_from_fileobj(self, file, **kwargs):
method dump_to_fileobj (line 17) | def dump_to_fileobj(self, obj, file, **kwargs):
method dump_to_str (line 21) | def dump_to_str(self, obj, **kwargs):
method load_from_path (line 24) | def load_from_path(self, filepath, mode='r', **kwargs):
method dump_to_path (line 28) | def dump_to_path(self, obj, filepath, mode='w', **kwargs):
FILE: annotator/mmpkg/mmcv/fileio/handlers/json_handler.py
function set_default (line 9) | def set_default(obj):
class JsonHandler (line 25) | class JsonHandler(BaseFileHandler):
method load_from_fileobj (line 27) | def load_from_fileobj(self, file):
method dump_to_fileobj (line 30) | def dump_to_fileobj(self, obj, file, **kwargs):
method dump_to_str (line 34) | def dump_to_str(self, obj, **kwargs):
FILE: annotator/mmpkg/mmcv/fileio/handlers/pickle_handler.py
class PickleHandler (line 7) | class PickleHandler(BaseFileHandler):
method load_from_fileobj (line 11) | def load_from_fileobj(self, file, **kwargs):
method load_from_path (line 14) | def load_from_path(self, filepath, **kwargs):
method dump_to_str (line 18) | def dump_to_str(self, obj, **kwargs):
method dump_to_fileobj (line 22) | def dump_to_fileobj(self, obj, file, **kwargs):
method dump_to_path (line 26) | def dump_to_path(self, obj, filepath, **kwargs):
FILE: annotator/mmpkg/mmcv/fileio/handlers/yaml_handler.py
class YamlHandler (line 12) | class YamlHandler(BaseFileHandler):
method load_from_fileobj (line 14) | def load_from_fileobj(self, file, **kwargs):
method dump_to_fileobj (line 18) | def dump_to_fileobj(self, obj, file, **kwargs):
method dump_to_str (line 22) | def dump_to_str(self, obj, **kwargs):
FILE: annotator/mmpkg/mmcv/fileio/io.py
function load (line 18) | def load(file, file_format=None, file_client_args=None, **kwargs):
function dump (line 69) | def dump(obj, file=None, file_format=None, file_client_args=None, **kwar...
function _register_handler (line 126) | def _register_handler(handler, file_formats):
function register_handler (line 145) | def register_handler(file_formats, **kwargs):
FILE: annotator/mmpkg/mmcv/fileio/parse.py
function list_from_file (line 8) | def list_from_file(filename,
function dict_from_file (line 55) | def dict_from_file(filename,
FILE: annotator/mmpkg/mmcv/image/colorspace.py
function imconvert (line 6) | def imconvert(img, src, dst):
function bgr2gray (line 22) | def bgr2gray(img, keepdim=False):
function rgb2gray (line 39) | def rgb2gray(img, keepdim=False):
function gray2bgr (line 56) | def gray2bgr(img):
function gray2rgb (line 70) | def gray2rgb(img):
function _convert_input_type_range (line 84) | def _convert_input_type_range(img):
function _convert_output_type_range (line 112) | def _convert_output_type_range(img, dst_type):
function rgb2ycbcr (line 143) | def rgb2ycbcr(img, y_only=False):
function bgr2ycbcr (line 177) | def bgr2ycbcr(img, y_only=False):
function ycbcr2rgb (line 211) | def ycbcr2rgb(img):
function ycbcr2bgr (line 243) | def ycbcr2bgr(img):
function convert_color_factory (line 275) | def convert_color_factory(src, dst):
FILE: annotator/mmpkg/mmcv/image/geometric.py
function _scale_size (line 16) | def _scale_size(size, scale):
function imresize (line 51) | def imresize(img,
function imresize_to_multiple (line 98) | def imresize_to_multiple(img,
function imresize_like (line 162) | def imresize_like(img,
function rescale_size (line 184) | def rescale_size(old_size, scale, return_scale=False):
function imrescale (line 221) | def imrescale(img,
function imflip (line 252) | def imflip(img, direction='horizontal'):
function imflip_ (line 272) | def imflip_(img, direction='horizontal'):
function imrotate (line 292) | def imrotate(img,
function bbox_clip (line 342) | def bbox_clip(bboxes, img_shape):
function bbox_scaling (line 360) | def bbox_scaling(bboxes, scale, clip_shape=None):
function imcrop (line 386) | def imcrop(img, bboxes, scale=1.0, pad_fill=None):
function impad (line 440) | def impad(img,
function impad_to_multiple (line 522) | def impad_to_multiple(img, divisor, pad_val=0):
function cutout (line 538) | def cutout(img, shape, pad_val=0):
function _get_shear_matrix (line 593) | def _get_shear_matrix(magnitude, direction='horizontal'):
function imshear (line 611) | def imshear(img,
function _get_translate_matrix (line 662) | def _get_translate_matrix(offset, direction='horizontal'):
function imtranslate (line 680) | def imtranslate(img,
FILE: annotator/mmpkg/mmcv/image/io.py
function use_backend (line 43) | def use_backend(backend):
function _jpegflag (line 69) | def _jpegflag(flag='color', channel_order='bgr'):
function _pillow2array (line 85) | def _pillow2array(img, flag='color', channel_order='bgr'):
function imread (line 140) | def imread(img_or_path, flag='color', channel_order='bgr', backend=None):
function imfrombytes (line 203) | def imfrombytes(content, flag='color', channel_order='bgr', backend=None):
function imwrite (line 242) | def imwrite(img, file_path, params=None, auto_mkdir=True):
FILE: annotator/mmpkg/mmcv/image/misc.py
function tensor2imgs (line 12) | def tensor2imgs(tensor, mean=(0, 0, 0), std=(1, 1, 1), to_rgb=True):
FILE: annotator/mmpkg/mmcv/image/photometric.py
function imnormalize (line 9) | def imnormalize(img, mean, std, to_rgb=True):
function imnormalize_ (line 25) | def imnormalize_(img, mean, std, to_rgb=True):
function imdenormalize (line 48) | def imdenormalize(img, mean, std, to_bgr=True):
function iminvert (line 59) | def iminvert(img):
function solarize (line 71) | def solarize(img, thr=128):
function posterize (line 85) | def posterize(img, bits):
function adjust_color (line 100) | def adjust_color(img, alpha=1, beta=None, gamma=0):
function imequalize (line 131) | def imequalize(img):
function adjust_brightness (line 176) | def adjust_brightness(img, factor=1.):
function adjust_contrast (line 208) | def adjust_contrast(img, factor=1.):
function auto_contrast (line 238) | def auto_contrast(img, cutoff=0):
function adjust_sharpness (line 294) | def adjust_sharpness(img, factor=1., kernel=None):
function adjust_lighting (line 338) | def adjust_lighting(img, eigval, eigvec, alphastd=0.1, to_rgb=True):
function lut_transform (line 381) | def lut_transform(img, lut_table):
function clahe (line 405) | def clahe(img, clip_limit=40.0, tile_grid_size=(8, 8)):
FILE: annotator/mmpkg/mmcv/ops/assign_score_withk.py
class AssignScoreWithK (line 9) | class AssignScoreWithK(Function):
method forward (line 29) | def forward(ctx,
method backward (line 81) | def backward(ctx, grad_out):
FILE: annotator/mmpkg/mmcv/ops/ball_query.py
class BallQuery (line 10) | class BallQuery(Function):
method forward (line 14) | def forward(ctx, min_radius: float, max_radius: float, sample_num: int,
method backward (line 51) | def backward(ctx, a=None):
FILE: annotator/mmpkg/mmcv/ops/bbox.py
function bbox_overlaps (line 7) | def bbox_overlaps(bboxes1, bboxes2, mode='iou', aligned=False, offset=0):
FILE: annotator/mmpkg/mmcv/ops/border_align.py
class BorderAlignFunction (line 16) | class BorderAlignFunction(Function):
method symbolic (line 19) | def symbolic(g, input, boxes, pool_size):
method forward (line 24) | def forward(ctx, input, boxes, pool_size):
method backward (line 48) | def backward(ctx, grad_output):
class BorderAlign (line 65) | class BorderAlign(nn.Module):
method __init__ (line 88) | def __init__(self, pool_size):
method forward (line 92) | def forward(self, input, boxes):
method __repr__ (line 106) | def __repr__(self):
FILE: annotator/mmpkg/mmcv/ops/box_iou_rotated.py
function box_iou_rotated (line 7) | def box_iou_rotated(bboxes1, bboxes2, mode='iou', aligned=False):
FILE: annotator/mmpkg/mmcv/ops/carafe.py
class CARAFENaiveFunction (line 17) | class CARAFENaiveFunction(Function):
method symbolic (line 20) | def symbolic(g, features, masks, kernel_size, group_size, scale_factor):
method forward (line 30) | def forward(ctx, features, masks, kernel_size, group_size, scale_factor):
method backward (line 58) | def backward(ctx, grad_output):
class CARAFENaive (line 84) | class CARAFENaive(Module):
method __init__ (line 86) | def __init__(self, kernel_size, group_size, scale_factor):
method forward (line 95) | def forward(self, features, masks):
class CARAFEFunction (line 100) | class CARAFEFunction(Function):
method symbolic (line 103) | def symbolic(g, features, masks, kernel_size, group_size, scale_factor):
method forward (line 113) | def forward(ctx, features, masks, kernel_size, group_size, scale_factor):
method backward (line 147) | def backward(ctx, grad_output):
class CARAFE (line 180) | class CARAFE(Module):
method __init__ (line 194) | def __init__(self, kernel_size, group_size, scale_factor):
method forward (line 203) | def forward(self, features, masks):
class CARAFEPack (line 209) | class CARAFEPack(nn.Module):
method __init__ (line 230) | def __init__(self,
method init_weights (line 258) | def init_weights(self):
method kernel_normalizer (line 264) | def kernel_normalizer(self, mask):
method feature_reassemble (line 277) | def feature_reassemble(self, x, mask):
method forward (line 281) | def forward(self, x):
FILE: annotator/mmpkg/mmcv/ops/cc_attention.py
function NEG_INF_DIAG (line 9) | def NEG_INF_DIAG(n, device):
class CrissCrossAttention (line 19) | class CrissCrossAttention(nn.Module):
method __init__ (line 44) | def __init__(self, in_channels):
method forward (line 52) | def forward(self, x):
method __repr__ (line 80) | def __repr__(self):
FILE: annotator/mmpkg/mmcv/ops/contour_expand.py
function contour_expand (line 10) | def contour_expand(kernel_mask, internal_kernel_label, min_kernel_area,
FILE: annotator/mmpkg/mmcv/ops/corner_pool.py
class TopPoolFunction (line 17) | class TopPoolFunction(Function):
method symbolic (line 20) | def symbolic(g, input):
method forward (line 26) | def forward(ctx, input):
method backward (line 32) | def backward(ctx, grad_output):
class BottomPoolFunction (line 38) | class BottomPoolFunction(Function):
method symbolic (line 41) | def symbolic(g, input):
method forward (line 47) | def forward(ctx, input):
method backward (line 53) | def backward(ctx, grad_output):
class LeftPoolFunction (line 59) | class LeftPoolFunction(Function):
method symbolic (line 62) | def symbolic(g, input):
method forward (line 68) | def forward(ctx, input):
method backward (line 74) | def backward(ctx, grad_output):
class RightPoolFunction (line 80) | class RightPoolFunction(Function):
method symbolic (line 83) | def symbolic(g, input):
method forward (line 89) | def forward(ctx, input):
method backward (line 95) | def backward(ctx, grad_output):
class CornerPool (line 101) | class CornerPool(nn.Module):
method __init__ (line 136) | def __init__(self, mode):
method forward (line 142) | def forward(self, x):
FILE: annotator/mmpkg/mmcv/ops/correlation.py
class CorrelationFunction (line 14) | class CorrelationFunction(Function):
method forward (line 17) | def forward(ctx,
method backward (line 63) | def backward(ctx, grad_output):
method _output_size (line 96) | def _output_size(ctx, input1):
class Correlation (line 114) | class Correlation(nn.Module):
method __init__ (line 167) | def __init__(self,
method forward (line 182) | def forward(self, input1: Tensor, input2: Tensor) -> Tensor:
method __repr__ (line 188) | def __repr__(self) -> str:
FILE: annotator/mmpkg/mmcv/ops/deform_conv.py
class DeformConv2dFunction (line 22) | class DeformConv2dFunction(Function):
method symbolic (line 25) | def symbolic(g,
method forward (line 50) | def forward(ctx,
method backward (line 114) | def backward(ctx, grad_output):
method _output_size (line 173) | def _output_size(ctx, input, weight):
class DeformConv2d (line 192) | class DeformConv2d(nn.Module):
method __init__ (line 228) | def __init__(self,
method reset_parameters (line 269) | def reset_parameters(self):
method forward (line 276) | def forward(self, x: Tensor, offset: Tensor) -> Tensor:
method __repr__ (line 315) | def __repr__(self):
class DeformConv2dPack (line 331) | class DeformConv2dPack(DeformConv2d):
method __init__ (line 358) | def __init__(self, *args, **kwargs):
method init_offset (line 370) | def init_offset(self):
method forward (line 374) | def forward(self, x):
method _load_from_state_dict (line 380) | def _load_from_state_dict(self, state_dict, prefix, local_metadata, st...
FILE: annotator/mmpkg/mmcv/ops/deform_roi_pool.py
class DeformRoIPoolFunction (line 13) | class DeformRoIPoolFunction(Function):
method symbolic (line 16) | def symbolic(g, input, rois, offset, output_size, spatial_scale,
method forward (line 30) | def forward(ctx,
method backward (line 67) | def backward(ctx, grad_output):
class DeformRoIPool (line 92) | class DeformRoIPool(nn.Module):
method __init__ (line 94) | def __init__(self,
method forward (line 105) | def forward(self, input, rois, offset=None):
class DeformRoIPoolPack (line 111) | class DeformRoIPoolPack(DeformRoIPool):
method __init__ (line 113) | def __init__(self,
method forward (line 138) | def forward(self, input, rois):
class ModulatedDeformRoIPoolPack (line 152) | class ModulatedDeformRoIPoolPack(DeformRoIPool):
method __init__ (line 154) | def __init__(self,
method forward (line 190) | def forward(self, input, rois):
FILE: annotator/mmpkg/mmcv/ops/deprecated_wrappers.py
class Conv2d_deprecated (line 9) | class Conv2d_deprecated(Conv2d):
method __init__ (line 11) | def __init__(self, *args, **kwargs):
class ConvTranspose2d_deprecated (line 18) | class ConvTranspose2d_deprecated(ConvTranspose2d):
method __init__ (line 20) | def __init__(self, *args, **kwargs):
class MaxPool2d_deprecated (line 28) | class MaxPool2d_deprecated(MaxPool2d):
method __init__ (line 30) | def __init__(self, *args, **kwargs):
class Linear_deprecated (line 37) | class Linear_deprecated(Linear):
method __init__ (line 39) | def __init__(self, *args, **kwargs):
FILE: annotator/mmpkg/mmcv/ops/focal_loss.py
class SigmoidFocalLossFunction (line 15) | class SigmoidFocalLossFunction(Function):
method symbolic (line 18) | def symbolic(g, input, target, gamma, alpha, weight, reduction):
method forward (line 29) | def forward(ctx,
method backward (line 66) | def backward(ctx, grad_output):
class SigmoidFocalLoss (line 88) | class SigmoidFocalLoss(nn.Module):
method __init__ (line 90) | def __init__(self, gamma, alpha, weight=None, reduction='mean'):
method forward (line 97) | def forward(self, input, target):
method __repr__ (line 101) | def __repr__(self):
class SoftmaxFocalLossFunction (line 109) | class SoftmaxFocalLossFunction(Function):
method symbolic (line 112) | def symbolic(g, input, target, gamma, alpha, weight, reduction):
method forward (line 123) | def forward(ctx,
method backward (line 171) | def backward(ctx, grad_output):
class SoftmaxFocalLoss (line 194) | class SoftmaxFocalLoss(nn.Module):
method __init__ (line 196) | def __init__(self, gamma, alpha, weight=None, reduction='mean'):
method forward (line 203) | def forward(self, input, target):
method __repr__ (line 207) | def __repr__(self):
FILE: annotator/mmpkg/mmcv/ops/furthest_point_sample.py
class FurthestPointSampling (line 12) | class FurthestPointSampling(Function):
method forward (line 17) | def forward(ctx, points_xyz: torch.Tensor,
method backward (line 46) | def backward(xyz, a=None):
class FurthestPointSamplingWithDist (line 50) | class FurthestPointSamplingWithDist(Function):
method forward (line 55) | def forward(ctx, points_dist: torch.Tensor,
method backward (line 78) | def backward(xyz, a=None):
FILE: annotator/mmpkg/mmcv/ops/fused_bias_leakyrelu.py
class FusedBiasLeakyReLUFunctionBackward (line 108) | class FusedBiasLeakyReLUFunctionBackward(Function):
method forward (line 116) | def forward(ctx, grad_output, out, negative_slope, scale):
method backward (line 142) | def backward(ctx, gradgrad_input, gradgrad_bias):
class FusedBiasLeakyReLUFunction (line 160) | class FusedBiasLeakyReLUFunction(Function):
method forward (line 163) | def forward(ctx, input, bias, negative_slope, scale):
method backward (line 181) | def backward(ctx, grad_output):
class FusedBiasLeakyReLU (line 190) | class FusedBiasLeakyReLU(nn.Module):
method __init__ (line 213) | def __init__(self, num_channels, negative_slope=0.2, scale=2**0.5):
method forward (line 220) | def forward(self, input):
function fused_bias_leakyrelu (line 225) | def fused_bias_leakyrelu(input, bias, negative_slope=0.2, scale=2**0.5):
function bias_leakyrelu_ref (line 257) | def bias_leakyrelu_ref(x, bias, negative_slope=0.2, scale=2**0.5):
FILE: annotator/mmpkg/mmcv/ops/gather_points.py
class GatherPoints (line 10) | class GatherPoints(Function):
method forward (line 14) | def forward(ctx, features: torch.Tensor,
method backward (line 40) | def backward(ctx, grad_out):
FILE: annotator/mmpkg/mmcv/ops/group_points.py
class QueryAndGroup (line 16) | class QueryAndGroup(nn.Module):
method __init__ (line 39) | def __init__(self,
method forward (line 67) | def forward(self, points_xyz, center_xyz, features=None):
class GroupAll (line 134) | class GroupAll(nn.Module):
method __init__ (line 141) | def __init__(self, use_xyz: bool = True):
method forward (line 145) | def forward(self,
class GroupingOperation (line 173) | class GroupingOperation(Function):
method forward (line 177) | def forward(ctx, features: torch.Tensor,
method backward (line 202) | def backward(ctx,
FILE: annotator/mmpkg/mmcv/ops/info.py
function get_compiler_version (line 10) | def get_compiler_version():
function get_compiling_cuda_version (line 13) | def get_compiling_cuda_version():
function get_compiler_version (line 20) | def get_compiler_version():
function get_compiling_cuda_version (line 23) | def get_compiling_cuda_version():
function get_onnxruntime_op_path (line 27) | def get_onnxruntime_op_path():
FILE: annotator/mmpkg/mmcv/ops/iou3d.py
function boxes_iou_bev (line 12) | def boxes_iou_bev(boxes_a, boxes_b):
function nms_bev (line 31) | def nms_bev(boxes, scores, thresh, pre_max_size=None, post_max_size=None):
function nms_normal_bev (line 65) | def nms_normal_bev(boxes, scores, thresh):
FILE: annotator/mmpkg/mmcv/ops/knn.py
class KNN (line 9) | class KNN(Function):
method forward (line 18) | def forward(ctx,
method backward (line 73) | def backward(ctx, a=None):
FILE: annotator/mmpkg/mmcv/ops/masked_conv.py
class MaskedConv2dFunction (line 16) | class MaskedConv2dFunction(Function):
method symbolic (line 19) | def symbolic(g, features, mask, weight, bias, padding, stride):
method forward (line 30) | def forward(ctx, features, mask, weight, bias, padding=0, stride=1):
method backward (line 79) | def backward(ctx, grad_output):
class MaskedConv2d (line 86) | class MaskedConv2d(nn.Conv2d):
method __init__ (line 93) | def __init__(self,
method forward (line 106) | def forward(self, input, mask=None):
FILE: annotator/mmpkg/mmcv/ops/merge_cells.py
class BaseMergeCell (line 11) | class BaseMergeCell(nn.Module):
method __init__ (line 43) | def __init__(self,
method _build_input_conv (line 78) | def _build_input_conv(self, channel, conv_cfg, norm_cfg):
method _binary_op (line 89) | def _binary_op(self, x1, x2):
method _resize (line 92) | def _resize(self, x, size):
method forward (line 103) | def forward(self, x1, x2, out_size=None):
class SumCell (line 121) | class SumCell(BaseMergeCell):
method __init__ (line 123) | def __init__(self, in_channels, out_channels, **kwargs):
method _binary_op (line 126) | def _binary_op(self, x1, x2):
class ConcatCell (line 130) | class ConcatCell(BaseMergeCell):
method __init__ (line 132) | def __init__(self, in_channels, out_channels, **kwargs):
method _binary_op (line 136) | def _binary_op(self, x1, x2):
class GlobalPoolingCell (line 141) | class GlobalPoolingCell(BaseMergeCell):
method __init__ (line 143) | def __init__(self, in_channels=None, out_channels=None, **kwargs):
method _binary_op (line 147) | def _binary_op(self, x1, x2):
FILE: annotator/mmpkg/mmcv/ops/modulated_deform_conv.py
class ModulatedDeformConv2dFunction (line 19) | class ModulatedDeformConv2dFunction(Function):
method symbolic (line 22) | def symbolic(g, input, offset, mask, weight, bias, stride, padding,
method forward (line 37) | def forward(ctx,
method backward (line 97) | def backward(ctx, grad_output):
method _output_size (line 137) | def _output_size(ctx, input, weight):
class ModulatedDeformConv2d (line 156) | class ModulatedDeformConv2d(nn.Module):
method __init__ (line 160) | def __init__(self,
method init_weights (line 192) | def init_weights(self):
method forward (line 201) | def forward(self, x, offset, mask):
class ModulatedDeformConv2dPack (line 209) | class ModulatedDeformConv2dPack(ModulatedDeformConv2d):
method __init__ (line 228) | def __init__(self, *args, **kwargs):
method init_weights (line 240) | def init_weights(self):
method forward (line 246) | def forward(self, x):
method _load_from_state_dict (line 256) | def _load_from_state_dict(self, state_dict, prefix, local_metadata, st...
FILE: annotator/mmpkg/mmcv/ops/multi_scale_deform_attn.py
class MultiScaleDeformableAttnFunction (line 20) | class MultiScaleDeformableAttnFunction(Function):
method forward (line 23) | def forward(ctx, value, value_spatial_shapes, value_level_start_index,
method backward (line 61) | def backward(ctx, grad_output):
function multi_scale_deformable_attn_pytorch (line 94) | def multi_scale_deformable_attn_pytorch(value, value_spatial_shapes,
class MultiScaleDeformableAttention (line 155) | class MultiScaleDeformableAttention(BaseModule):
method __init__ (line 182) | def __init__(self,
method init_weights (line 230) | def init_weights(self):
method forward (line 252) | def forward(self,
FILE: annotator/mmpkg/mmcv/ops/nms.py
class NMSop (line 14) | class NMSop(torch.autograd.Function):
method forward (line 17) | def forward(ctx, bboxes, scores, iou_threshold, offset, score_threshold,
method symbolic (line 36) | def symbolic(g, bboxes, scores, iou_threshold, offset, score_threshold,
class SoftNMSop (line 82) | class SoftNMSop(torch.autograd.Function):
method forward (line 85) | def forward(ctx, boxes, scores, iou_threshold, sigma, min_score, method,
method symbolic (line 100) | def symbolic(g, boxes, scores, iou_threshold, sigma, min_score, method,
function nms (line 118) | def nms(boxes, scores, iou_threshold, offset=0, score_threshold=0, max_n...
function soft_nms (line 181) | def soft_nms(boxes,
function batched_nms (line 260) | def batched_nms(boxes, scores, idxs, nms_cfg, class_agnostic=False):
function nms_match (line 339) | def nms_match(dets, iou_threshold):
function nms_rotated (line 376) | def nms_rotated(dets, scores, iou_threshold, labels=None):
FILE: annotator/mmpkg/mmcv/ops/pixel_group.py
function pixel_group (line 10) | def pixel_group(score, mask, embedding, kernel_label, kernel_contour,
FILE: annotator/mmpkg/mmcv/ops/point_sample.py
function bilinear_grid_sample (line 12) | def bilinear_grid_sample(im, grid, align_corners=False):
function is_in_onnx_export_without_custom_ops (line 87) | def is_in_onnx_export_without_custom_ops():
function normalize (line 94) | def normalize(grid):
function denormalize (line 105) | def denormalize(grid):
function generate_grid (line 116) | def generate_grid(num_grid, size, device):
function rel_roi_point_to_abs_img_point (line 137) | def rel_roi_point_to_abs_img_point(rois, rel_roi_points):
function get_shape_from_feature_map (line 168) | def get_shape_from_feature_map(x):
function abs_img_point_to_rel_img_point (line 186) | def abs_img_point_to_rel_img_point(abs_img_points, img, spatial_scale=1.):
function rel_roi_point_to_rel_img_point (line 216) | def rel_roi_point_to_rel_img_point(rois,
function point_sample (line 242) | def point_sample(input, points, align_corners=False, **kwargs):
class SimpleRoIAlign (line 276) | class SimpleRoIAlign(nn.Module):
method __init__ (line 278) | def __init__(self, output_size, spatial_scale, aligned=True):
method forward (line 296) | def forward(self, features, rois):
method __repr__ (line 332) | def __repr__(self):
FILE: annotator/mmpkg/mmcv/ops/points_in_boxes.py
function points_in_boxes_part (line 11) | def points_in_boxes_part(points, boxes):
function points_in_boxes_cpu (line 58) | def points_in_boxes_cpu(points, boxes):
function points_in_boxes_all (line 95) | def points_in_boxes_all(points, boxes):
FILE: annotator/mmpkg/mmcv/ops/points_sampler.py
function calc_square_dist (line 11) | def calc_square_dist(point_feat_a, point_feat_b, norm=True):
function get_sampler_cls (line 37) | def get_sampler_cls(sampler_type):
class PointsSampler (line 60) | class PointsSampler(nn.Module):
method __init__ (line 74) | def __init__(self,
method forward (line 92) | def forward(self, points_xyz, features):
class DFPSSampler (line 133) | class DFPSSampler(nn.Module):
method __init__ (line 136) | def __init__(self):
method forward (line 139) | def forward(self, points, features, npoint):
class FFPSSampler (line 145) | class FFPSSampler(nn.Module):
method __init__ (line 148) | def __init__(self):
method forward (line 151) | def forward(self, points, features, npoint):
class FSSampler (line 162) | class FSSampler(nn.Module):
method __init__ (line 165) | def __init__(self):
method forward (line 168) | def forward(self, points, features, npoint):
FILE: annotator/mmpkg/mmcv/ops/psa_mask.py
class PSAMaskFunction (line 12) | class PSAMaskFunction(Function):
method symbolic (line 15) | def symbolic(g, input, psa_type, mask_size):
method forward (line 23) | def forward(ctx, input, psa_type, mask_size):
method backward (line 48) | def backward(ctx, grad_output):
class PSAMask (line 72) | class PSAMask(nn.Module):
method __init__ (line 74) | def __init__(self, psa_type, mask_size=None):
method forward (line 85) | def forward(self, input):
method __repr__ (line 88) | def __repr__(self):
FILE: annotator/mmpkg/mmcv/ops/roi_align.py
class RoIAlignFunction (line 14) | class RoIAlignFunction(Function):
method symbolic (line 17) | def symbolic(g, input, rois, output_size, spatial_scale, sampling_ratio,
method forward (line 64) | def forward(ctx,
method backward (line 110) | def backward(ctx, grad_output):
class RoIAlign (line 133) | class RoIAlign(nn.Module):
method __init__ (line 176) | def __init__(self,
method forward (line 192) | def forward(self, input, rois):
method __repr__ (line 215) | def __repr__(self):
FILE: annotator/mmpkg/mmcv/ops/roi_align_rotated.py
class RoIAlignRotatedFunction (line 11) | class RoIAlignRotatedFunction(Function):
method symbolic (line 14) | def symbolic(g, features, rois, out_size, spatial_scale, sample_num,
method forward (line 39) | def forward(ctx,
method backward (line 82) | def backward(ctx, grad_output):
class RoIAlignRotated (line 116) | class RoIAlignRotated(nn.Module):
method __init__ (line 159) | def __init__(self,
method forward (line 173) | def forward(self, features, rois):
FILE: annotator/mmpkg/mmcv/ops/roi_pool.py
class RoIPoolFunction (line 14) | class RoIPoolFunction(Function):
method symbolic (line 17) | def symbolic(g, input, rois, output_size, spatial_scale):
method forward (line 26) | def forward(ctx, input, rois, output_size, spatial_scale=1.0):
method backward (line 52) | def backward(ctx, grad_output):
class RoIPool (line 71) | class RoIPool(nn.Module):
method __init__ (line 73) | def __init__(self, output_size, spatial_scale=1.0):
method forward (line 79) | def forward(self, input, rois):
method __repr__ (line 82) | def __repr__(self):
FILE: annotator/mmpkg/mmcv/ops/roiaware_pool3d.py
class RoIAwarePool3d (line 13) | class RoIAwarePool3d(nn.Module):
method __init__ (line 28) | def __init__(self, out_size, max_pts_per_voxel=128, mode='max'):
method forward (line 37) | def forward(self, rois, pts, pts_feature):
class RoIAwarePool3dFunction (line 54) | class RoIAwarePool3dFunction(Function):
method forward (line 57) | def forward(ctx, rois, pts, pts_feature, out_size, max_pts_per_voxel,
method backward (line 105) | def backward(ctx, grad_out):
FILE: annotator/mmpkg/mmcv/ops/roipoint_pool3d.py
class RoIPointPool3d (line 9) | class RoIPointPool3d(nn.Module):
method __init__ (line 20) | def __init__(self, num_sampled_points=512):
method forward (line 24) | def forward(self, points, point_features, boxes3d):
class RoIPointPool3dFunction (line 41) | class RoIPointPool3dFunction(Function):
method forward (line 44) | def forward(ctx, points, point_features, boxes3d, num_sampled_points=5...
method backward (line 76) | def backward(ctx, grad_out):
FILE: annotator/mmpkg/mmcv/ops/saconv.py
class SAConv2d (line 12) | class SAConv2d(ConvAWS2d):
method __init__ (line 37) | def __init__(self,
method init_weights (line 81) | def init_weights(self):
method forward (line 90) | def forward(self, x):
FILE: annotator/mmpkg/mmcv/ops/scatter_points.py
class _DynamicScatter (line 13) | class _DynamicScatter(Function):
method forward (line 16) | def forward(ctx, feats, coors, reduce_type='max'):
method backward (line 44) | def backward(ctx, grad_voxel_feats, grad_voxel_coors=None):
class DynamicScatter (line 59) | class DynamicScatter(nn.Module):
method __init__ (line 75) | def __init__(self, voxel_size, point_cloud_range, average_points: bool):
method forward_single (line 82) | def forward_single(self, points, coors):
method forward (line 98) | def forward(self, points, coors):
method __repr__ (line 129) | def __repr__(self):
FILE: annotator/mmpkg/mmcv/ops/sync_bn.py
class SyncBatchNormFunction (line 19) | class SyncBatchNormFunction(Function):
method symbolic (line 22) | def symbolic(g, input, running_mean, running_var, weight, bias, momentum,
method forward (line 38) | def forward(self, input, running_mean, running_var, weight, bias, mome...
method backward (line 129) | def backward(self, grad_output):
class SyncBatchNorm (line 159) | class SyncBatchNorm(Module):
method __init__ (line 193) | def __init__(self,
method reset_running_stats (line 230) | def reset_running_stats(self):
method reset_parameters (line 236) | def reset_parameters(self):
method forward (line 242) | def forward(self, input):
method __repr__ (line 270) | def __repr__(self):
FILE: annotator/mmpkg/mmcv/ops/three_interpolate.py
class ThreeInterpolate (line 12) | class ThreeInterpolate(Function):
method forward (line 20) | def forward(ctx, features: torch.Tensor, indices: torch.Tensor,
method backward (line 47) | def backward(
FILE: annotator/mmpkg/mmcv/ops/three_nn.py
class ThreeNN (line 11) | class ThreeNN(Function):
method forward (line 19) | def forward(ctx, target: torch.Tensor,
method backward (line 47) | def backward(ctx, a=None, b=None):
FILE: annotator/mmpkg/mmcv/ops/tin_shift.py
class TINShiftFunction (line 17) | class TINShiftFunction(Function):
method forward (line 20) | def forward(ctx, input, shift):
method backward (line 35) | def backward(ctx, grad_output):
class TINShift (line 48) | class TINShift(nn.Module):
method forward (line 58) | def forward(self, input, shift):
FILE: annotator/mmpkg/mmcv/ops/upfirdn2d.py
class UpFirDn2dBackward (line 108) | class UpFirDn2dBackward(Function):
method forward (line 111) | def forward(ctx, grad_output, kernel, grad_kernel, up, down, pad, g_pad,
method backward (line 152) | def backward(ctx, gradgrad_input):
class UpFirDn2d (line 177) | class UpFirDn2d(Function):
method forward (line 180) | def forward(ctx, input, kernel, up, down, pad):
method backward (line 225) | def backward(ctx, grad_output):
function upfirdn2d (line 243) | def upfirdn2d(input, kernel, up=1, down=1, pad=(0, 0)):
function upfirdn2d_native (line 290) | def upfirdn2d_native(input, kernel, up_x, up_y, down_x, down_y, pad_x0, ...
FILE: annotator/mmpkg/mmcv/ops/voxelize.py
class _Voxelization (line 13) | class _Voxelization(Function):
method forward (line 16) | def forward(ctx,
class Voxelization (line 71) | class Voxelization(nn.Module):
method __init__ (line 89) | def __init__(self,
method forward (line 116) | def forward(self, input):
method __repr__ (line 125) | def __repr__(self):
FILE: annotator/mmpkg/mmcv/parallel/_functions.py
function scatter (line 6) | def scatter(input, devices, streams=None):
function synchronize_stream (line 34) | def synchronize_stream(output, devices, streams):
function get_input_device (line 51) | def get_input_device(input):
class Scatter (line 64) | class Scatter:
method forward (line 67) | def forward(target_gpus, input):
FILE: annotator/mmpkg/mmcv/parallel/collate.py
function collate (line 11) | def collate(batch, samples_per_gpu=1):
FILE: annotator/mmpkg/mmcv/parallel/data_container.py
function assert_tensor_type (line 7) | def assert_tensor_type(func):
class DataContainer (line 20) | class DataContainer:
method __init__ (line 37) | def __init__(self,
method __repr__ (line 50) | def __repr__(self):
method __len__ (line 53) | def __len__(self):
method data (line 57) | def data(self):
method datatype (line 61) | def datatype(self):
method cpu_only (line 68) | def cpu_only(self):
method stack (line 72) | def stack(self):
method padding_value (line 76) | def padding_value(self):
method pad_dims (line 80) | def pad_dims(self):
method size (line 84) | def size(self, *args, **kwargs):
method dim (line 88) | def dim(self):
FILE: annotator/mmpkg/mmcv/parallel/data_parallel.py
class MMDataParallel (line 9) | class MMDataParallel(DataParallel):
method __init__ (line 26) | def __init__(self, *args, dim=0, **kwargs):
method forward (line 30) | def forward(self, *inputs, **kwargs):
method scatter (line 44) | def scatter(self, inputs, kwargs, device_ids):
method train_step (line 47) | def train_step(self, *inputs, **kwargs):
method val_step (line 69) | def val_step(self, *inputs, **kwargs):
FILE: annotator/mmpkg/mmcv/parallel/distributed.py
class MMDistributedDataParallel (line 11) | class MMDistributedDataParallel(DistributedDataParallel):
method to_kwargs (line 21) | def to_kwargs(self, inputs, kwargs, device_id):
method scatter (line 26) | def scatter(self, inputs, kwargs, device_ids):
method train_step (line 29) | def train_step(self, *inputs, **kwargs):
method val_step (line 72) | def val_step(self, *inputs, **kwargs):
FILE: annotator/mmpkg/mmcv/parallel/distributed_deprecated.py
class MMDistributedDataParallel (line 14) | class MMDistributedDataParallel(nn.Module):
method __init__ (line 16) | def __init__(self,
method _dist_broadcast_coalesced (line 29) | def _dist_broadcast_coalesced(self, tensors, buffer_size):
method _sync_params (line 37) | def _sync_params(self):
method scatter (line 52) | def scatter(self, inputs, kwargs, device_ids):
method forward (line 55) | def forward(self, *inputs, **kwargs):
method train_step (line 60) | def train_step(self, *inputs, **kwargs):
method val_step (line 66) | def val_step(self, *inputs, **kwargs):
FILE: annotator/mmpkg/mmcv/parallel/scatter_gather.py
function scatter (line 9) | def scatter(inputs, target_gpus, dim=0):
function scatter_kwargs (line 49) | def scatter_kwargs(inputs, kwargs, target_gpus, dim=0):
FILE: annotator/mmpkg/mmcv/parallel/utils.py
function is_module_wrapper (line 5) | def is_module_wrapper(module):
FILE: annotator/mmpkg/mmcv/runner/base_module.py
class BaseModule (line 14) | class BaseModule(nn.Module, metaclass=ABCMeta):
method __init__ (line 33) | def __init__(self, init_cfg=None):
method is_init (line 53) | def is_init(self):
method init_weights (line 56) | def init_weights(self):
method _dump_init_info (line 137) | def _dump_init_info(self, logger_name):
method __repr__ (line 166) | def __repr__(self):
class Sequential (line 173) | class Sequential(BaseModule, nn.Sequential):
method __init__ (line 180) | def __init__(self, *args, init_cfg=None):
class ModuleList (line 185) | class ModuleList(BaseModule, nn.ModuleList):
method __init__ (line 193) | def __init__(self, modules=None, init_cfg=None):
FILE: annotator/mmpkg/mmcv/runner/base_runner.py
class BaseRunner (line 21) | class BaseRunner(metaclass=ABCMeta):
method __init__ (line 51) | def __init__(self,
method model_name (line 139) | def model_name(self):
method rank (line 144) | def rank(self):
method world_size (line 149) | def world_size(self):
method hooks (line 155) | def hooks(self):
method epoch (line 160) | def epoch(self):
method iter (line 165) | def iter(self):
method inner_iter (line 170) | def inner_iter(self):
method max_epochs (line 175) | def max_epochs(self):
method max_iters (line 180) | def max_iters(self):
method train (line 185) | def train(self):
method val (line 189) | def val(self):
method run (line 193) | def run(self, data_loaders, workflow, **kwargs):
method save_checkpoint (line 197) | def save_checkpoint(self,
method current_lr (line 205) | def current_lr(self):
method current_momentum (line 224) | def current_momentum(self):
method register_hook (line 255) | def register_hook(self, hook, priority='NORMAL'):
method register_hook_from_cfg (line 283) | def register_hook_from_cfg(self, hook_cfg):
method call_hook (line 299) | def call_hook(self, fn_name):
method get_hook_info (line 309) | def get_hook_info(self):
method load_checkpoint (line 332) | def load_checkpoint(self,
method resume (line 345) | def resume(self,
method register_lr_hook (line 399) | def register_lr_hook(self, lr_config):
method register_momentum_hook (line 420) | def register_momentum_hook(self, momentum_config):
method register_optimizer_hook (line 441) | def register_optimizer_hook(self, optimizer_config):
method register_checkpoint_hook (line 451) | def register_checkpoint_hook(self, checkpoint_config):
method register_logger_hooks (line 461) | def register_logger_hooks(self, log_config):
method register_timer_hook (line 470) | def register_timer_hook(self, timer_config):
method register_custom_hooks (line 480) | def register_custom_hooks(self, custom_config):
method register_profiler_hook (line 493) | def register_profiler_hook(self, profiler_config):
method register_training_hooks (line 503) | def register_training_hooks(self,
FILE: annotator/mmpkg/mmcv/runner/builder.py
function build_runner_constructor (line 10) | def build_runner_constructor(cfg):
function build_runner (line 14) | def build_runner(cfg, default_args=None):
FILE: annotator/mmpkg/mmcv/runner/checkpoint.py
function _get_mmcv_home (line 30) | def _get_mmcv_home():
function load_state_dict (line 41) | def load_state_dict(module, state_dict, strict=False, logger=None):
function get_torchvision_models (line 109) | def get_torchvision_models():
function get_external_models (line 121) | def get_external_models():
function get_mmcls_models (line 135) | def get_mmcls_models():
function get_deprecated_model_names (line 142) | def get_deprecated_model_names():
function _process_mmcls_checkpoint (line 151) | def _process_mmcls_checkpoint(checkpoint):
class CheckpointLoader (line 162) | class CheckpointLoader:
method _register_scheme (line 168) | def _register_scheme(cls, prefixes, loader, force=False):
method register_scheme (line 185) | def register_scheme(cls, prefixes, loader=None, force=False):
method _get_checkpoint_loader (line 211) | def _get_checkpoint_loader(cls, path):
method load_checkpoint (line 227) | def load_checkpoint(cls, filename, map_location=None, logger=None):
function load_from_local (line 249) | def load_from_local(filename, map_location):
function load_from_http (line 267) | def load_from_http(filename, map_location=None, model_dir=None):
function load_from_pavi (line 295) | def load_from_pavi(filename, map_location=None):
function load_from_ceph (line 327) | def load_from_ceph(filename, map_location=None, backend='petrel'):
function load_from_torchvision (line 368) | def load_from_torchvision(filename, map_location=None):
function load_from_openmmlab (line 391) | def load_from_openmmlab(filename, map_location=None):
function load_from_mmcls (line 431) | def load_from_mmcls(filename, map_location=None):
function _load_checkpoint (line 450) | def _load_checkpoint(filename, map_location=None, logger=None):
function _load_checkpoint_with_prefix (line 470) | def _load_checkpoint_with_prefix(prefix, filename, map_location=None):
function load_checkpoint (line 503) | def load_checkpoint(model,
function weights_to_cpu (line 553) | def weights_to_cpu(state_dict):
function _save_to_state_dict (line 570) | def _save_to_state_dict(module, destination, prefix, keep_vars):
function get_state_dict (line 590) | def get_state_dict(module, destination=None, prefix='', keep_vars=False):
function save_checkpoint (line 634) | def save_checkpoint(model,
FILE: annotator/mmpkg/mmcv/runner/default_constructor.py
class DefaultRunnerConstructor (line 5) | class DefaultRunnerConstructor:
method __init__ (line 36) | def __init__(self, runner_cfg, default_args=None):
method __call__ (line 43) | def __call__(self):
FILE: annotator/mmpkg/mmcv/runner/dist_utils.py
function init_dist (line 14) | def init_dist(launcher, backend='nccl', **kwargs):
function _init_dist_pytorch (line 27) | def _init_dist_pytorch(backend, **kwargs):
function _init_dist_mpi (line 35) | def _init_dist_mpi(backend, **kwargs):
function _init_dist_slurm (line 43) | def _init_dist_slurm(backend, port=None):
function get_dist_info (line 78) | def get_dist_info():
function master_only (line 88) | def master_only(func):
function allreduce_params (line 99) | def allreduce_params(params, coalesce=True, bucket_size_mb=-1):
function allreduce_grads (line 121) | def allreduce_grads(params, coalesce=True, bucket_size_mb=-1):
function _allreduce_coalesced (line 145) | def _allreduce_coalesced(tensors, world_size, bucket_size_mb=-1):
FILE: annotator/mmpkg/mmcv/runner/epoch_based_runner.py
class EpochBasedRunner (line 18) | class EpochBasedRunner(BaseRunner):
method run_iter (line 24) | def run_iter(self, data_batch, train_mode, **kwargs):
method train (line 40) | def train(self, data_loader, **kwargs):
method val (line 58) | def val(self, data_loader, **kwargs):
method run (line 72) | def run(self, data_loaders, workflow, max_epochs=None, **kwargs):
method save_checkpoint (line 132) | def save_checkpoint(self,
class Runner (line 181) | class Runner(EpochBasedRunner):
method __init__ (line 184) | def __init__(self, *args, **kwargs):
FILE: annotator/mmpkg/mmcv/runner/fp16_utils.py
function cast_tensor_type (line 24) | def cast_tensor_type(inputs, src_type, dst_type):
function auto_fp16 (line 55) | def auto_fp16(apply_to=None, out_fp32=False):
function force_fp32 (line 141) | def force_fp32(apply_to=None, out_fp16=False):
function allreduce_grads (line 227) | def allreduce_grads(params, coalesce=True, bucket_size_mb=-1):
function wrap_fp16_model (line 234) | def wrap_fp16_model(model):
function patch_norm_fp32 (line 263) | def patch_norm_fp32(module):
function patch_forward_method (line 283) | def patch_forward_method(func, src_type, dst_type, convert_output=True):
class LossScaler (line 306) | class LossScaler:
method __init__ (line 335) | def __init__(self,
method has_overflow (line 349) | def has_overflow(self, params):
method _has_inf_or_nan (line 358) | def _has_inf_or_nan(x):
method update_scale (line 372) | def update_scale(self, overflow):
method state_dict (line 385) | def state_dict(self):
method load_state_dict (line 395) | def load_state_dict(self, state_dict):
method loss_scale (line 409) | def loss_scale(self):
FILE: annotator/mmpkg/mmcv/runner/hooks/checkpoint.py
class CheckpointHook (line 11) | class CheckpointHook(Hook):
method __init__ (line 51) | def __init__(self,
method before_run (line 71) | def before_run(self, runner):
method after_train_epoch (line 102) | def after_train_epoch(self, runner):
method _save_checkpoint (line 119) | def _save_checkpoint(self, runner):
method after_train_iter (line 153) | def after_train_iter(self, runner):
FILE: annotator/mmpkg/mmcv/runner/hooks/closure.py
class ClosureHook (line 6) | class ClosureHook(Hook):
method __init__ (line 8) | def __init__(self, fn_name, fn):
FILE: annotator/mmpkg/mmcv/runner/hooks/ema.py
class EMAHook (line 7) | class EMAHook(Hook):
method __init__ (line 29) | def __init__(self,
method before_run (line 41) | def before_run(self, runner):
method after_train_iter (line 60) | def after_train_iter(self, runner):
method after_train_epoch (line 73) | def after_train_epoch(self, runner):
method before_train_epoch (line 78) | def before_train_epoch(self, runner):
method _swap_ema_parameters (line 83) | def _swap_ema_parameters(self):
FILE: annotator/mmpkg/mmcv/runner/hooks/evaluation.py
class EvalHook (line 16) | class EvalHook(Hook):
method __init__ (line 85) | def __init__(self,
method _init_rule (line 153) | def _init_rule(self, rule, key_indicator):
method before_run (line 202) | def before_run(self, runner):
method before_train_iter (line 228) | def before_train_iter(self, runner):
method before_train_epoch (line 236) | def before_train_epoch(self, runner):
method after_train_iter (line 244) | def after_train_iter(self, runner):
method after_train_epoch (line 264) | def after_train_epoch(self, runner):
method _do_evaluate (line 269) | def _do_evaluate(self, runner):
method _should_evaluate (line 279) | def _should_evaluate(self, runner):
method _save_ckpt (line 314) | def _save_ckpt(self, runner, key_score):
method evaluate (line 354) | def evaluate(self, runner, results):
class DistEvalHook (line 387) | class DistEvalHook(EvalHook):
method __init__ (line 439) | def __init__(self,
method _do_evaluate (line 478) | def _do_evaluate(self, runner):
FILE: annotator/mmpkg/mmcv/runner/hooks/hook.py
class Hook (line 7) | class Hook:
method before_run (line 13) | def before_run(self, runner):
method after_run (line 16) | def after_run(self, runner):
method before_epoch (line 19) | def before_epoch(self, runner):
method after_epoch (line 22) | def after_epoch(self, runner):
method before_iter (line 25) | def before_iter(self, runner):
method after_iter (line 28) | def after_iter(self, runner):
method before_train_epoch (line 31) | def before_train_epoch(self, runner):
method before_val_epoch (line 34) | def before_val_epoch(self, runner):
method after_train_epoch (line 37) | def after_train_epoch(self, runner):
method after_val_epoch (line 40) | def after_val_epoch(self, runner):
method before_train_iter (line 43) | def before_train_iter(self, runner):
method before_val_iter (line 46) | def before_val_iter(self, runner):
method after_train_iter (line 49) | def after_train_iter(self, runner):
method after_val_iter (line 52) | def after_val_iter(self, runner):
method every_n_epochs (line 55) | def every_n_epochs(self, runner, n):
method every_n_inner_iters (line 58) | def every_n_inner_iters(self, runner, n):
method every_n_iters (line 61) | def every_n_iters(self, runner, n):
method end_of_epoch (line 64) | def end_of_epoch(self, runner):
method is_last_epoch (line 67) | def is_last_epoch(self, runner):
method is_last_iter (line 70) | def is_last_iter(self, runner):
method get_triggered_stages (line 73) | def get_triggered_stages(self):
FILE: annotator/mmpkg/mmcv/runner/hooks/iter_timer.py
class IterTimerHook (line 8) | class IterTimerHook(Hook):
method before_epoch (line 10) | def before_epoch(self, runner):
method before_iter (line 13) | def before_iter(self, runner):
method after_iter (line 16) | def after_iter(self, runner):
FILE: annotator/mmpkg/mmcv/runner/hooks/logger/base.py
class LoggerHook (line 11) | class LoggerHook(Hook):
method __init__ (line 24) | def __init__(self,
method log (line 35) | def log(self, runner):
method is_scalar (line 39) | def is_scalar(val, include_np=True, include_torch=True):
method get_mode (line 59) | def get_mode(self, runner):
method get_epoch (line 72) | def get_epoch(self, runner):
method get_iter (line 84) | def get_iter(self, runner, inner_iter=False):
method get_lr_tags (line 92) | def get_lr_tags(self, runner):
method get_momentum_tags (line 102) | def get_momentum_tags(self, runner):
method get_loggable_tags (line 112) | def get_loggable_tags(self,
method before_run (line 133) | def before_run(self, runner):
method before_epoch (line 139) | def before_epoch(self, runner):
method after_train_iter (line 142) | def after_train_iter(self, runner):
method after_train_epoch (line 156) | def after_train_epoch(self, runner):
method after_val_epoch (line 162) | def after_val_epoch(self, runner):
FILE: annotator/mmpkg/mmcv/runner/hooks/logger/dvclive.py
class DvcliveLoggerHook (line 8) | class DvcliveLoggerHook(LoggerHook):
method __init__ (line 29) | def __init__(self,
method import_dvclive (line 41) | def import_dvclive(self):
method before_run (line 50) | def before_run(self, runner):
method log (line 54) | def log(self, runner):
FILE: annotator/mmpkg/mmcv/runner/hooks/logger/mlflow.py
class MlflowLoggerHook (line 8) | class MlflowLoggerHook(LoggerHook):
method __init__ (line 10) | def __init__(self,
method import_mlflow (line 51) | def import_mlflow(self):
method before_run (line 62) | def before_run(self, runner):
method log (line 70) | def log(self, runner):
method after_run (line 76) | def after_run(self, runner):
FILE: annotator/mmpkg/mmcv/runner/hooks/logger/neptune.py
class NeptuneLoggerHook (line 8) | class NeptuneLoggerHook(LoggerHook):
method __init__ (line 38) | def __init__(self,
method import_neptune (line 52) | def import_neptune(self):
method before_run (line 62) | def before_run(self, runner):
method log (line 69) | def log(self, runner):
method after_run (line 81) | def after_run(self, runner):
FILE: annotator/mmpkg/mmcv/runner/hooks/logger/pavi.py
class PaviLoggerHook (line 17) | class PaviLoggerHook(LoggerHook):
method __init__ (line 19) | def __init__(self,
method before_run (line 36) | def before_run(self, runner):
method get_step (line 74) | def get_step(self, runner):
method log (line 82) | def log(self, runner):
method after_run (line 89) | def after_run(self, runner):
method before_epoch (line 107) | def before_epoch(self, runner):
FILE: annotator/mmpkg/mmcv/runner/hooks/logger/tensorboard.py
class TensorboardLoggerHook (line 11) | class TensorboardLoggerHook(LoggerHook):
method __init__ (line 13) | def __init__(self,
method before_run (line 24) | def before_run(self, runner):
method log (line 47) | def log(self, runner):
method after_run (line 56) | def after_run(self, runner):
FILE: annotator/mmpkg/mmcv/runner/hooks/logger/text.py
class TextLoggerHook (line 18) | class TextLoggerHook(LoggerHook):
method __init__ (line 55) | def __init__(self,
method before_run (line 89) | def before_run(self, runner):
method _get_max_memory (line 109) | def _get_max_memory(self, runner):
method _log_info (line 119) | def _log_info(self, log_dict, runner):
method _dump_log (line 185) | def _dump_log(self, log_dict, runner):
method _round_float (line 196) | def _round_float(self, items):
method log (line 204) | def log(self, runner):
method after_run (line 238) | def after_run(self, runner):
FILE: annotator/mmpkg/mmcv/runner/hooks/logger/wandb.py
class WandbLoggerHook (line 8) | class WandbLoggerHook(LoggerHook):
method __init__ (line 10) | def __init__(self,
method import_wandb (line 25) | def import_wandb(self):
method before_run (line 34) | def before_run(self, runner):
method log (line 44) | def log(self, runner):
method after_run (line 55) | def after_run(self, runner):
FILE: annotator/mmpkg/mmcv/runner/hooks/lr_updater.py
class LrUpdaterHook (line 9) | class LrUpdaterHook(Hook):
method __init__ (line 25) | def __init__(self,
method _set_lr (line 58) | def _set_lr(self, runner, lr_groups):
method get_lr (line 68) | def get_lr(self, runner, base_lr):
method get_regular_lr (line 71) | def get_regular_lr(self, runner):
method get_warmup_lr (line 85) | def get_warmup_lr(self, cur_iters):
method before_run (line 107) | def before_run(self, runner):
method before_train_epoch (line 126) | def before_train_epoch(self, runner):
method before_train_iter (line 137) | def before_train_iter(self, runner):
class FixedLrUpdaterHook (line 157) | class FixedLrUpdaterHook(LrUpdaterHook):
method __init__ (line 159) | def __init__(self, **kwargs):
method get_lr (line 162) | def get_lr(self, runner, base_lr):
class StepLrUpdaterHook (line 167) | class StepLrUpdaterHook(LrUpdaterHook):
method __init__ (line 180) | def __init__(self, step, gamma=0.1, min_lr=None, **kwargs):
method get_lr (line 193) | def get_lr(self, runner, base_lr):
class ExpLrUpdaterHook (line 214) | class ExpLrUpdaterHook(LrUpdaterHook):
method __init__ (line 216) | def __init__(self, gamma, **kwargs):
method get_lr (line 220) | def get_lr(self, runner, base_lr):
class PolyLrUpdaterHook (line 226) | class PolyLrUpdaterHook(LrUpdaterHook):
method __init__ (line 228) | def __init__(self, power=1., min_lr=0., **kwargs):
method get_lr (line 233) | def get_lr(self, runner, base_lr):
class InvLrUpdaterHook (line 245) | class InvLrUpdaterHook(LrUpdaterHook):
method __init__ (line 247) | def __init__(self, gamma, power=1., **kwargs):
method get_lr (line 252) | def get_lr(self, runner, base_lr):
class CosineAnnealingLrUpdaterHook (line 258) | class CosineAnnealingLrUpdaterHook(LrUpdaterHook):
method __init__ (line 260) | def __init__(self, min_lr=None, min_lr_ratio=None, **kwargs):
method get_lr (line 266) | def get_lr(self, runner, base_lr):
class FlatCosineAnnealingLrUpdaterHook (line 282) | class FlatCosineAnnealingLrUpdaterHook(LrUpdaterHook):
method __init__ (line 298) | def __init__(self,
method get_lr (line 314) | def get_lr(self, runner, base_lr):
class CosineRestartLrUpdaterHook (line 336) | class CosineRestartLrUpdaterHook(LrUpdaterHook):
method __init__ (line 349) | def __init__(self,
method get_lr (line 368) | def get_lr(self, runner, base_lr):
function get_position_from_periods (line 388) | def get_position_from_periods(iteration, cumulative_periods):
class CyclicLrUpdaterHook (line 412) | class CyclicLrUpdaterHook(LrUpdaterHook):
method __init__ (line 434) | def __init__(self,
method before_run (line 472) | def before_run(self, runner):
method get_lr (line 485) | def get_lr(self, runner, base_lr):
class OneCycleLrUpdaterHook (line 498) | class OneCycleLrUpdaterHook(LrUpdaterHook):
method __init__ (line 532) | def __init__(self,
method before_run (line 575) | def before_run(self, runner):
method get_lr (line 614) | def get_lr(self, runner, base_lr):
function annealing_cos (line 627) | def annealing_cos(start, end, factor, weight=1):
function annealing_linear (line 645) | def annealing_linear(start, end, factor):
function format_param (line 659) | def format_param(name, optim, param):
FILE: annotator/mmpkg/mmcv/runner/hooks/memory.py
class EmptyCacheHook (line 8) | class EmptyCacheHook(Hook):
method __init__ (line 10) | def __init__(self, before_epoch=False, after_epoch=True, after_iter=Fa...
method after_iter (line 15) | def after_iter(self, runner):
method before_epoch (line 19) | def before_epoch(self, runner):
method after_epoch (line 23) | def after_epoch(self, runner):
FILE: annotator/mmpkg/mmcv/runner/hooks/momentum_updater.py
class MomentumUpdaterHook (line 7) | class MomentumUpdaterHook(Hook):
method __init__ (line 9) | def __init__(self,
method _set_momentum (line 35) | def _set_momentum(self, runner, momentum_groups):
method get_momentum (line 52) | def get_momentum(self, runner, base_momentum):
method get_regular_momentum (line 55) | def get_regular_momentum(self, runner):
method get_warmup_momentum (line 71) | def get_warmup_momentum(self, cur_iters):
method before_run (line 101) | def before_run(self, runner):
method before_train_epoch (line 128) | def before_train_epoch(self, runner):
method before_train_iter (line 134) | def before_train_iter(self, runner):
class StepMomentumUpdaterHook (line 154) | class StepMomentumUpdaterHook(MomentumUpdaterHook):
method __init__ (line 168) | def __init__(self, step, gamma=0.5, min_momentum=None, **kwargs):
method get_momentum (line 181) | def get_momentum(self, runner, base_momentum):
class CosineAnnealingMomentumUpdaterHook (line 202) | class CosineAnnealingMomentumUpdaterHook(MomentumUpdaterHook):
method __init__ (line 204) | def __init__(self, min_momentum=None, min_momentum_ratio=None, **kwargs):
method get_momentum (line 210) | def get_momentum(self, runner, base_momentum):
class CyclicMomentumUpdaterHook (line 226) | class CyclicMomentumUpdaterHook(MomentumUpdaterHook):
method __init__ (line 244) | def __init__(self,
method before_run (line 273) | def before_run(self, runner):
method get_momentum (line 286) | def get_momentum(self, runner, base_momentum):
class OneCycleMomentumUpdaterHook (line 299) | class OneCycleMomentumUpdaterHook(MomentumUpdaterHook):
method __init__ (line 333) | def __init__(self,
method before_run (line 371) | def before_run(self, runner):
method _set_momentum (line 448) | def _set_momentum(self, runner, momentum_groups):
method get_momentum (line 465) | def get_momentum(self, runner, param_group):
method get_regular_momentum (line 479) | def get_regular_momentum(self, runner):
FILE: annotator/mmpkg/mmcv/runner/hooks/optimizer.py
class OptimizerHook (line 22) | class OptimizerHook(Hook):
method __init__ (line 24) | def __init__(self, grad_clip=None):
method clip_grads (line 27) | def clip_grads(self, params):
method after_train_iter (line 33) | def after_train_iter(self, runner):
class GradientCumulativeOptimizerHook (line 46) | class GradientCumulativeOptimizerHook(OptimizerHook):
method __init__ (line 64) | def __init__(self, cumulative_iters=1, **kwargs):
method has_batch_norm (line 76) | def has_batch_norm(self, module):
method _init (line 84) | def _init(self, runner):
method after_train_iter (line 105) | def after_train_iter(self, runner):
class Fp16OptimizerHook (line 134) | class Fp16OptimizerHook(OptimizerHook):
method __init__ (line 162) | def __init__(self,
method before_run (line 184) | def before_run(self, runner):
method copy_grads_to_fp32 (line 193) | def copy_grads_to_fp32(self, fp16_net, fp32_weights):
method copy_params_to_fp16 (line 203) | def copy_params_to_fp16(self, fp16_net, fp32_weights):
method after_train_iter (line 209) | def after_train_iter(self, runner):
method __init__ (line 318) | def __init__(self,
method before_run (line 339) | def before_run(self, runner):
method copy_grads_to_fp32 (line 367) | def copy_grads_to_fp32(self, fp16_net, fp32_weights):
method copy_params_to_fp16 (line 377) | def copy_params_to_fp16(self, fp16_net, fp32_weights):
method after_train_iter (line 383) | def after_train_iter(self, runner):
class GradientCumulativeFp16OptimizerHook (line 242) | class GradientCumulativeFp16OptimizerHook(GradientCumulativeOptimizerHook,
method __init__ (line 251) | def __init__(self, *args, **kwargs):
method after_train_iter (line 255) | def after_train_iter(self, runner):
method __init__ (line 444) | def __init__(self, *args, **kwargs):
method after_train_iter (line 448) | def after_train_iter(self, runner):
class Fp16OptimizerHook (line 297) | class Fp16OptimizerHook(OptimizerHook):
method __init__ (line 162) | def __init__(self,
method before_run (line 184) | def before_run(self, runner):
method copy_grads_to_fp32 (line 193) | def copy_grads_to_fp32(self, fp16_net, fp32_weights):
method copy_params_to_fp16 (line 203) | def copy_params_to_fp16(self, fp16_net, fp32_weights):
method after_train_iter (line 209) | def after_train_iter(self, runner):
method __init__ (line 318) | def __init__(self,
method before_run (line 339) | def before_run(self, runner):
method copy_grads_to_fp32 (line 367) | def copy_grads_to_fp32(self, fp16_net, fp32_weights):
method copy_params_to_fp16 (line 377) | def copy_params_to_fp16(self, fp16_net, fp32_weights):
method after_train_iter (line 383) | def after_train_iter(self, runner):
class GradientCumulativeFp16OptimizerHook (line 439) | class GradientCumulativeFp16OptimizerHook(GradientCumulativeOptimizerHook,
method __init__ (line 251) | def __init__(self, *args, **kwargs):
method after_train_iter (line 255) | def after_train_iter(self, runner):
method __init__ (line 444) | def __init__(self, *args, **kwargs):
method after_train_iter (line 448) | def after_train_iter(self, runner):
FILE: annotator/mmpkg/mmcv/runner/hooks/profiler.py
class ProfilerHook (line 12) | class ProfilerHook(Hook):
method __init__ (line 55) | def __init__(self,
method before_run (line 107) | def before_run(self, runner):
method after_train_epoch (line 166) | def after_train_epoch(self, runner):
method after_train_iter (line 174) | def after_train_iter(self, runner):
FILE: annotator/mmpkg/mmcv/runner/hooks/sampler_seed.py
class DistSamplerSeedHook (line 6) | class DistSamplerSeedHook(Hook):
method before_epoch (line 14) | def before_epoch(self, runner):
FILE: annotator/mmpkg/mmcv/runner/hooks/sync_buffer.py
class SyncBuffersHook (line 7) | class SyncBuffersHook(Hook):
method __init__ (line 16) | def __init__(self, distributed=True):
method after_epoch (line 19) | def after_epoch(self, runner):
FILE: annotator/mmpkg/mmcv/runner/iter_based_runner.py
class IterLoader (line 19) | class IterLoader:
method __init__ (line 21) | def __init__(self, dataloader):
method epoch (line 27) | def epoch(self):
method __next__ (line 30) | def __next__(self):
method __len__ (line 43) | def __len__(self):
class IterBasedRunner (line 48) | class IterBasedRunner(BaseRunner):
method train (line 54) | def train(self, data_loader, **kwargs):
method val (line 72) | def val(self, data_loader, **kwargs):
method run (line 87) | def run(self, data_loaders, workflow, max_iters=None, **kwargs):
method resume (line 140) | def resume(self,
method save_checkpoint (line 179) | def save_checkpoint(self,
method register_training_hooks (line 224) | def register_training_hooks(self,
FILE: annotator/mmpkg/mmcv/runner/log_buffer.py
class LogBuffer (line 7) | class LogBuffer:
method __init__ (line 9) | def __init__(self):
method clear (line 15) | def clear(self):
method clear_output (line 20) | def clear_output(self):
method update (line 24) | def update(self, vars, count=1):
method average (line 33) | def average(self, n=0):
FILE: annotator/mmpkg/mmcv/runner/optimizer/builder.py
function register_torch_optimizers (line 13) | def register_torch_optimizers():
function build_optimizer_constructor (line 29) | def build_optimizer_constructor(cfg):
function build_optimizer (line 33) | def build_optimizer(model, cfg):
FILE: annotator/mmpkg/mmcv/runner/optimizer/default_constructor.py
class DefaultOptimizerConstructor (line 13) | class DefaultOptimizerConstructor:
method __init__ (line 95) | def __init__(self, optimizer_cfg, paramwise_cfg=None):
method _validate_cfg (line 105) | def _validate_cfg(self):
method _is_in (line 128) | def _is_in(self, param_group, param_group_list):
method add_params (line 137) | def add_params(self, params, module, prefix='', is_dcn_module=None):
method __call__ (line 234) | def __call__(self, model):
FILE: annotator/mmpkg/mmcv/runner/priority.py
class Priority (line 5) | class Priority(Enum):
function get_priority (line 42) | def get_priority(priority):
FILE: annotator/mmpkg/mmcv/runner/utils.py
function get_host_info (line 16) | def get_host_info():
function get_time_str (line 31) | def get_time_str():
function obj_from_dict (line 35) | def obj_from_dict(info, parent=None, default_args=None):
function set_random_seed (line 70) | def set_random_seed(seed, deterministic=False, use_rank_shift=False):
FILE: annotator/mmpkg/mmcv/utils/config.py
class ConfigDict (line 33) | class ConfigDict(Dict):
method __missing__ (line 35) | def __missing__(self, name):
method __getattr__ (line 38) | def __getattr__(self, name):
function add_args (line 51) | def add_args(parser, cfg, prefix=''):
class Config (line 70) | class Config:
method _validate_py_syntax (line 96) | def _validate_py_syntax(filename):
method _substitute_predefined_vars (line 107) | def _substitute_predefined_vars(filename, temp_config_name):
method _pre_substitute_base_vars (line 128) | def _pre_substitute_base_vars(filename, temp_config_name):
method _substitute_base_vars (line 147) | def _substitute_base_vars(cfg, base_var_dict, base_cfg):
method _file2dict (line 179) | def _file2dict(filename, use_predefined_variables=True):
method _merge_a_into_b (line 274) | def _merge_a_into_b(a, b, allow_list_keys=False):
method fromfile (line 328) | def fromfile(filename,
method fromstring (line 338) | def fromstring(cfg_str, file_format):
method auto_argparser (line 366) | def auto_argparser(description=None):
method __init__ (line 377) | def __init__(self, cfg_dict=None, cfg_text=None, filename=None):
method filename (line 399) | def filename(self):
method text (line 403) | def text(self):
method pretty_text (line 407) | def pretty_text(self):
method __repr__ (line 500) | def __repr__(self):
method __len__ (line 503) | def __len__(self):
method __getattr__ (line 506) | def __getattr__(self, name):
method __getitem__ (line 509) | def __getitem__(self, name):
method __setattr__ (line 512) | def __setattr__(self, name, value):
method __setitem__ (line 517) | def __setitem__(self, name, value):
method __iter__ (line 522) | def __iter__(self):
method __getstate__ (line 525) | def __getstate__(self):
method __setstate__ (line 528) | def __setstate__(self, state):
method dump (line 534) | def dump(self, file=None):
method merge_from_dict (line 550) | def merge_from_dict(self, options, allow_list_keys=True):
class DictAction (line 597) | class DictAction(Action):
method _parse_int_float_bool (line 607) | def _parse_int_float_bool(val):
method _parse_iterable (line 621) | def _parse_iterable(val):
method __call__ (line 683) | def __call__(self, parser, namespace, values, option_string=None):
FILE: annotator/mmpkg/mmcv/utils/env.py
function collect_env (line 16) | def collect_env():
FILE: annotator/mmpkg/mmcv/utils/ext_loader.py
function load_ext (line 12) | def load_ext(name, funcs):
function get_fake_func (line 41) | def get_fake_func(name, e):
function load_ext (line 49) | def load_ext(name, funcs):
function check_ops_exist (line 69) | def check_ops_exist():
FILE: annotator/mmpkg/mmcv/utils/logging.py
function get_logger (line 9) | def get_logger(name, log_file=None, log_level=logging.INFO, file_mode='w'):
function print_log (line 85) | def print_log(msg, logger=None, level=logging.INFO):
FILE: annotator/mmpkg/mmcv/utils/misc.py
function _ntuple (line 14) | def _ntuple(n):
function is_str (line 31) | def is_str(x):
function import_modules_from_strings (line 39) | def import_modules_from_strings(imports, allow_failed_imports=False):
function iter_cast (line 87) | def iter_cast(inputs, dst_type, return_type=None):
function list_cast (line 112) | def list_cast(inputs, dst_type):
function tuple_cast (line 120) | def tuple_cast(inputs, dst_type):
function is_seq_of (line 128) | def is_seq_of(seq, expected_type, seq_type=None):
function is_list_of (line 152) | def is_list_of(seq, expected_type):
function is_tuple_of (line 160) | def is_tuple_of(seq, expected_type):
function slice_list (line 168) | def slice_list(in_list, lens):
function concat_list (line 194) | def concat_list(in_list):
function check_prerequisites (line 206) | def check_prerequisites(
function _check_py_package (line 244) | def _check_py_package(package):
function _check_executable (line 253) | def _check_executable(cmd):
function requires_package (line 260) | def requires_package(prerequisites):
function requires_executable (line 276) | def requires_executable(prerequisites):
function deprecated_api_warning (line 288) | def deprecated_api_warning(name_dict, cls_name=None):
function is_method_overridden (line 348) | def is_method_overridden(method, base_class, derived_class):
function has_method (line 367) | def has_method(obj: object, method: str) -> bool:
FILE: annotator/mmpkg/mmcv/utils/parrots_jit.py
function jit (line 12) | def jit(func=None,
function skip_no_elena (line 36) | def skip_no_elena(func):
FILE: annotator/mmpkg/mmcv/utils/parrots_wrapper.py
function is_rocm_pytorch (line 9) | def is_rocm_pytorch() -> bool:
function _get_cuda_home (line 21) | def _get_cuda_home():
function get_build_config (line 33) | def get_build_config():
function _get_conv (line 41) | def _get_conv():
function _get_dataloader (line 49) | def _get_dataloader():
function _get_extension (line 58) | def _get_extension():
function _get_pool (line 69) | def _get_pool():
function _get_norm (line 81) | def _get_norm():
class SyncBatchNorm (line 99) | class SyncBatchNorm(SyncBatchNorm_):
method _check_input_dim (line 101) | def _check_input_dim(self, input):
FILE: annotator/mmpkg/mmcv/utils/path.py
function is_filepath (line 9) | def is_filepath(x):
function fopen (line 13) | def fopen(filepath, *args, **kwargs):
function check_file_exist (line 21) | def check_file_exist(filename, msg_tmpl='file "{}" does not exist'):
function mkdir_or_exist (line 26) | def mkdir_or_exist(dir_name, mode=0o777):
function symlink (line 33) | def symlink(src, dst, overwrite=True, **kwargs):
function scandir (line 39) | def scandir(dir_path, suffix=None, recursive=False, case_sensitive=True):
function find_vcs_root (line 83) | def find_vcs_root(path, markers=('.git', )):
FILE: annotator/mmpkg/mmcv/utils/progressbar.py
class ProgressBar (line 10) | class ProgressBar:
method __init__ (line 13) | def __init__(self, task_num=0, bar_width=50, start=True, file=sys.stdo...
method terminal_width (line 22) | def terminal_width(self):
method start (line 26) | def start(self):
method update (line 35) | def update(self, num_tasks=1):
function track_progress (line 64) | def track_progress(func, tasks, bar_width=50, file=sys.stdout, **kwargs):
function init_pool (line 98) | def init_pool(process_num, initializer=None, initargs=None):
function track_parallel_progress (line 109) | def track_parallel_progress(func,
function track_iter_progress (line 179) | def track_iter_progress(tasks, bar_width=50, file=sys.stdout):
FILE: annotator/mmpkg/mmcv/utils/registry.py
function build_from_cfg (line 9) | def build_from_cfg(cfg, registry, default_args=None):
class Registry (line 58) | class Registry:
method __init__ (line 88) | def __init__(self, name, build_func=None, parent=None, scope=None):
method __len__ (line 112) | def __len__(self):
method __contains__ (line 115) | def __contains__(self, key):
method __repr__ (line 118) | def __repr__(self):
method infer_scope (line 125) | def infer_scope():
method split_scope_key (line 149) | def split_scope_key(key):
method name (line 171) | def name(self):
method scope (line 175) | def scope(self):
method module_dict (line 179) | def module_dict(self):
method children (line 183) | def children(self):
method get (line 186) | def get(self, key):
method build (line 211) | def build(self, *args, **kwargs):
method _add_children (line 214) | def _add_children(self, registry):
method _register_module (line 235) | def _register_module(self, module_class, module_name=None, force=False):
method deprecated_register_module (line 250) | def deprecated_register_module(self, cls=None, force=False):
method register_module (line 260) | def register_module(self, name=None, force=False, module=None):
FILE: annotator/mmpkg/mmcv/utils/testing.py
function check_python_script (line 10) | def check_python_script(cmd):
function _any (line 25) | def _any(judge_result):
function assert_dict_contains_subset (line 42) | def assert_dict_contains_subset(dict_obj: Dict[Any, Any],
function assert_attrs_equal (line 61) | def assert_attrs_equal(obj: Any, expected_attrs: Dict[str, Any]) -> bool:
function assert_dict_has_keys (line 77) | def assert_dict_has_keys(obj: Dict[str, Any],
function assert_keys_equal (line 92) | def assert_keys_equal(result_keys: List[str], target_keys: List[str]) ->...
function assert_is_norm_layer (line 105) | def assert_is_norm_layer(module) -> bool:
function assert_params_all_zeros (line 120) | def assert_params_all_zeros(module) -> bool:
FILE: annotator/mmpkg/mmcv/utils/timer.py
class TimerError (line 5) | class TimerError(Exception):
method __init__ (line 7) | def __init__(self, message):
class Timer (line 12) | class Timer:
method __init__ (line 38) | def __init__(self, start=True, print_tmpl=None):
method is_running (line 45) | def is_running(self):
method __enter__ (line 49) | def __enter__(self):
method __exit__ (line 53) | def __exit__(self, type, value, traceback):
method start (line 57) | def start(self):
method since_start (line 64) | def since_start(self):
method since_last_check (line 74) | def since_last_check(self):
function check_time (line 92) | def check_time(timer_id):
FILE: annotator/mmpkg/mmcv/utils/trace.py
function is_jit_tracing (line 8) | def is_jit_tracing() -> bool:
FILE: annotator/mmpkg/mmcv/utils/version_utils.py
function digit_version (line 9) | def digit_version(version_str: str, length: int = 4):
function _minimal_ext_cmd (line 50) | def _minimal_ext_cmd(cmd):
function get_git_hash (line 66) | def get_git_hash(fallback='unknown', digits=None):
FILE: annotator/mmpkg/mmcv/version.py
function parse_version_info (line 5) | def parse_version_info(version_str: str, length: int = 4) -> tuple:
FILE: annotator/mmpkg/mmcv/video/io.py
class Cache (line 14) | class Cache:
method __init__ (line 16) | def __init__(self, capacity):
method capacity (line 23) | def capacity(self):
method size (line 27) | def size(self):
method put (line 30) | def put(self, key, val):
method get (line 37) | def get(self, key, default=None):
class VideoReader (line 42) | class VideoReader:
method __init__ (line 64) | def __init__(self, filename, cache_capacity=10):
method vcap (line 80) | def vcap(self):
method opened (line 85) | def opened(self):
method width (line 90) | def width(self):
method height (line 95) | def height(self):
method resolution (line 100) | def resolution(self):
method fps (line 105) | def fps(self):
method frame_cnt (line 110) | def frame_cnt(self):
method fourcc (line 115) | def fourcc(self):
method position (line 120) | def position(self):
method _get_real_position (line 124) | def _get_real_position(self):
method _set_real_position (line 127) | def _set_real_position(self, frame_id):
method read (line 134) | def read(self):
method get_frame (line 160) | def get_frame(self, frame_id):
method current_frame (line 187) | def current_frame(self):
method cvt2frames (line 198) | def cvt2frames(self,
method __len__ (line 240) | def __len__(self):
method __getitem__ (line 243) | def __getitem__(self, index):
method __iter__ (line 256) | def __iter__(self):
method __next__ (line 260) | def __next__(self):
method __enter__ (line 269) | def __enter__(self):
method __exit__ (line 272) | def __exit__(self, exc_type, exc_value, traceback):
function frames2video (line 276) | def frames2video(frame_dir,
FILE: annotator/mmpkg/mmcv/video/optflow.py
function flowread (line 12) | def flowread(flow_or_path, quantize=False, concat_axis=0, *args, **kwargs):
function flowwrite (line 61) | def flowwrite(flow, filename, quantize=False, concat_axis=0, *args, **kw...
function quantize_flow (line 91) | def quantize_flow(flow, max_val=0.02, norm=True):
function dequantize_flow (line 119) | def dequantize_flow(dx, dy, max_val=0.02, denorm=True):
function flow_warp (line 143) | def flow_warp(img, flow, filling_value=0, interpolate_mode='nearest'):
function flow_from_bytes (line 204) | def flow_from_bytes(content):
function sparse_flow_from_bytes (line 234) | def sparse_flow_from_bytes(content):
FILE: annotator/mmpkg/mmcv/video/processing.py
function convert_video (line 11) | def convert_video(in_file,
function resize_video (line 55) | def resize_video(in_file,
function cut_video (line 93) | def cut_video(in_file,
function concat_video (line 128) | def concat_video(video_list,
FILE: annotator/mmpkg/mmcv/visualization/color.py
class Color (line 9) | class Color(Enum):
function color_val (line 24) | def color_val(color):
FILE: annotator/mmpkg/mmcv/visualization/image.py
function imshow (line 9) | def imshow(img, win_name='', wait_time=0):
function imshow_bboxes (line 30) | def imshow_bboxes(img,
function imshow_det_bboxes (line 84) | def imshow_det_bboxes(img,
FILE: annotator/mmpkg/mmcv/visualization/optflow.py
function flowshow (line 11) | def flowshow(flow, win_name='', wait_time=0):
function flow2rgb (line 24) | def flow2rgb(flow, color_wheel=None, unknown_thr=1e6):
function make_color_wheel (line 76) | def make_color_wheel(bins=None):
FILE: annotator/mmpkg/mmseg/apis/inference.py
function init_segmentor (line 12) | def init_segmentor(config, checkpoint=None, device=devices.get_device_fo...
class LoadImage (line 43) | class LoadImage:
method __call__ (line 46) | def __call__(self, results):
function inference_segmentor (line 70) | def inference_segmentor(model, img):
function show_result_pyplot (line 103) | def show_result_pyplot(model,
FILE: annotator/mmpkg/mmseg/apis/test.py
function np2tmp (line 14) | def np2tmp(array, temp_file_name=None):
function single_gpu_test (line 34) | def single_gpu_test(model,
function multi_gpu_test (line 106) | def multi_gpu_test(model,
function collect_results_cpu (line 164) | def collect_results_cpu(result_part, size, tmpdir=None):
function collect_results_gpu (line 207) | def collect_results_gpu(result_part, size):
FILE: annotator/mmpkg/mmseg/apis/train.py
function set_random_seed (line 14) | def set_random_seed(seed, deterministic=False):
function train_segmentor (line 33) | def train_segmentor(model,
FILE: annotator/mmpkg/mmseg/core/evaluation/class_names.py
function cityscapes_classes (line 4) | def cityscapes_classes():
function ade_classes (line 14) | def ade_classes():
function voc_classes (line 44) | def voc_classes():
function cityscapes_palette (line 54) | def cityscapes_palette():
function ade_palette (line 63) | def ade_palette():
function voc_palette (line 105) | def voc_palette():
function get_classes (line 121) | def get_classes(dataset):
function get_palette (line 138) | def get_palette(dataset):
FILE: annotator/mmpkg/mmseg/core/evaluation/eval_hooks.py
class EvalHook (line 7) | class EvalHook(_EvalHook):
method __init__ (line 22) | def __init__(self, *args, by_epoch=False, efficient_test=False, **kwar...
method after_train_iter (line 26) | def after_train_iter(self, runner):
method after_train_epoch (line 42) | def after_train_epoch(self, runner):
class DistEvalHook (line 55) | class DistEvalHook(_DistEvalHook):
method __init__ (line 70) | def __init__(self, *args, by_epoch=False, efficient_test=False, **kwar...
method after_train_iter (line 74) | def after_train_iter(self, runner):
method after_train_epoch (line 93) | def after_train_epoch(self, runner):
FILE: annotator/mmpkg/mmseg/core/evaluation/metrics.py
function f_score (line 8) | def f_score(precision, recall, beta=1):
function intersect_and_union (line 25) | def intersect_and_union(pred_label,
function total_intersect_and_union (line 88) | def total_intersect_and_union(results,
function mean_iou (line 133) | def mean_iou(results,
function mean_dice (line 172) | def mean_dice(results,
function mean_fscore (line 212) | def mean_fscore(results,
function eval_metrics (line 257) | def eval_metrics(results,
FILE: annotator/mmpkg/mmseg/core/seg/builder.py
function build_pixel_sampler (line 6) | def build_pixel_sampler(cfg, **default_args):
FILE: annotator/mmpkg/mmseg/core/seg/sampler/base_pixel_sampler.py
class BasePixelSampler (line 4) | class BasePixelSampler(metaclass=ABCMeta):
method __init__ (line 7) | def __init__(self, **kwargs):
method sample (line 11) | def sample(self, seg_logit, seg_label):
FILE: annotator/mmpkg/mmseg/core/seg/sampler/ohem_pixel_sampler.py
class OHEMPixelSampler (line 9) | class OHEMPixelSampler(BasePixelSampler):
method __init__ (line 23) | def __init__(self, context, thresh=None, min_kept=100000):
method sample (line 30) | def sample(self, seg_logit, seg_label):
FILE: annotator/mmpkg/mmseg/core/utils/misc.py
function add_prefix (line 1) | def add_prefix(inputs, prefix):
FILE: annotator/mmpkg/mmseg/datasets/ade.py
class ADE20KDataset (line 6) | class ADE20KDataset(CustomDataset):
method __init__ (line 79) | def __init__(self, **kwargs):
FILE: annotator/mmpkg/mmseg/datasets/builder.py
function _concat_dataset (line 25) | def _concat_dataset(cfg, default_args=None):
function build_dataset (line 61) | def build_dataset(cfg, default_args=None):
function build_dataloader (line 78) | def build_dataloader(dataset,
function worker_init_fn (line 155) | def worker_init_fn(worker_id, num_workers, rank, seed):
FILE: annotator/mmpkg/mmseg/datasets/chase_db1.py
class ChaseDB1Dataset (line 8) | class ChaseDB1Dataset(CustomDataset):
method __init__ (line 21) | def __init__(self, **kwargs):
FILE: annotator/mmpkg/mmseg/datasets/cityscapes.py
class CityscapesDataset (line 14) | class CityscapesDataset(CustomDataset):
method __init__ (line 32) | def __init__(self, **kwargs):
method _convert_to_label_id (line 39) | def _convert_to_label_id(result):
method results2img (line 50) | def results2img(self, results, imgfile_prefix, to_label_id):
method format_results (line 91) | def format_results(self, results, imgfile_prefix=None, to_label_id=True):
method evaluate (line 124) | def evaluate(self,
method _evaluate_cityscapes (line 164) | def _evaluate_cityscapes(self, results, logger, imgfile_prefix):
FILE: annotator/mmpkg/mmseg/datasets/custom.py
class CustomDataset (line 18) | class CustomDataset(Dataset):
method __init__ (line 74) | def __init__(self,
method __len__ (line 115) | def __len__(self):
method load_annotations (line 119) | def load_annotations(self, img_dir, img_suffix, ann_dir, seg_map_suffix,
method get_ann_info (line 157) | def get_ann_info(self, idx):
method pre_pipeline (line 169) | def pre_pipeline(self, results):
method __getitem__ (line 177) | def __getitem__(self, idx):
method prepare_train_img (line 193) | def prepare_train_img(self, idx):
method prepare_test_img (line 210) | def prepare_test_img(self, idx):
method format_results (line 226) | def format_results(self, results, **kwargs):
method get_gt_seg_maps (line 229) | def get_gt_seg_maps(self, efficient_test=False):
method get_classes_and_palette (line 242) | def get_classes_and_palette(self, classes=None, palette=None):
method get_palette_for_custom_classes (line 286) | def get_palette_for_custom_classes(self, class_names, palette=None):
method evaluate (line 305) | def evaluate(self,
FILE: annotator/mmpkg/mmseg/datasets/dataset_wrappers.py
class ConcatDataset (line 7) | class ConcatDataset(_ConcatDataset):
method __init__ (line 17) | def __init__(self, datasets):
class RepeatDataset (line 24) | class RepeatDataset(object):
method __init__ (line 37) | def __init__(self, dataset, times):
method __getitem__ (line 44) | def __getitem__(self, idx):
method __len__ (line 48) | def __len__(self):
FILE: annotator/mmpkg/mmseg/datasets/drive.py
class DRIVEDataset (line 8) | class DRIVEDataset(CustomDataset):
method __init__ (line 21) | def __init__(self, **kwargs):
FILE: annotator/mmpkg/mmseg/datasets/hrf.py
class HRFDataset (line 8) | class HRFDataset(CustomDataset):
method __init__ (line 21) | def __init__(self, **kwargs):
FILE: annotator/mmpkg/mmseg/datasets/pascal_context.py
class PascalContextDataset (line 8) | class PascalContextDataset(CustomDataset):
method __init__ (line 47) | def __init__(self, split, **kwargs):
class PascalContextDataset59 (line 58) | class PascalContextDataset59(CustomDataset):
method __init__ (line 96) | def __init__(self, split, **kwargs):
FILE: annotator/mmpkg/mmseg/datasets/pipelines/compose.py
class Compose (line 9) | class Compose(object):
method __init__ (line 17) | def __init__(self, transforms):
method __call__ (line 29) | def __call__(self, data):
method __repr__ (line 45) | def __repr__(self):
FILE: annotator/mmpkg/mmseg/datasets/pipelines/formating.py
function to_tensor (line 11) | def to_tensor(data):
class ToTensor (line 37) | class ToTensor(object):
method __init__ (line 44) | def __init__(self, keys):
method __call__ (line 47) | def __call__(self, results):
method __repr__ (line 62) | def __repr__(self):
class ImageToTensor (line 67) | class ImageToTensor(object):
method __init__ (line 78) | def __init__(self, keys):
method __call__ (line 81) | def __call__(self, results):
method __repr__ (line 100) | def __repr__(self):
class Transpose (line 105) | class Transpose(object):
method __init__ (line 113) | def __init__(self, keys, order):
method __call__ (line 117) | def __call__(self, results):
method __repr__ (line 133) | def __repr__(self):
class ToDataContainer (line 139) | class ToDataContainer(object):
method __init__ (line 150) | def __init__(self,
method __call__ (line 155) | def __call__(self, results):
method __repr__ (line 173) | def __repr__(self):
class DefaultFormatBundle (line 178) | class DefaultFormatBundle(object):
method __call__ (line 189) | def __call__(self, results):
method __repr__ (line 214) | def __repr__(self):
class Collect (line 219) | class Collect(object):
method __init__ (line 256) | def __init__(self,
method __call__ (line 264) | def __call__(self, results):
method __repr__ (line 286) | def __repr__(self):
FILE: annotator/mmpkg/mmseg/datasets/pipelines/loading.py
class LoadImageFromFile (line 10) | class LoadImageFromFile(object):
method __init__ (line 31) | def __init__(self,
method __call__ (line 42) | def __call__(self, results):
method __repr__ (line 81) | def __repr__(self):
class LoadAnnotations (line 90) | class LoadAnnotations(object):
method __init__ (line 104) | def __init__(self,
method __call__ (line 113) | def __call__(self, results):
method __repr__ (line 149) | def __repr__(self):
FILE: annotator/mmpkg/mmseg/datasets/pipelines/test_time_aug.py
class MultiScaleFlipAug (line 10) | class MultiScaleFlipAug(object):
method __init__ (line 53) | def __init__(self,
method __call__ (line 93) | def __call__(self, results):
method __repr__ (line 128) | def __repr__(self):
FILE: annotator/mmpkg/mmseg/datasets/pipelines/transforms.py
class Resize (line 10) | class Resize(object):
method __init__ (line 41) | def __init__(self,
method random_select (line 68) | def random_select(img_scales):
method random_sample (line 86) | def random_sample(img_scales):
method random_sample_ratio (line 113) | def random_sample_ratio(img_scale, ratio_range):
method _random_scale (line 139) | def _random_scale(self, results):
method _resize_img (line 177) | def _resize_img(self, results):
method _resize_seg (line 199) | def _resize_seg(self, results):
method __call__ (line 210) | def __call__(self, results):
method __repr__ (line 228) | def __repr__(self):
class RandomFlip (line 238) | class RandomFlip(object):
method __init__ (line 252) | def __init__(self, prob=None, direction='horizontal'):
method __call__ (line 259) | def __call__(self, results):
method __repr__ (line 288) | def __repr__(self):
class Pad (line 293) | class Pad(object):
method __init__ (line 308) | def __init__(self,
method _pad_img (line 321) | def _pad_img(self, results):
method _pad_seg (line 334) | def _pad_seg(self, results):
method __call__ (line 342) | def __call__(self, results):
method __repr__ (line 356) | def __repr__(self):
class Normalize (line 364) | class Normalize(object):
method __init__ (line 376) | def __init__(self, mean, std, to_rgb=True):
method __call__ (line 381) | def __call__(self, results):
method __repr__ (line 398) | def __repr__(self):
class Rerange (line 406) | class Rerange(object):
method __init__ (line 416) | def __init__(self, min_value=0, max_value=255):
method __call__ (line 423) | def __call__(self, results):
method __repr__ (line 445) | def __repr__(self):
class CLAHE (line 452) | class CLAHE(object):
method __init__ (line 465) | def __init__(self, clip_limit=40.0, tile_grid_size=(8, 8)):
method __call__ (line 472) | def __call__(self, results):
method __repr__ (line 489) | def __repr__(self):
class RandomCrop (line 497) | class RandomCrop(object):
method __init__ (line 506) | def __init__(self, crop_size, cat_max_ratio=1., ignore_index=255):
method get_crop_bbox (line 512) | def get_crop_bbox(self, img):
method crop (line 523) | def crop(self, img, crop_bbox):
method __call__ (line 529) | def __call__(self, results):
method __repr__ (line 565) | def __repr__(self):
class RandomRotate (line 570) | class RandomRotate(object):
method __init__ (line 588) | def __init__(self,
method __call__ (line 609) | def __call__(self, results):
method __repr__ (line 641) | def __repr__(self):
class RGB2Gray (line 653) | class RGB2Gray(object):
method __init__ (line 668) | def __init__(self, out_channels=None, weights=(0.299, 0.587, 0.114)):
method __call__ (line 676) | def __call__(self, results):
method __repr__ (line 700) | def __repr__(self):
class AdjustGamma (line 708) | class AdjustGamma(object):
method __init__ (line 716) | def __init__(self, gamma=1.0):
method __call__ (line 724) | def __call__(self, results):
method __repr__ (line 739) | def __repr__(self):
class SegRescale (line 744) | class SegRescale(object):
method __init__ (line 751) | def __init__(self, scale_factor=1):
method __call__ (line 754) | def __call__(self, results):
method __repr__ (line 769) | def __repr__(self):
class PhotoMetricDistortion (line 774) | class PhotoMetricDistortion(object):
method __init__ (line 794) | def __init__(self,
method convert (line 804) | def convert(self, img, alpha=1, beta=0):
method brightness (line 810) | def brightness(self, img):
method contrast (line 819) | def contrast(self, img):
method saturation (line 827) | def saturation(self, img):
method hue (line 838) | def hue(self, img):
method __call__ (line 848) | def __call__(self, results):
method __repr__ (line 881) | def __repr__(self):
FILE: annotator/mmpkg/mmseg/datasets/stare.py
class STAREDataset (line 8) | class STAREDataset(CustomDataset):
method __init__ (line 21) | def __init__(self, **kwargs):
FILE: annotator/mmpkg/mmseg/datasets/voc.py
class PascalVOCDataset (line 8) | class PascalVOCDataset(CustomDataset):
method __init__ (line 26) | def __init__(self, split, **kwargs):
FILE: annotator/mmpkg/mmseg/models/backbones/cgnet.py
class GlobalContextExtractor (line 13) | class GlobalContextExtractor(nn.Module):
method __init__ (line 26) | def __init__(self, channel, reduction=16, with_cp=False):
method forward (line 37) | def forward(self, x):
class ContextGuidedBlock (line 53) | class ContextGuidedBlock(nn.Module):
method __init__ (line 78) | def __init__(self,
method forward (line 142) | def forward(self, x):
class InputInjection (line 170) | class InputInjection(nn.Module):
method __init__ (line 173) | def __init__(self, num_downsampling):
method forward (line 179) | def forward(self, x):
class CGNet (line 186) | class CGNet(nn.Module):
method __init__ (line 215) | def __init__(self,
method forward (line 309) | def forward(self, x):
method init_weights (line 338) | def init_weights(self, pretrained=None):
method train (line 359) | def train(self, mode=True):
FILE: annotator/mmpkg/mmseg/models/backbones/fast_scnn.py
class LearningToDownsample (line 13) | class LearningToDownsample(nn.Module):
method __init__ (line 29) | def __init__(self,
method forward (line 66) | def forward(self, x):
class GlobalFeatureExtractor (line 73) | class GlobalFeatureExtractor(nn.Module):
method __init__ (line 106) | def __init__(self,
method _make_layer (line 148) | def _make_layer(self,
method forward (line 172) | def forward(self, x):
class FeatureFusionModule (line 181) | class FeatureFusionModule(nn.Module):
method __init__ (line 199) | def __init__(self,
method forward (line 235) | def forward(self, higher_res_feature, lower_res_feature):
class FastSCNN (line 250) | class FastSCNN(nn.Module):
method __init__ (line 296) | def __init__(self,
method init_weights (line 360) | def init_weights(self, pretrained=None):
method forward (line 367) | def forward(self, x):
FILE: annotator/mmpkg/mmseg/models/backbones/hrnet.py
class HRModule (line 13) | class HRModule(nn.Module):
method __init__ (line 20) | def __init__(self,
method _check_branches (line 46) | def _check_branches(self, num_branches, num_blocks, in_channels,
method _make_one_branch (line 64) | def _make_one_branch(self,
method _make_branches (line 109) | def _make_branches(self, num_branches, block, num_blocks, num_channels):
method _make_fuse_layers (line 119) | def _make_fuse_layers(self):
method forward (line 185) | def forward(self, x):
class HRNet (line 212) | class HRNet(nn.Module):
method __init__ (line 273) | def __init__(self,
method norm1 (line 362) | def norm1(self):
method norm2 (line 367) | def norm2(self):
method _make_transition_layer (line 371) | def _make_transition_layer(self, num_channels_pre_layer,
method _make_layer (line 418) | def _make_layer(self, block, inplanes, planes, blocks, stride=1):
method _make_stage (line 454) | def _make_stage(self, layer_config, in_channels, multiscale_output=True):
method init_weights (line 484) | def init_weights(self, pretrained=None):
method forward (line 510) | def forward(self, x):
method train (line 547) | def train(self, mode=True):
FILE: annotator/mmpkg/mmseg/models/backbones/mobilenet_v2.py
class MobileNetV2 (line 13) | class MobileNetV2(nn.Module):
method __init__ (line 45) | def __init__(self,
method make_layer (line 107) | def make_layer(self, out_channels, num_blocks, stride, dilation,
method init_weights (line 136) | def init_weights(self, pretrained=None):
method forward (line 149) | def forward(self, x):
method _freeze_stages (line 164) | def _freeze_stages(self):
method train (line 174) | def train(self, mode=True):
FILE: annotator/mmpkg/mmseg/models/backbones/mobilenet_v3.py
class MobileNetV3 (line 15) | class MobileNetV3(nn.Module):
method __init__ (line 70) | def __init__(self,
method _make_layer (line 104) | def _make_layer(self):
method init_weights (line 220) | def init_weights(self, pretrained=None):
method forward (line 233) | def forward(self, x):
method _freeze_stages (line 242) | def _freeze_stages(self):
method train (line 249) | def train(self, mode=True):
FILE: annotator/mmpkg/mmseg/models/backbones/resnest.py
class RSoftmax (line 15) | class RSoftmax(nn.Module):
method __init__ (line 23) | def __init__(self, radix, groups):
method forward (line 28) | def forward(self, x):
class SplitAttentionConv2d (line 39) | class SplitAttentionConv2d(nn.Module):
method __init__ (line 58) | def __init__(self,
method norm0 (line 108) | def norm0(self):
method norm1 (line 113) | def norm1(self):
method forward (line 117) | def forward(self, x):
class Bottleneck (line 146) | class Bottleneck(_Bottleneck):
method __init__ (line 165) | def __init__(self,
method forward (line 226) | def forward(self, x):
class ResNeSt (line 270) | class ResNeSt(ResNetV1d):
method __init__ (line 291) | def __init__(self,
method make_res_layer (line 305) | def make_res_layer(self, **kwargs):
FILE: annotator/mmpkg/mmseg/models/backbones/resnet.py
class BasicBlock (line 13) | class BasicBlock(nn.Module):
method __init__ (line 18) | def __init__(self,
method norm1 (line 58) | def norm1(self):
method norm2 (line 63) | def norm2(self):
method forward (line 67) | def forward(self, x):
class Bottleneck (line 97) | class Bottleneck(nn.Module):
method __init__ (line 106) | def __init__(self,
method make_block_plugins (line 219) | def make_block_plugins(self, in_channels, plugins):
method forward_plugin (line 242) | def forward_plugin(self, x, plugin_names):
method norm1 (line 250) | def norm1(self):
method norm2 (line 255) | def norm2(self):
method norm3 (line 260) | def norm3(self):
method forward (line 264) | def forward(self, x):
class ResNet (line 308) | class ResNet(nn.Module):
method __init__ (line 373) | def __init__(self,
method make_stage_plugins (line 470) | def make_stage_plugins(self, plugins, stage_idx):
method make_res_layer (line 523) | def make_res_layer(self, **kwargs):
method norm1 (line 528) | def norm1(self):
method _make_stem_layer (line 532) | def _make_stem_layer(self, in_channels, stem_channels):
method _freeze_stages (line 581) | def _freeze_stages(self):
method init_weights (line 600) | def init_weights(self, pretrained=None):
method forward (line 632) | def forward(self, x):
method train (line 649) | def train(self, mode=True):
class ResNetV1c (line 662) | class ResNetV1c(ResNet):
method __init__ (line 672) | def __init__(self, **kwargs):
class ResNetV1d (line 678) | class ResNetV1d(ResNet):
method __init__ (line 686) | def __init__(self, **kwargs):
FILE: annotator/mmpkg/mmseg/models/backbones/resnext.py
class Bottleneck (line 11) | class Bottleneck(_Bottleneck):
method __init__ (line 18) | def __init__(self,
class ResNeXt (line 87) | class ResNeXt(ResNet):
method __init__ (line 134) | def __init__(self, groups=1, base_width=4, **kwargs):
method make_res_layer (line 139) | def make_res_layer(self, **kwargs):
FILE: annotator/mmpkg/mmseg/models/backbones/unet.py
class BasicConvBlock (line 13) | class BasicConvBlock(nn.Module):
method __init__ (line 43) | def __init__(self,
method forward (line 76) | def forward(self, x):
class DeconvModule (line 87) | class DeconvModule(nn.Module):
method __init__ (line 105) | def __init__(self,
method forward (line 137) | def forward(self, x):
class InterpConv (line 148) | class InterpConv(nn.Module):
method __init__ (line 179) | def __init__(self,
method forward (line 211) | def forward(self, x):
class UNet (line 222) | class UNet(nn.Module):
method __init__ (line 277) | def __init__(self,
method forward (line 376) | def forward(self, x):
method train (line 389) | def train(self, mode=True):
method _check_input_divisible (line 399) | def _check_input_divisible(self, x):
method init_weights (line 412) | def init_weights(self, pretrained=None):
FILE: annotator/mmpkg/mmseg/models/backbones/vit.py
class Mlp (line 20) | class Mlp(nn.Module):
method __init__ (line 36) | def __init__(self,
method forward (line 50) | def forward(self, x):
class Attention (line 59) | class Attention(nn.Module):
method __init__ (line 72) | def __init__(self,
method forward (line 89) | def forward(self, x):
class Block (line 105) | class Block(nn.Module):
method __init__ (line 128) | def __init__(self,
method forward (line 156) | def forward(self, x):
class PatchEmbed (line 171) | class PatchEmbed(nn.Module):
method __init__ (line 183) | def __init__(self,
method forward (line 201) | def forward(self, x):
class VisionTransformer (line 206) | class VisionTransformer(nn.Module):
method __init__ (line 246) | def __init__(self,
method init_weights (line 314) | def init_weights(self, pretrained=None):
method _pos_embeding (line 359) | def _pos_embeding(self, img, patched_img, pos_embed):
method resize_pos_embed (line 392) | def resize_pos_embed(pos_embed, input_shpae, pos_shape, patch_size, mo...
method forward (line 421) | def forward(self, inputs):
method train (line 454) | def train(self, mode=True):
FILE: annotator/mmpkg/mmseg/models/builder.py
function build_backbone (line 15) | def build_backbone(cfg):
function build_neck (line 20) | def build_neck(cfg):
function build_head (line 25) | def build_head(cfg):
function build_loss (line 30) | def build_loss(cfg):
function build_segmentor (line 35) | def build_segmentor(cfg, train_cfg=None, test_cfg=None):
FILE: annotator/mmpkg/mmseg/models/decode_heads/ann_head.py
class PPMConcat (line 10) | class PPMConcat(nn.ModuleList):
method __init__ (line 18) | def __init__(self, pool_scales=(1, 3, 6, 8)):
method forward (line 22) | def forward(self, feats):
class SelfAttentionBlock (line 32) | class SelfAttentionBlock(_SelfAttentionBlock):
method __init__ (line 52) | def __init__(self, low_in_channels, high_in_channels, channels,
class AFNB (line 79) | class AFNB(nn.Module):
method __init__ (line 99) | def __init__(self, low_in_channels, high_in_channels, channels,
method forward (line 125) | def forward(self, low_feats, high_feats):
class APNB (line 133) | class APNB(nn.Module):
method __init__ (line 150) | def __init__(self, in_channels, channels, out_channels, query_scales,
method forward (line 175) | def forward(self, feats):
class ANNHead (line 184) | class ANNHead(BaseDecodeHead):
method __init__ (line 198) | def __init__(self,
method forward (line 236) | def forward(self, inputs):
FILE: annotator/mmpkg/mmseg/models/decode_heads/apc_head.py
class ACM (line 11) | class ACM(nn.Module):
method __init__ (line 25) | def __init__(self, pool_scale, fusion, in_channels, channels, conv_cfg,
method forward (line 78) | def forward(self, x):
class APCHead (line 110) | class APCHead(BaseDecodeHead):
method __init__ (line 124) | def __init__(self, pool_scales=(1, 2, 3, 6), fusion=True, **kwargs):
method forward (line 149) | def forward(self, inputs):
FILE: annotator/mmpkg/mmseg/models/decode_heads/aspp_head.py
class ASPPModule (line 10) | class ASPPModule(nn.ModuleList):
method __init__ (line 22) | def __init__(self, dilations, in_channels, channels, conv_cfg, norm_cfg,
method forward (line 43) | def forward(self, x):
class ASPPHead (line 53) | class ASPPHead(BaseDecodeHead):
method __init__ (line 64) | def __init__(self, dilations=(1, 6, 12, 18), **kwargs):
method forward (line 93) | def forward(self, inputs):
FILE: annotator/mmpkg/mmseg/models/decode_heads/cascade_decode_head.py
class BaseCascadeDecodeHead (line 6) | class BaseCascadeDecodeHead(BaseDecodeHead, metaclass=ABCMeta):
method __init__ (line 10) | def __init__(self, *args, **kwargs):
method forward (line 14) | def forward(self, inputs, prev_output):
method forward_train (line 18) | def forward_train(self, inputs, prev_output, img_metas, gt_semantic_seg,
method forward_test (line 41) | def forward_test(self, inputs, prev_output, img_metas, test_cfg):
FILE: annotator/mmpkg/mmseg/models/decode_heads/cc_head.py
class CCHead (line 16) | class CCHead(FCNHead):
method __init__ (line 27) | def __init__(self, recurrence=2, **kwargs):
method forward (line 35) | def forward(self, inputs):
FILE: annotator/mmpkg/mmseg/models/decode_heads/da_head.py
class PAM (line 12) | class PAM(_SelfAttentionBlock):
method __init__ (line 20) | def __init__(self, in_channels, channels):
method forward (line 41) | def forward(self, x):
class CAM (line 49) | class CAM(nn.Module):
method __init__ (line 52) | def __init__(self):
method forward (line 56) | def forward(self, x):
class DAHead (line 75) | class DAHead(BaseDecodeHead):
method __init__ (line 85) | def __init__(self, pam_channels, **kwargs):
method pam_cls_seg (line 128) | def pam_cls_seg(self, feat):
method cam_cls_seg (line 135) | def cam_cls_seg(self, feat):
method forward (line 142) | def forward(self, inputs):
method forward_test (line 160) | def forward_test(self, inputs, img_metas, test_cfg):
method losses (line 164) | def losses(self, seg_logit, seg_label):
FILE: annotator/mmpkg/mmseg/models/decode_heads/decode_head.py
class BaseDecodeHead (line 14) | class BaseDecodeHead(nn.Module, metaclass=ABCMeta):
method __init__ (line 46) | def __init__(self,
method extra_repr (line 88) | def extra_repr(self):
method _init_inputs (line 95) | def _init_inputs(self, in_channels, in_index, input_transform):
method init_weights (line 133) | def init_weights(self):
method _transform_inputs (line 137) | def _transform_inputs(self, inputs):
method forward (line 166) | def forward(self, inputs):
method forward_train (line 170) | def forward_train(self, inputs, img_metas, gt_semantic_seg, train_cfg):
method forward_test (line 190) | def forward_test(self, inputs, img_metas, test_cfg):
method cls_seg (line 207) | def cls_seg(self, feat):
method losses (line 215) | def losses(self, seg_logit, seg_label):
FILE: annotator/mmpkg/mmseg/models/decode_heads/dm_head.py
class DCM (line 10) | class DCM(nn.Module):
method __init__ (line 24) | def __init__(self, filter_size, fusion, in_channels, channels, conv_cfg,
method forward (line 60) | def forward(self, x):
class DMHead (line 92) | class DMHead(BaseDecodeHead):
method __init__ (line 106) | def __init__(self, filter_sizes=(1, 3, 5, 7), fusion=False, **kwargs):
method forward (line 131) | def forward(self, inputs):
FILE: annotator/mmpkg/mmseg/models/decode_heads/dnl_head.py
class DisentangledNonLocal2d (line 9) | class DisentangledNonLocal2d(NonLocal2d):
method __init__ (line 16) | def __init__(self, *arg, temperature, **kwargs):
method embedded_gaussian (line 21) | def embedded_gaussian(self, theta_x, phi_x):
method forward (line 33) | def forward(self, x):
class DNLHead (line 87) | class DNLHead(FCNHead):
method __init__ (line 102) | def __init__(self,
method forward (line 122) | def forward(self, inputs):
FILE: annotator/mmpkg/mmseg/models/decode_heads/ema_head.py
function reduce_mean (line 13) | def reduce_mean(tensor):
class EMAModule (line 22) | class EMAModule(nn.Module):
method __init__ (line 31) | def __init__(self, channels, num_bases, num_stages, momentum):
method forward (line 44) | def forward(self, feats):
class EMAHead (line 79) | class EMAHead(BaseDecodeHead):
method __init__ (line 94) | def __init__(self,
method forward (line 154) | def forward(self, inputs):
FILE: annotator/mmpkg/mmseg/models/decode_heads/enc_head.py
class EncModule (line 11) | class EncModule(nn.Module):
method __init__ (line 22) | def __init__(self, in_channels, num_codes, conv_cfg, norm_cfg, act_cfg):
method forward (line 50) | def forward(self, x):
class EncHead (line 62) | class EncHead(BaseDecodeHead):
method __init__ (line 78) | def __init__(self,
method forward (line 129) | def forward(self, inputs):
method forward_test (line 151) | def forward_test(self, inputs, img_metas, test_cfg):
method _convert_to_onehot_labels (line 159) | def _convert_to_onehot_labels(seg_label, num_classes):
method losses (line 178) | def losses(self, seg_logit, seg_label):
FILE: annotator/mmpkg/mmseg/models/decode_heads/fcn_head.py
class FCNHead (line 10) | class FCNHead(BaseDecodeHead):
method __init__ (line 23) | def __init__(self,
method forward (line 74) | def forward(self, inputs):
FILE: annotator/mmpkg/mmseg/models/decode_heads/fpn_head.py
class FPNHead (line 11) | class FPNHead(BaseDecodeHead):
method __init__ (line 23) | def __init__(self, feature_strides, **kwargs):
method forward (line 54) | def forward(self, inputs):
FILE: annotator/mmpkg/mmseg/models/decode_heads/gc_head.py
class GCHead (line 9) | class GCHead(FCNHead):
method __init__ (line 23) | def __init__(self,
method forward (line 38) | def forward(self, inputs):
FILE: annotator/mmpkg/mmseg/models/decode_heads/lraspp_head.py
class LRASPPHead (line 12) | class LRASPPHead(BaseDecodeHead):
method __init__ (line 23) | def __init__(self, branch_channels=(32, 64), **kwargs):
method forward (line 68) | def forward(self, inputs):
FILE: annotator/mmpkg/mmseg/models/decode_heads/nl_head.py
class NLHead (line 9) | class NLHead(FCNHead):
method __init__ (line 23) | def __init__(self,
method forward (line 40) | def forward(self, inputs):
FILE: annotator/mmpkg/mmseg/models/decode_heads/ocr_head.py
class SpatialGatherModule (line 12) | class SpatialGatherModule(nn.Module):
method __init__ (line 19) | def __init__(self, scale):
method forward (line 23) | def forward(self, feats, probs):
class ObjectAttentionBlock (line 39) | class ObjectAttentionBlock(_SelfAttentionBlock):
method __init__ (line 42) | def __init__(self, in_channels, channels, scale, conv_cfg, norm_cfg,
method forward (line 73) | def forward(self, query_feats, key_feats):
class OCRHead (line 85) | class OCRHead(BaseCascadeDecodeHead):
method __init__ (line 97) | def __init__(self, ocr_channels, scale=1, **kwargs):
method forward (line 119) | def forward(self, inputs, prev_output):
FILE: annotator/mmpkg/mmseg/models/decode_heads/point_head.py
function calculate_uncertainty (line 19) | def calculate_uncertainty(seg_logits):
class PointHead (line 40) | class PointHead(BaseCascadeDecodeHead):
method __init__ (line 65) | def __init__(self,
method init_weights (line 109) | def init_weights(self):
method cls_seg (line 113) | def cls_seg(self, feat):
method forward (line 120) | def forward(self, fine_grained_point_feats, coarse_point_feats):
method _get_fine_grained_point_feats (line 128) | def _get_fine_grained_point_feats(self, x, points):
method _get_coarse_point_feats (line 152) | def _get_coarse_point_feats(self, prev_output, points):
method forward_train (line 170) | def forward_train(self, inputs, prev_output, img_metas, gt_semantic_seg,
method forward_test (line 208) | def forward_test(self, inputs, prev_output, img_metas, test_cfg):
method losses (line 253) | def losses(self, point_logits, point_label):
method get_points_train (line 261) | def get_points_train(self, seg_logits, uncertainty_func, cfg):
method get_points_test (line 315) | def get_points_test(self, seg_logits, uncertainty_func, cfg):
FILE: annotator/mmpkg/mmseg/models/decode_heads/psa_head.py
class PSAHead (line 20) | class PSAHead(BaseDecodeHead):
method __init__ (line 38) | def __init__(self,
method forward (line 116) | def forward(self, inputs):
FILE: annotator/mmpkg/mmseg/models/decode_heads/psp_head.py
class PPM (line 10) | class PPM(nn.ModuleList):
method __init__ (line 24) | def __init__(self, pool_scales, in_channels, channels, conv_cfg, norm_...
method forward (line 46) | def forward(self, x):
class PSPHead (line 61) | class PSPHead(BaseDecodeHead):
method __init__ (line 72) | def __init__(self, pool_scales=(1, 2, 3, 6), **kwargs):
method forward (line 93) | def forward(self, inputs):
FILE: annotator/mmpkg/mmseg/models/decode_heads/sep_aspp_head.py
class DepthwiseSeparableASPPModule (line 10) | class DepthwiseSeparableASPPModule(ASPPModule):
method __init__ (line 14) | def __init__(self, **kwargs):
class DepthwiseSeparableASPPHead (line 29) | class DepthwiseSeparableASPPHead(ASPPHead):
method __init__ (line 42) | def __init__(self, c1_in_channels, c1_channels, **kwargs):
method forward (line 78) | def forward(self, inputs):
FILE: annotator/mmpkg/mmseg/models/decode_heads/sep_fcn_head.py
class DepthwiseSeparableFCNHead (line 8) | class DepthwiseSeparableFCNHead(FCNHead):
method __init__ (line 29) | def __init__(self, **kwargs):
FILE: annotator/mmpkg/mmseg/models/decode_heads/uper_head.py
class UPerHead (line 12) | class UPerHead(BaseDecodeHead):
method __init__ (line 23) | def __init__(self, pool_scales=(1, 2, 3, 6), **kwargs):
method psp_forward (line 76) | def psp_forward(self, inputs):
method forward (line 86) | def forward(self, inputs):
FILE: annotator/mmpkg/mmseg/models/losses/accuracy.py
function accuracy (line 4) | def accuracy(pred, target, topk=1, thresh=None):
class Accuracy (line 52) | class Accuracy(nn.Module):
method __init__ (line 55) | def __init__(self, topk=(1, ), thresh=None):
method forward (line 68) | def forward(self, pred, target):
FILE: annotator/mmpkg/mmseg/models/losses/cross_entropy_loss.py
function cross_entropy (line 9) | def cross_entropy(pred,
function _expand_onehot_labels (line 35) | def _expa
Condensed preview — 932 files, each showing path, character count, and a content snippet. Download the .json file or copy for the full structured content (6,808K chars).
[
{
"path": ".github/ISSUE_TEMPLATE/bug_report.yml",
"chars": 3269,
"preview": "name: Bug Report\ndescription: Create a report\ntitle: \"[Bug]: \"\nlabels: [\"bug-report\"]\n\nbody:\n - type: checkboxes\n at"
},
{
"path": ".github/ISSUE_TEMPLATE/config.yml",
"chars": 27,
"preview": "blank_issues_enabled: true\n"
},
{
"path": ".github/workflows/lint.yaml",
"chars": 661,
"preview": "name: Linter\n\non:\n - push\n - pull_request\n\njobs:\n lint-python:\n name: ruff\n runs-on: ubuntu-latest\n steps:\n "
},
{
"path": ".github/workflows/tests.yml",
"chars": 4548,
"preview": "name: Run basic features tests on CPU\n\non:\n - push\n - pull_request\n\nenv:\n FORGE_CQ_TEST: \"True\"\n\njobs:\n build:\n r"
},
{
"path": ".gitignore",
"chars": 3551,
"preview": "# Byte-compiled / optimized / DLL files\n__pycache__/\n*.py[cod]\n*$py.class\n\n# C extensions\n*.so\n\n# Distribution / packagi"
},
{
"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": 18401,
"preview": "# ControlNet for Stable Diffusion WebUI\n\nThe WebUI extension for ControlNet and other injection-based SD controls.\n![ima"
},
{
"path": "annotator/__init__.py",
"chars": 0,
"preview": ""
},
{
"path": "annotator/anime_face_segment/LICENSE",
"chars": 1068,
"preview": "MIT License\n\nCopyright (c) 2021 Miaomiao Li\n\nPermission is hereby granted, free of charge, to any person obtaining a cop"
},
{
"path": "annotator/anime_face_segment/__init__.py",
"chars": 5841,
"preview": "import os\nimport torch\nimport torch.nn as nn\nimport torch.nn.functional as F\nfrom PIL import Image\nimport fnmatch\nimport"
},
{
"path": "annotator/annotator_path.py",
"chars": 1050,
"preview": "import os\nfrom modules import shared\n\nmodels_path = shared.opts.data.get('control_net_modules_path', None)\nif not models"
},
{
"path": "annotator/binary/__init__.py",
"chars": 491,
"preview": "import cv2\n\n\ndef apply_binary(img, bin_threshold):\n img_gray = cv2.cvtColor(img, cv2.COLOR_RGB2GRAY)\n\n if bin_thre"
},
{
"path": "annotator/canny/__init__.py",
"chars": 123,
"preview": "import cv2\n\n\ndef apply_canny(img, low_threshold, high_threshold):\n return cv2.Canny(img, low_threshold, high_threshol"
},
{
"path": "annotator/clipvision/__init__.py",
"chars": 5506,
"preview": "import os\nimport cv2\nimport torch\nimport numpy as np\n\nfrom einops import rearrange\nfrom modules import devices\nfrom anno"
},
{
"path": "annotator/color/__init__.py",
"chars": 646,
"preview": "import cv2\n\ndef cv2_resize_shortest_edge(image, size):\n h, w = image.shape[:2]\n if h < w:\n new_h = size\n "
},
{
"path": "annotator/densepose/__init__.py",
"chars": 2700,
"preview": "import torchvision # Fix issue Unknown builtin op: torchvision::nms\nimport cv2\nimport numpy as np\nimport torch\nfrom eino"
},
{
"path": "annotator/densepose/densepose.py",
"chars": 11925,
"preview": "from typing import Tuple\nimport math\nimport numpy as np\nfrom enum import IntEnum\nfrom typing import List, Tuple, Union\ni"
},
{
"path": "annotator/depth_anything.py",
"chars": 2550,
"preview": "import os\nimport torch\nimport cv2\nimport numpy as np\nimport torch.nn.functional as F\nfrom torchvision.transforms import "
},
{
"path": "annotator/depth_anything_v2.py",
"chars": 2729,
"preview": "import os\r\nimport torch\r\nimport cv2\r\nimport numpy as np\r\nimport torch.nn.functional as F\r\nfrom torchvision.transforms im"
},
{
"path": "annotator/hed/__init__.py",
"chars": 4513,
"preview": "# This is an improved version and model of HED edge detection with Apache License, Version 2.0.\n# Please use this implem"
},
{
"path": "annotator/keypose/__init__.py",
"chars": 7768,
"preview": "import numpy as np\nimport cv2\nimport torch\n\nimport os\nfrom modules import devices\nfrom annotator.annotator_path import m"
},
{
"path": "annotator/keypose/faster_rcnn_r50_fpn_coco.py",
"chars": 5870,
"preview": "checkpoint_config = dict(interval=1)\n# yapf:disable\nlog_config = dict(\n interval=50,\n hooks=[\n dict(type='T"
},
{
"path": "annotator/keypose/hrnet_w48_coco_256x192.py",
"chars": 5108,
"preview": "# _base_ = [\n# '../../../../_base_/default_runtime.py',\n# '../../../../_base_/datasets/coco.py'\n# ]\nevaluation ="
},
{
"path": "annotator/lama/__init__.py",
"chars": 2351,
"preview": "# https://github.com/advimman/lama\n\nimport yaml\nimport torch\nfrom omegaconf import OmegaConf\nimport numpy as np\n\nfrom ei"
},
{
"path": "annotator/lama/config.yaml",
"chars": 3947,
"preview": "run_title: b18_ffc075_batch8x15\ntraining_model:\n kind: default\n visualize_each_iters: 1000\n concat_mask: true\n store"
},
{
"path": "annotator/lama/saicinpainting/__init__.py",
"chars": 0,
"preview": ""
},
{
"path": "annotator/lama/saicinpainting/training/__init__.py",
"chars": 0,
"preview": ""
},
{
"path": "annotator/lama/saicinpainting/training/data/__init__.py",
"chars": 0,
"preview": ""
},
{
"path": "annotator/lama/saicinpainting/training/data/masks.py",
"chars": 13720,
"preview": "import math\nimport random\nimport hashlib\nimport logging\nfrom enum import Enum\n\nimport cv2\nimport numpy as np\n\n# from ann"
},
{
"path": "annotator/lama/saicinpainting/training/losses/__init__.py",
"chars": 0,
"preview": ""
},
{
"path": "annotator/lama/saicinpainting/training/losses/adversarial.py",
"chars": 8593,
"preview": "from typing import Tuple, Dict, Optional\n\nimport torch\nimport torch.nn as nn\nimport torch.nn.functional as F\n\n\nclass Bas"
},
{
"path": "annotator/lama/saicinpainting/training/losses/constants.py",
"chars": 3061,
"preview": "weights = {\"ade20k\": \n [6.34517766497462,\n 9.328358208955224,\n 11.389521640091116,\n 16.10305958132045,\n 2"
},
{
"path": "annotator/lama/saicinpainting/training/losses/distance_weighting.py",
"chars": 5466,
"preview": "import torch\nimport torch.nn as nn\nimport torch.nn.functional as F\nimport torchvision\n\nfrom annotator.lama.saicinpaintin"
},
{
"path": "annotator/lama/saicinpainting/training/losses/feature_matching.py",
"chars": 1313,
"preview": "from typing import List\n\nimport torch\nimport torch.nn.functional as F\n\n\ndef masked_l2_loss(pred, target, mask, weight_kn"
},
{
"path": "annotator/lama/saicinpainting/training/losses/perceptual.py",
"chars": 4142,
"preview": "import torch\nimport torch.nn as nn\nimport torch.nn.functional as F\nimport torchvision\n\n# from models.ade20k import Model"
},
{
"path": "annotator/lama/saicinpainting/training/losses/segmentation.py",
"chars": 2005,
"preview": "import torch\nimport torch.nn as nn\nimport torch.nn.functional as F\n\nfrom .constants import weights as constant_weights\n\n"
},
{
"path": "annotator/lama/saicinpainting/training/losses/style_loss.py",
"chars": 4777,
"preview": "import torch\nimport torch.nn as nn\nimport torchvision.models as models\n\n\nclass PerceptualLoss(nn.Module):\n r\"\"\"\n P"
},
{
"path": "annotator/lama/saicinpainting/training/modules/__init__.py",
"chars": 1002,
"preview": "import logging\n\nfrom annotator.lama.saicinpainting.training.modules.ffc import FFCResNetGenerator\nfrom annotator.lama.sa"
},
{
"path": "annotator/lama/saicinpainting/training/modules/base.py",
"chars": 2714,
"preview": "import abc\nfrom typing import Tuple, List\n\nimport torch\nimport torch.nn as nn\n\nfrom annotator.lama.saicinpainting.traini"
},
{
"path": "annotator/lama/saicinpainting/training/modules/depthwise_sep_conv.py",
"chars": 557,
"preview": "import torch\nimport torch.nn as nn\n\nclass DepthWiseSeperableConv(nn.Module):\n def __init__(self, in_dim, out_dim, *ar"
},
{
"path": "annotator/lama/saicinpainting/training/modules/fake_fakes.py",
"chars": 2141,
"preview": "import torch\nfrom kornia import SamplePadding\nfrom kornia.augmentation import RandomAffine, CenterCrop\n\n\nclass FakeFakes"
},
{
"path": "annotator/lama/saicinpainting/training/modules/ffc.py",
"chars": 20410,
"preview": "# Fast Fourier Convolution NeurIPS 2020\n# original implementation https://github.com/pkumivision/FFC/blob/main/model_zoo"
},
{
"path": "annotator/lama/saicinpainting/training/modules/multidilated_conv.py",
"chars": 4075,
"preview": "import torch\nimport torch.nn as nn\nimport random\nfrom annotator.lama.saicinpainting.training.modules.depthwise_sep_conv "
},
{
"path": "annotator/lama/saicinpainting/training/modules/multiscale.py",
"chars": 10729,
"preview": "from typing import List, Tuple, Union, Optional\n\nimport torch\nimport torch.nn as nn\nimport torch.nn.functional as F\n\nfro"
},
{
"path": "annotator/lama/saicinpainting/training/modules/pix2pixhd.py",
"chars": 28009,
"preview": "# original: https://github.com/NVIDIA/pix2pixHD/blob/master/models/networks.py\nimport collections\nfrom functools import "
},
{
"path": "annotator/lama/saicinpainting/training/modules/spatial_transform.py",
"chars": 1976,
"preview": "import torch\nimport torch.nn as nn\nimport torch.nn.functional as F\nfrom kornia.geometry.transform import rotate\n\n\nclass "
},
{
"path": "annotator/lama/saicinpainting/training/modules/squeeze_excitation.py",
"chars": 609,
"preview": "import torch.nn as nn\n\n\nclass SELayer(nn.Module):\n def __init__(self, channel, reduction=16):\n super(SELayer, "
},
{
"path": "annotator/lama/saicinpainting/training/trainers/__init__.py",
"chars": 890,
"preview": "import logging\nimport torch\nfrom annotator.lama.saicinpainting.training.trainers.default import DefaultInpaintingTrainin"
},
{
"path": "annotator/lama/saicinpainting/training/trainers/base.py",
"chars": 14189,
"preview": "import copy\nimport logging\nfrom typing import Dict, Tuple\n\nimport pandas as pd\nimport pytorch_lightning as ptl\nimport to"
},
{
"path": "annotator/lama/saicinpainting/training/trainers/default.py",
"chars": 9500,
"preview": "import logging\n\nimport torch\nimport torch.nn.functional as F\nfrom omegaconf import OmegaConf\n\n# from annotator.lama.saic"
},
{
"path": "annotator/lama/saicinpainting/training/visualizers/__init__.py",
"chars": 461,
"preview": "import logging\n\nfrom annotator.lama.saicinpainting.training.visualizers.directory import DirectoryVisualizer\nfrom annota"
},
{
"path": "annotator/lama/saicinpainting/training/visualizers/base.py",
"chars": 2639,
"preview": "import abc\nfrom typing import Dict, List\n\nimport numpy as np\nimport torch\nfrom skimage import color\nfrom skimage.segment"
},
{
"path": "annotator/lama/saicinpainting/training/visualizers/colors.py",
"chars": 2945,
"preview": "import random\nimport colorsys\n\nimport numpy as np\nimport matplotlib\nmatplotlib.use('agg')\nimport matplotlib.pyplot as pl"
},
{
"path": "annotator/lama/saicinpainting/training/visualizers/directory.py",
"chars": 1632,
"preview": "import os\n\nimport cv2\nimport numpy as np\n\nfrom annotator.lama.saicinpainting.training.visualizers.base import BaseVisual"
},
{
"path": "annotator/lama/saicinpainting/training/visualizers/noop.py",
"chars": 262,
"preview": "from annotator.lama.saicinpainting.training.visualizers.base import BaseVisualizer\n\n\nclass NoopVisualizer(BaseVisualizer"
},
{
"path": "annotator/lama/saicinpainting/utils.py",
"chars": 5268,
"preview": "import bisect\nimport functools\nimport logging\nimport numbers\nimport os\nimport signal\nimport sys\nimport traceback\nimport "
},
{
"path": "annotator/leres/__init__.py",
"chars": 4004,
"preview": "import cv2\nimport numpy as np\nimport torch\nimport os\nfrom modules import devices, shared\nfrom annotator.annotator_path i"
},
{
"path": "annotator/leres/leres/LICENSE",
"chars": 1132,
"preview": "https://github.com/thygate/stable-diffusion-webui-depthmap-script\n\nMIT License\n\nCopyright (c) 2023 Bob Thiry\n\nPermission"
},
{
"path": "annotator/leres/leres/Resnet.py",
"chars": 6241,
"preview": "import torch.nn as nn\nimport torch.nn as NN\n\n__all__ = ['ResNet', 'resnet18', 'resnet34', 'resnet50', 'resnet101',\n "
},
{
"path": "annotator/leres/leres/Resnext_torch.py",
"chars": 8547,
"preview": "#!/usr/bin/env python\n# coding: utf-8\nimport torch.nn as nn\n\ntry:\n from urllib import urlretrieve\nexcept ImportError:"
},
{
"path": "annotator/leres/leres/depthmap.py",
"chars": 22911,
"preview": "# Author: thygate\n# https://github.com/thygate/stable-diffusion-webui-depthmap-script\n\nfrom modules import devices\nfrom "
},
{
"path": "annotator/leres/leres/multi_depth_model_woauxi.py",
"chars": 1148,
"preview": "from . import network_auxi as network\nfrom .net_tools import get_func\nimport torch\nimport torch.nn as nn\nfrom modules im"
},
{
"path": "annotator/leres/leres/net_tools.py",
"chars": 2024,
"preview": "import importlib\nimport torch\nimport os\nfrom collections import OrderedDict\n\n\ndef get_func(func_name):\n \"\"\"Helper to "
},
{
"path": "annotator/leres/leres/network_auxi.py",
"chars": 16887,
"preview": "import torch\nimport torch.nn as nn\nimport torch.nn.init as init\n\nfrom . import Resnet, Resnext_torch\n\n\ndef resnet50_stri"
},
{
"path": "annotator/leres/pix2pix/LICENSE",
"chars": 1223,
"preview": "https://github.com/compphoto/BoostingMonocularDepth\n\nCopyright 2021, Seyed Mahdi Hosseini Miangoleh, Sebastian Dille, Co"
},
{
"path": "annotator/leres/pix2pix/models/__init__.py",
"chars": 3090,
"preview": "\"\"\"This package contains modules related to objective functions, optimizations, and network architectures.\n\nTo add a cus"
},
{
"path": "annotator/leres/pix2pix/models/base_model.py",
"chars": 10712,
"preview": "import os\nimport torch, gc\nfrom modules import devices\nfrom collections import OrderedDict\nfrom abc import ABC, abstract"
},
{
"path": "annotator/leres/pix2pix/models/base_model_hg.py",
"chars": 1660,
"preview": "import os\nimport torch\n\nclass BaseModelHG():\n def name(self):\n return 'BaseModel'\n\n def initialize(self, op"
},
{
"path": "annotator/leres/pix2pix/models/networks.py",
"chars": 28955,
"preview": "import torch\nimport torch.nn as nn\nfrom torch.nn import init\nimport functools\nfrom torch.optim import lr_scheduler\n\n\n###"
},
{
"path": "annotator/leres/pix2pix/models/pix2pix4depth_model.py",
"chars": 7404,
"preview": "import torch\nfrom .base_model import BaseModel\nfrom . import networks\n\n\nclass Pix2Pix4DepthModel(BaseModel):\n \"\"\" Thi"
},
{
"path": "annotator/leres/pix2pix/options/__init__.py",
"chars": 136,
"preview": "\"\"\"This package options includes option modules: training options, test options, and basic options (used in both trainin"
},
{
"path": "annotator/leres/pix2pix/options/base_options.py",
"chars": 9364,
"preview": "import argparse\nimport os\nfrom ...pix2pix.util import util\n# import torch\nfrom ...pix2pix import models\n# import pix2pix"
},
{
"path": "annotator/leres/pix2pix/options/test_options.py",
"chars": 1062,
"preview": "from .base_options import BaseOptions\n\n\nclass TestOptions(BaseOptions):\n \"\"\"This class includes test options.\n\n It"
},
{
"path": "annotator/leres/pix2pix/util/__init__.py",
"chars": 83,
"preview": "\"\"\"This package includes a miscellaneous collection of useful helper functions.\"\"\"\n"
},
{
"path": "annotator/leres/pix2pix/util/get_data.py",
"chars": 3639,
"preview": "from __future__ import print_function\nimport os\nimport tarfile\nimport requests\nfrom warnings import warn\nfrom zipfile im"
},
{
"path": "annotator/leres/pix2pix/util/guidedfilter.py",
"chars": 1532,
"preview": "import numpy as np\n\nclass GuidedFilter():\n def __init__(self, source, reference, r=64, eps= 0.05**2):\n self.so"
},
{
"path": "annotator/leres/pix2pix/util/html.py",
"chars": 3223,
"preview": "import dominate\nfrom dominate.tags import meta, h3, table, tr, td, p, a, img, br\nimport os\n\n\nclass HTML:\n \"\"\"This HTM"
},
{
"path": "annotator/leres/pix2pix/util/image_pool.py",
"chars": 2226,
"preview": "import random\nimport torch\n\n\nclass ImagePool():\n \"\"\"This class implements an image buffer that stores previously gene"
},
{
"path": "annotator/leres/pix2pix/util/util.py",
"chars": 3110,
"preview": "\"\"\"This module contains simple helper functions \"\"\"\nfrom __future__ import print_function\nimport torch\nimport numpy as n"
},
{
"path": "annotator/leres/pix2pix/util/visualizer.py",
"chars": 7532,
"preview": "import numpy as np\nimport os\nimport sys\nimport ntpath\nimport time\nfrom . import util, html\nfrom subprocess import Popen,"
},
{
"path": "annotator/lineart/LICENSE",
"chars": 1069,
"preview": "MIT License\n\nCopyright (c) 2022 Caroline Chan\n\nPermission is hereby granted, free of charge, to any person obtaining a c"
},
{
"path": "annotator/lineart/__init__.py",
"chars": 4280,
"preview": "import os\nimport cv2\nimport torch\nimport numpy as np\n\nimport torch.nn as nn\nfrom einops import rearrange\nfrom modules im"
},
{
"path": "annotator/lineart_anime/LICENSE",
"chars": 1069,
"preview": "MIT License\n\nCopyright (c) 2022 Caroline Chan\n\nPermission is hereby granted, free of charge, to any person obtaining a c"
},
{
"path": "annotator/lineart_anime/__init__.py",
"chars": 7188,
"preview": "import numpy as np\nimport torch\nimport torch.nn as nn\nimport functools\n\nimport os\nimport cv2\nfrom einops import rearrang"
},
{
"path": "annotator/manga_line/LICENSE",
"chars": 1068,
"preview": "MIT License\n\nCopyright (c) 2021 Miaomiao Li\n\nPermission is hereby granted, free of charge, to any person obtaining a cop"
},
{
"path": "annotator/manga_line/__init__.py",
"chars": 9234,
"preview": "import os\nimport torch\nimport torch.nn as nn\nfrom PIL import Image\nimport fnmatch\nimport cv2\n\nimport sys\n\nimport numpy a"
},
{
"path": "annotator/mediapipe_face/__init__.py",
"chars": 204,
"preview": "from .mediapipe_face_common import generate_annotation\n\n\ndef apply_mediapipe_face(image, max_faces: int = 1, min_confide"
},
{
"path": "annotator/mediapipe_face/mediapipe_face_common.py",
"chars": 6714,
"preview": "from typing import Mapping\n\nimport mediapipe as mp\nimport numpy\n\n\nmp_drawing = mp.solutions.drawing_utils\nmp_drawing_sty"
},
{
"path": "annotator/midas/LICENSE",
"chars": 1098,
"preview": "MIT License\n\nCopyright (c) 2019 Intel ISL (Intel Intelligent Systems Lab)\n\nPermission is hereby granted, free of charge,"
},
{
"path": "annotator/midas/__init__.py",
"chars": 1694,
"preview": "import cv2\nimport numpy as np\nimport torch\n\nfrom einops import rearrange\nfrom .api import MiDaSInference\nfrom modules im"
},
{
"path": "annotator/midas/api.py",
"chars": 5676,
"preview": "# based on https://github.com/isl-org/MiDaS\n\nimport cv2\nimport torch\nimport torch.nn as nn\nimport os\nfrom annotator.anno"
},
{
"path": "annotator/midas/midas/__init__.py",
"chars": 0,
"preview": ""
},
{
"path": "annotator/midas/midas/base_model.py",
"chars": 367,
"preview": "import torch\n\n\nclass BaseModel(torch.nn.Module):\n def load(self, path):\n \"\"\"Load model from file.\n\n Arg"
},
{
"path": "annotator/midas/midas/blocks.py",
"chars": 9242,
"preview": "import torch\nimport torch.nn as nn\n\nfrom .vit import (\n _make_pretrained_vitb_rn50_384,\n _make_pretrained_vitl16_3"
},
{
"path": "annotator/midas/midas/dpt_depth.py",
"chars": 3154,
"preview": "import torch\nimport torch.nn as nn\nimport torch.nn.functional as F\n\nfrom .base_model import BaseModel\nfrom .blocks impor"
},
{
"path": "annotator/midas/midas/midas_net.py",
"chars": 2709,
"preview": "\"\"\"MidashNet: Network for monocular depth estimation trained by mixing several datasets.\nThis file contains code that is"
},
{
"path": "annotator/midas/midas/midas_net_custom.py",
"chars": 5207,
"preview": "\"\"\"MidashNet: Network for monocular depth estimation trained by mixing several datasets.\nThis file contains code that is"
},
{
"path": "annotator/midas/midas/transforms.py",
"chars": 7869,
"preview": "import numpy as np\nimport cv2\nimport math\n\n\ndef apply_min_size(sample, size, image_interpolation_method=cv2.INTER_AREA):"
},
{
"path": "annotator/midas/midas/vit.py",
"chars": 14625,
"preview": "import torch\nimport torch.nn as nn\nimport timm\nimport types\nimport math\nimport torch.nn.functional as F\n\n\nclass Slice(nn"
},
{
"path": "annotator/midas/utils.py",
"chars": 4582,
"preview": "\"\"\"Utils for monoDepth.\"\"\"\nimport sys\nimport re\nimport numpy as np\nimport cv2\nimport torch\n\n\ndef read_pfm(path):\n \"\"\""
},
{
"path": "annotator/mlsd/LICENSE",
"chars": 11347,
"preview": " Apache License\n Version 2.0, January 2004\n "
},
{
"path": "annotator/mlsd/__init__.py",
"chars": 1864,
"preview": "import cv2\nimport numpy as np\nimport torch\nimport os\n\nfrom einops import rearrange\nfrom .models.mbv2_mlsd_tiny import M"
},
{
"path": "annotator/mlsd/models/mbv2_mlsd_large.py",
"chars": 9678,
"preview": "import os\nimport sys\nimport torch\nimport torch.nn as nn\nimport torch.utils.model_zoo as model_zoo\nfrom torch.nn import "
},
{
"path": "annotator/mlsd/models/mbv2_mlsd_tiny.py",
"chars": 9180,
"preview": "import os\nimport sys\nimport torch\nimport torch.nn as nn\nimport torch.utils.model_zoo as model_zoo\nfrom torch.nn import "
},
{
"path": "annotator/mlsd/utils.py",
"chars": 24145,
"preview": "'''\nmodified by lihaoweicv\npytorch version\n'''\n\n'''\nM-LSD\nCopyright 2021-present NAVER Corp.\nApache License v2.0\n'''\n\ni"
},
{
"path": "annotator/mmpkg/mmcv/__init__.py",
"chars": 352,
"preview": "# Copyright (c) OpenMMLab. All rights reserved.\n# flake8: noqa\nfrom .arraymisc import *\nfrom .fileio import *\nfrom .imag"
},
{
"path": "annotator/mmpkg/mmcv/arraymisc/__init__.py",
"chars": 133,
"preview": "# Copyright (c) OpenMMLab. All rights reserved.\nfrom .quantization import dequantize, quantize\n\n__all__ = ['quantize', '"
},
{
"path": "annotator/mmpkg/mmcv/arraymisc/quantization.py",
"chars": 1824,
"preview": "# Copyright (c) OpenMMLab. All rights reserved.\nimport numpy as np\n\n\ndef quantize(arr, min_val, max_val, levels, dtype=n"
},
{
"path": "annotator/mmpkg/mmcv/cnn/__init__.py",
"chars": 2438,
"preview": "# Copyright (c) OpenMMLab. All rights reserved.\nfrom .alexnet import AlexNet\n# yapf: disable\nfrom .bricks import (ACTIVA"
},
{
"path": "annotator/mmpkg/mmcv/cnn/alexnet.py",
"chars": 1990,
"preview": "# Copyright (c) OpenMMLab. All rights reserved.\nimport logging\n\nimport torch.nn as nn\n\n\nclass AlexNet(nn.Module):\n \"\""
},
{
"path": "annotator/mmpkg/mmcv/cnn/bricks/__init__.py",
"chars": 1732,
"preview": "# Copyright (c) OpenMMLab. All rights reserved.\nfrom .activation import build_activation_layer\nfrom .context_block impor"
},
{
"path": "annotator/mmpkg/mmcv/cnn/bricks/activation.py",
"chars": 2504,
"preview": "# Copyright (c) OpenMMLab. All rights reserved.\nimport torch\nimport torch.nn as nn\nimport torch.nn.functional as F\n\nfrom"
},
{
"path": "annotator/mmpkg/mmcv/cnn/bricks/context_block.py",
"chars": 4681,
"preview": "# Copyright (c) OpenMMLab. All rights reserved.\nimport torch\nfrom torch import nn\n\nfrom ..utils import constant_init, ka"
},
{
"path": "annotator/mmpkg/mmcv/cnn/bricks/conv.py",
"chars": 1446,
"preview": "# Copyright (c) OpenMMLab. All rights reserved.\nfrom torch import nn\n\nfrom .registry import CONV_LAYERS\n\nCONV_LAYERS.reg"
},
{
"path": "annotator/mmpkg/mmcv/cnn/bricks/conv2d_adaptive_padding.py",
"chars": 2514,
"preview": "# Copyright (c) OpenMMLab. All rights reserved.\nimport math\n\nfrom torch import nn\nfrom torch.nn import functional as F\n\n"
},
{
"path": "annotator/mmpkg/mmcv/cnn/bricks/conv_module.py",
"chars": 8756,
"preview": "# Copyright (c) OpenMMLab. All rights reserved.\nimport warnings\n\nimport torch.nn as nn\n\nfrom annotator.mmpkg.mmcv.utils "
},
{
"path": "annotator/mmpkg/mmcv/cnn/bricks/conv_ws.py",
"chars": 5417,
"preview": "# Copyright (c) OpenMMLab. All rights reserved.\nimport torch\nimport torch.nn as nn\nimport torch.nn.functional as F\n\nfrom"
},
{
"path": "annotator/mmpkg/mmcv/cnn/bricks/depthwise_separable_conv_module.py",
"chars": 4142,
"preview": "# Copyright (c) OpenMMLab. All rights reserved.\nimport torch.nn as nn\n\nfrom .conv_module import ConvModule\n\n\nclass Depth"
},
{
"path": "annotator/mmpkg/mmcv/cnn/bricks/drop.py",
"chars": 2168,
"preview": "# Copyright (c) OpenMMLab. All rights reserved.\nimport torch\nimport torch.nn as nn\n\nfrom annotator.mmpkg.mmcv import bui"
},
{
"path": "annotator/mmpkg/mmcv/cnn/bricks/generalized_attention.py",
"chars": 15999,
"preview": "# Copyright (c) OpenMMLab. All rights reserved.\nimport math\n\nimport numpy as np\nimport torch\nimport torch.nn as nn\nimpor"
},
{
"path": "annotator/mmpkg/mmcv/cnn/bricks/hsigmoid.py",
"chars": 1097,
"preview": "# Copyright (c) OpenMMLab. All rights reserved.\nimport torch.nn as nn\n\nfrom .registry import ACTIVATION_LAYERS\n\n\n@ACTIVA"
},
{
"path": "annotator/mmpkg/mmcv/cnn/bricks/hswish.py",
"chars": 651,
"preview": "# Copyright (c) OpenMMLab. All rights reserved.\nimport torch.nn as nn\n\nfrom .registry import ACTIVATION_LAYERS\n\n\n@ACTIVA"
},
{
"path": "annotator/mmpkg/mmcv/cnn/bricks/non_local.py",
"chars": 11012,
"preview": "# Copyright (c) OpenMMLab. All rights reserved.\nfrom abc import ABCMeta\n\nimport torch\nimport torch.nn as nn\n\nfrom ..util"
},
{
"path": "annotator/mmpkg/mmcv/cnn/bricks/norm.py",
"chars": 5146,
"preview": "# Copyright (c) OpenMMLab. All rights reserved.\nimport inspect\n\nimport torch.nn as nn\n\nfrom annotator.mmpkg.mmcv.utils i"
},
{
"path": "annotator/mmpkg/mmcv/cnn/bricks/padding.py",
"chars": 1127,
"preview": "# Copyright (c) OpenMMLab. All rights reserved.\nimport torch.nn as nn\n\nfrom .registry import PADDING_LAYERS\n\nPADDING_LAY"
},
{
"path": "annotator/mmpkg/mmcv/cnn/bricks/plugin.py",
"chars": 2487,
"preview": "import inspect\nimport platform\n\nfrom .registry import PLUGIN_LAYERS\n\nif platform.system() == 'Windows':\n import regex"
},
{
"path": "annotator/mmpkg/mmcv/cnn/bricks/registry.py",
"chars": 654,
"preview": "# Copyright (c) OpenMMLab. All rights reserved.\nfrom annotator.mmpkg.mmcv.utils import Registry\n\nCONV_LAYERS = Registry("
},
{
"path": "annotator/mmpkg/mmcv/cnn/bricks/scale.py",
"chars": 577,
"preview": "# Copyright (c) OpenMMLab. All rights reserved.\nimport torch\nimport torch.nn as nn\n\n\nclass Scale(nn.Module):\n \"\"\"A le"
},
{
"path": "annotator/mmpkg/mmcv/cnn/bricks/swish.py",
"chars": 485,
"preview": "# Copyright (c) OpenMMLab. All rights reserved.\nimport torch\nimport torch.nn as nn\n\nfrom .registry import ACTIVATION_LAY"
},
{
"path": "annotator/mmpkg/mmcv/cnn/bricks/transformer.py",
"chars": 24609,
"preview": "# Copyright (c) OpenMMLab. All rights reserved.\nimport copy\nimport warnings\n\nimport torch\nimport torch.nn as nn\n\nfrom an"
},
{
"path": "annotator/mmpkg/mmcv/cnn/bricks/upsample.py",
"chars": 2880,
"preview": "# Copyright (c) OpenMMLab. All rights reserved.\nimport torch.nn as nn\nimport torch.nn.functional as F\n\nfrom ..utils impo"
},
{
"path": "annotator/mmpkg/mmcv/cnn/bricks/wrappers.py",
"chars": 6961,
"preview": "# Copyright (c) OpenMMLab. All rights reserved.\nr\"\"\"Modified from https://github.com/facebookresearch/detectron2/blob/ma"
},
{
"path": "annotator/mmpkg/mmcv/cnn/builder.py",
"chars": 1089,
"preview": "# Copyright (c) OpenMMLab. All rights reserved.\nfrom ..runner import Sequential\nfrom ..utils import Registry, build_from"
},
{
"path": "annotator/mmpkg/mmcv/cnn/resnet.py",
"chars": 9955,
"preview": "# Copyright (c) OpenMMLab. All rights reserved.\nimport logging\n\nimport torch.nn as nn\nimport torch.utils.checkpoint as c"
},
{
"path": "annotator/mmpkg/mmcv/cnn/utils/__init__.py",
"chars": 1023,
"preview": "# Copyright (c) OpenMMLab. All rights reserved.\nfrom .flops_counter import get_model_complexity_info\nfrom .fuse_conv_bn "
},
{
"path": "annotator/mmpkg/mmcv/cnn/utils/flops_counter.py",
"chars": 22100,
"preview": "# Modified from flops-counter.pytorch by Vladislav Sovrasov\n# original repo: https://github.com/sovrasov/flops-counter.p"
},
{
"path": "annotator/mmpkg/mmcv/cnn/utils/fuse_conv_bn.py",
"chars": 1881,
"preview": "# Copyright (c) OpenMMLab. All rights reserved.\nimport torch\nimport torch.nn as nn\n\n\ndef _fuse_conv_bn(conv, bn):\n \"\""
},
{
"path": "annotator/mmpkg/mmcv/cnn/utils/sync_bn.py",
"chars": 2323,
"preview": "import torch\n\nimport annotator.mmpkg.mmcv as mmcv\n\n\nclass _BatchNormXd(torch.nn.modules.batchnorm._BatchNorm):\n \"\"\"A "
},
{
"path": "annotator/mmpkg/mmcv/cnn/utils/weight_init.py",
"chars": 25998,
"preview": "# Copyright (c) OpenMMLab. All rights reserved.\nimport copy\nimport math\nimport warnings\n\nimport numpy as np\nimport torch"
},
{
"path": "annotator/mmpkg/mmcv/cnn/vgg.py",
"chars": 6053,
"preview": "# Copyright (c) OpenMMLab. All rights reserved.\nimport logging\n\nimport torch.nn as nn\n\nfrom .utils import constant_init,"
},
{
"path": "annotator/mmpkg/mmcv/engine/__init__.py",
"chars": 266,
"preview": "# Copyright (c) OpenMMLab. All rights reserved.\nfrom .test import (collect_results_cpu, collect_results_gpu, multi_gpu_t"
},
{
"path": "annotator/mmpkg/mmcv/engine/test.py",
"chars": 7188,
"preview": "# Copyright (c) OpenMMLab. All rights reserved.\nimport os.path as osp\nimport pickle\nimport shutil\nimport tempfile\nimport"
},
{
"path": "annotator/mmpkg/mmcv/fileio/__init__.py",
"chars": 478,
"preview": "# Copyright (c) OpenMMLab. All rights reserved.\nfrom .file_client import BaseStorageBackend, FileClient\nfrom .handlers i"
},
{
"path": "annotator/mmpkg/mmcv/fileio/file_client.py",
"chars": 41921,
"preview": "# Copyright (c) OpenMMLab. All rights reserved.\nimport inspect\nimport os\nimport os.path as osp\nimport re\nimport tempfile"
},
{
"path": "annotator/mmpkg/mmcv/fileio/handlers/__init__.py",
"chars": 278,
"preview": "# Copyright (c) OpenMMLab. All rights reserved.\nfrom .base import BaseFileHandler\nfrom .json_handler import JsonHandler\n"
},
{
"path": "annotator/mmpkg/mmcv/fileio/handlers/base.py",
"chars": 993,
"preview": "# Copyright (c) OpenMMLab. All rights reserved.\nfrom abc import ABCMeta, abstractmethod\n\n\nclass BaseFileHandler(metaclas"
},
{
"path": "annotator/mmpkg/mmcv/fileio/handlers/json_handler.py",
"chars": 1068,
"preview": "# Copyright (c) OpenMMLab. All rights reserved.\nimport json\n\nimport numpy as np\n\nfrom .base import BaseFileHandler\n\n\ndef"
},
{
"path": "annotator/mmpkg/mmcv/fileio/handlers/pickle_handler.py",
"chars": 817,
"preview": "# Copyright (c) OpenMMLab. All rights reserved.\nimport pickle\n\nfrom .base import BaseFileHandler\n\n\nclass PickleHandler(B"
},
{
"path": "annotator/mmpkg/mmcv/fileio/handlers/yaml_handler.py",
"chars": 665,
"preview": "# Copyright (c) OpenMMLab. All rights reserved.\nimport yaml\n\ntry:\n from yaml import CLoader as Loader, CDumper as Dum"
},
{
"path": "annotator/mmpkg/mmcv/fileio/io.py",
"chars": 5520,
"preview": "# Copyright (c) OpenMMLab. All rights reserved.\nfrom io import BytesIO, StringIO\nfrom pathlib import Path\n\nfrom ..utils "
},
{
"path": "annotator/mmpkg/mmcv/fileio/parse.py",
"chars": 3458,
"preview": "# Copyright (c) OpenMMLab. All rights reserved.\n\nfrom io import StringIO\n\nfrom .file_client import FileClient\n\n\ndef list"
},
{
"path": "annotator/mmpkg/mmcv/image/__init__.py",
"chars": 1725,
"preview": "# Copyright (c) OpenMMLab. All rights reserved.\nfrom .colorspace import (bgr2gray, bgr2hls, bgr2hsv, bgr2rgb, bgr2ycbcr,"
},
{
"path": "annotator/mmpkg/mmcv/image/colorspace.py",
"chars": 9907,
"preview": "# Copyright (c) OpenMMLab. All rights reserved.\nimport cv2\nimport numpy as np\n\n\ndef imconvert(img, src, dst):\n \"\"\"Con"
},
{
"path": "annotator/mmpkg/mmcv/image/geometric.py",
"chars": 25196,
"preview": "# Copyright (c) OpenMMLab. All rights reserved.\nimport numbers\n\nimport cv2\nimport numpy as np\n\nfrom ..utils import to_2t"
},
{
"path": "annotator/mmpkg/mmcv/image/io.py",
"chars": 9568,
"preview": "# Copyright (c) OpenMMLab. All rights reserved.\nimport io\nimport os.path as osp\nfrom pathlib import Path\n\nimport cv2\nimp"
},
{
"path": "annotator/mmpkg/mmcv/image/misc.py",
"chars": 1406,
"preview": "# Copyright (c) OpenMMLab. All rights reserved.\nimport numpy as np\n\nimport annotator.mmpkg.mmcv as mmcv\n\ntry:\n import"
},
{
"path": "annotator/mmpkg/mmcv/image/photometric.py",
"chars": 14999,
"preview": "# Copyright (c) OpenMMLab. All rights reserved.\nimport cv2\nimport numpy as np\n\nfrom ..utils import is_tuple_of\nfrom .col"
},
{
"path": "annotator/mmpkg/mmcv/model_zoo/deprecated.json",
"chars": 217,
"preview": "{\n \"resnet50_caffe\": \"detectron/resnet50_caffe\",\n \"resnet50_caffe_bgr\": \"detectron2/resnet50_caffe_bgr\",\n \"resnet101_"
},
{
"path": "annotator/mmpkg/mmcv/model_zoo/mmcls.json",
"chars": 3690,
"preview": "{\n \"vgg11\": \"https://download.openmmlab.com/mmclassification/v0/vgg/vgg11_batch256_imagenet_20210208-4271cd6c.pth\",\n \""
},
{
"path": "annotator/mmpkg/mmcv/model_zoo/open_mmlab.json",
"chars": 5181,
"preview": "{\n \"vgg16_caffe\": \"https://download.openmmlab.com/pretrain/third_party/vgg16_caffe-292e1171.pth\",\n \"detectron/resnet50"
},
{
"path": "annotator/mmpkg/mmcv/ops/__init__.py",
"chars": 4506,
"preview": "# Copyright (c) OpenMMLab. All rights reserved.\nfrom .assign_score_withk import assign_score_withk\nfrom .ball_query impo"
},
{
"path": "annotator/mmpkg/mmcv/ops/assign_score_withk.py",
"chars": 4344,
"preview": "from torch.autograd import Function\n\nfrom ..utils import ext_loader\n\next_module = ext_loader.load_ext(\n '_ext', ['ass"
},
{
"path": "annotator/mmpkg/mmcv/ops/ball_query.py",
"chars": 1695,
"preview": "# Copyright (c) OpenMMLab. All rights reserved.\nimport torch\nfrom torch.autograd import Function\n\nfrom ..utils import ex"
},
{
"path": "annotator/mmpkg/mmcv/ops/bbox.py",
"chars": 2508,
"preview": "# Copyright (c) OpenMMLab. All rights reserved.\nfrom ..utils import ext_loader\n\next_module = ext_loader.load_ext('_ext',"
},
{
"path": "annotator/mmpkg/mmcv/ops/border_align.py",
"chars": 3725,
"preview": "# Copyright (c) OpenMMLab. All rights reserved.\n# modified from\n# https://github.com/Megvii-BaseDetection/cvpods/blob/ma"
},
{
"path": "annotator/mmpkg/mmcv/ops/box_iou_rotated.py",
"chars": 1609,
"preview": "# Copyright (c) OpenMMLab. All rights reserved.\nfrom ..utils import ext_loader\n\next_module = ext_loader.load_ext('_ext',"
},
{
"path": "annotator/mmpkg/mmcv/ops/carafe.py",
"chars": 9873,
"preview": "# Copyright (c) OpenMMLab. All rights reserved.\nimport torch\nimport torch.nn as nn\nimport torch.nn.functional as F\nfrom "
},
{
"path": "annotator/mmpkg/mmcv/ops/cc_attention.py",
"chars": 3037,
"preview": "# Copyright (c) OpenMMLab. All rights reserved.\nimport torch\nimport torch.nn as nn\nimport torch.nn.functional as F\n\nfrom"
},
{
"path": "annotator/mmpkg/mmcv/ops/contour_expand.py",
"chars": 1795,
"preview": "# Copyright (c) OpenMMLab. All rights reserved.\nimport numpy as np\nimport torch\n\nfrom ..utils import ext_loader\n\next_mod"
},
{
"path": "annotator/mmpkg/mmcv/ops/corner_pool.py",
"chars": 4697,
"preview": "# Copyright (c) OpenMMLab. All rights reserved.\nimport torch\nfrom torch import nn\nfrom torch.autograd import Function\n\nf"
},
{
"path": "annotator/mmpkg/mmcv/ops/correlation.py",
"chars": 6697,
"preview": "# Copyright (c) OpenMMLab. All rights reserved.\nimport torch\nfrom torch import Tensor, nn\nfrom torch.autograd import Fun"
},
{
"path": "annotator/mmpkg/mmcv/ops/deform_conv.py",
"chars": 15599,
"preview": "# Copyright (c) OpenMMLab. All rights reserved.\nfrom typing import Tuple, Union\n\nimport torch\nimport torch.nn as nn\nimpo"
},
{
"path": "annotator/mmpkg/mmcv/ops/deform_roi_pool.py",
"chars": 7410,
"preview": "# Copyright (c) OpenMMLab. All rights reserved.\nfrom torch import nn\nfrom torch.autograd import Function\nfrom torch.auto"
},
{
"path": "annotator/mmpkg/mmcv/ops/deprecated_wrappers.py",
"chars": 1467,
"preview": "# Copyright (c) OpenMMLab. All rights reserved.\n# This file is for backward compatibility.\n# Module wrappers for empty t"
},
{
"path": "annotator/mmpkg/mmcv/ops/focal_loss.py",
"chars": 6582,
"preview": "# Copyright (c) OpenMMLab. All rights reserved.\nimport torch\nimport torch.nn as nn\nfrom torch.autograd import Function\nf"
},
{
"path": "annotator/mmpkg/mmcv/ops/furthest_point_sample.py",
"chars": 2550,
"preview": "import torch\nfrom torch.autograd import Function\n\nfrom ..utils import ext_loader\n\next_module = ext_loader.load_ext('_ext"
},
{
"path": "annotator/mmpkg/mmcv/ops/fused_bias_leakyrelu.py",
"chars": 10027,
"preview": "# modified from https://github.com/rosinality/stylegan2-pytorch/blob/master/op/fused_act.py # noqa:E501\n\n# Copyright (c)"
},
{
"path": "annotator/mmpkg/mmcv/ops/gather_points.py",
"chars": 1607,
"preview": "import torch\nfrom torch.autograd import Function\n\nfrom ..utils import ext_loader\n\next_module = ext_loader.load_ext(\n "
},
{
"path": "annotator/mmpkg/mmcv/ops/group_points.py",
"chars": 8135,
"preview": "# Copyright (c) OpenMMLab. All rights reserved.\nfrom typing import Tuple\n\nimport torch\nfrom torch import nn as nn\nfrom t"
},
{
"path": "annotator/mmpkg/mmcv/ops/info.py",
"chars": 887,
"preview": "# Copyright (c) OpenMMLab. All rights reserved.\nimport glob\nimport os\n\nimport torch\n\nif torch.__version__ == 'parrots':\n"
},
{
"path": "annotator/mmpkg/mmcv/ops/iou3d.py",
"chars": 2988,
"preview": "# Copyright (c) OpenMMLab. All rights reserved.\nimport torch\n\nfrom ..utils import ext_loader\n\next_module = ext_loader.lo"
},
{
"path": "annotator/mmpkg/mmcv/ops/knn.py",
"chars": 2599,
"preview": "import torch\nfrom torch.autograd import Function\n\nfrom ..utils import ext_loader\n\next_module = ext_loader.load_ext('_ext"
},
{
"path": "annotator/mmpkg/mmcv/ops/masked_conv.py",
"chars": 3761,
"preview": "# Copyright (c) OpenMMLab. All rights reserved.\nimport math\n\nimport torch\nimport torch.nn as nn\nfrom torch.autograd impo"
},
{
"path": "annotator/mmpkg/mmcv/ops/merge_cells.py",
"chars": 5403,
"preview": "# Copyright (c) OpenMMLab. All rights reserved.\nfrom abc import abstractmethod\n\nimport torch\nimport torch.nn as nn\nimpor"
},
{
"path": "annotator/mmpkg/mmcv/ops/modulated_deform_conv.py",
"chars": 10570,
"preview": "# Copyright (c) OpenMMLab. All rights reserved.\nimport math\n\nimport torch\nimport torch.nn as nn\nfrom torch.autograd impo"
},
{
"path": "annotator/mmpkg/mmcv/ops/multi_scale_deform_attn.py",
"chars": 15159,
"preview": "# Copyright (c) OpenMMLab. All rights reserved.\nimport math\nimport warnings\n\nimport torch\nimport torch.nn as nn\nimport t"
},
{
"path": "annotator/mmpkg/mmcv/ops/nms.py",
"chars": 16233,
"preview": "import os\n\nimport numpy as np\nimport torch\n\nfrom annotator.mmpkg.mmcv.utils import deprecated_api_warning\nfrom ..utils i"
},
{
"path": "annotator/mmpkg/mmcv/ops/pixel_group.py",
"chars": 3113,
"preview": "# Copyright (c) OpenMMLab. All rights reserved.\nimport numpy as np\nimport torch\n\nfrom ..utils import ext_loader\n\next_mod"
},
{
"path": "annotator/mmpkg/mmcv/ops/point_sample.py",
"chars": 12283,
"preview": "# Modified from https://github.com/facebookresearch/detectron2/tree/master/projects/PointRend # noqa\n\nfrom os import pa"
},
{
"path": "annotator/mmpkg/mmcv/ops/points_in_boxes.py",
"chars": 5241,
"preview": "import torch\n\nfrom ..utils import ext_loader\n\next_module = ext_loader.load_ext('_ext', [\n 'points_in_boxes_part_forwa"
},
{
"path": "annotator/mmpkg/mmcv/ops/points_sampler.py",
"chars": 6059,
"preview": "from typing import List\n\nimport torch\nfrom torch import nn as nn\n\nfrom annotator.mmpkg.mmcv.runner import force_fp32\nfro"
},
{
"path": "annotator/mmpkg/mmcv/ops/psa_mask.py",
"chars": 2773,
"preview": "# Modified from https://github.com/hszhao/semseg/blob/master/lib/psa\nfrom torch import nn\nfrom torch.autograd import Fun"
},
{
"path": "annotator/mmpkg/mmcv/ops/roi_align.py",
"chars": 8519,
"preview": "# Copyright (c) OpenMMLab. All rights reserved.\nimport torch\nimport torch.nn as nn\nfrom torch.autograd import Function\nf"
},
{
"path": "annotator/mmpkg/mmcv/ops/roi_align_rotated.py",
"chars": 6434,
"preview": "# Copyright (c) OpenMMLab. All rights reserved.\nimport torch.nn as nn\nfrom torch.autograd import Function\n\nfrom ..utils "
},
{
"path": "annotator/mmpkg/mmcv/ops/roi_pool.py",
"chars": 2517,
"preview": "# Copyright (c) OpenMMLab. All rights reserved.\nimport torch\nimport torch.nn as nn\nfrom torch.autograd import Function\nf"
},
{
"path": "annotator/mmpkg/mmcv/ops/roiaware_pool3d.py",
"chars": 4252,
"preview": "# Copyright (c) OpenMMLab. All rights reserved.\nimport torch\nfrom torch import nn as nn\nfrom torch.autograd import Funct"
},
{
"path": "annotator/mmpkg/mmcv/ops/roipoint_pool3d.py",
"chars": 2990,
"preview": "from torch import nn as nn\nfrom torch.autograd import Function\n\nfrom ..utils import ext_loader\n\next_module = ext_loader."
},
{
"path": "annotator/mmpkg/mmcv/ops/saconv.py",
"chars": 5792,
"preview": "# Copyright (c) OpenMMLab. All rights reserved.\nimport torch\nimport torch.nn as nn\nimport torch.nn.functional as F\n\nfrom"
},
{
"path": "annotator/mmpkg/mmcv/ops/scatter_points.py",
"chars": 5201,
"preview": "# Copyright (c) OpenMMLab. All rights reserved.\nimport torch\nfrom torch import nn\nfrom torch.autograd import Function\n\nf"
},
{
"path": "annotator/mmpkg/mmcv/ops/sync_bn.py",
"chars": 11263,
"preview": "# Copyright (c) OpenMMLab. All rights reserved.\nimport torch\nimport torch.distributed as dist\nimport torch.nn.functional"
}
]
// ... and 732 more files (download for full content)
About this extraction
This page contains the full source code of the Mikubill/sd-webui-controlnet GitHub repository, extracted and formatted as plain text for AI agents and large language models (LLMs). The extraction includes 932 files (6.2 MB), approximately 1.7M tokens, and a symbol index with 6571 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.