├── .gitignore ├── LICENSE.txt ├── README.md ├── TikTok-v4 └── put the dataset here.txt ├── dataset ├── __init__.py ├── hdfs_io.py ├── kv_dataset.py ├── mask.py ├── safty.py ├── tiktok_video_arnold_copy.py ├── tiktok_video_mm.py └── transforms.py ├── environment.yml ├── example_data ├── image │ ├── human │ │ ├── 0001.png │ │ └── 0125.png │ └── out-of-domain │ │ ├── 001.png │ │ └── 181020.png └── pose_sequence │ ├── 001 │ ├── 0001.png │ ├── 0002.png │ ├── 0003.png │ ├── 0004.png │ ├── 0005.png │ ├── 0006.png │ ├── 0007.png │ ├── 0008.png │ ├── 0009.png │ ├── 0010.png │ ├── 0011.png │ ├── 0012.png │ ├── 0013.png │ ├── 0014.png │ ├── 0015.png │ ├── 0016.png │ ├── 0017.png │ ├── 0018.png │ ├── 0019.png │ ├── 0020.png │ ├── 0021.png │ ├── 0022.png │ ├── 0023.png │ ├── 0024.png │ └── 0025.png │ ├── 002 │ ├── 0001.png │ ├── 0006.png │ ├── 0011.png │ ├── 0016.png │ ├── 0021.png │ ├── 0026.png │ ├── 0031.png │ ├── 0036.png │ ├── 0041.png │ ├── 0046.png │ ├── 0051.png │ ├── 0056.png │ ├── 0061.png │ ├── 0066.png │ ├── 0071.png │ ├── 0076.png │ ├── 0081.png │ ├── 0086.png │ ├── 0091.png │ ├── 0096.png │ ├── 0101.png │ ├── 0106.png │ ├── 0111.png │ ├── 0116.png │ ├── 0121.png │ ├── 0126.png │ ├── 0131.png │ ├── 0136.png │ ├── 0141.png │ ├── 0146.png │ ├── 0151.png │ ├── 0156.png │ ├── 0161.png │ ├── 0166.png │ ├── 0171.png │ ├── 0176.png │ ├── 0181.png │ ├── 0186.png │ ├── 0191.png │ └── 0196.png │ └── 003 │ ├── 0001.png │ ├── 0006.png │ ├── 0011.png │ ├── 0016.png │ ├── 0021.png │ ├── 0026.png │ ├── 0031.png │ ├── 0036.png │ ├── 0041.png │ ├── 0046.png │ ├── 0051.png │ ├── 0057.png │ ├── 0062.png │ ├── 0067.png │ ├── 0072.png │ ├── 0077.png │ ├── 0082.png │ ├── 0087.png │ ├── 0092.png │ ├── 0097.png │ ├── 0102.png │ ├── 0107.png │ ├── 0112.png │ ├── 0117.png │ ├── 0122.png │ ├── 0127.png │ ├── 0132.png │ ├── 0137.png │ ├── 0142.png │ ├── 0147.png │ ├── 0152.png │ ├── 0157.png │ ├── 0162.png │ ├── 0167.png │ ├── 0172.png │ ├── 0177.png │ ├── 0182.png │ ├── 0187.png │ ├── 0192.png │ └── 0197.png ├── figures ├── 1.gif ├── 2.gif ├── Comparison_Animate_Anyone.gif ├── magicanimate_1.png ├── magicanimate_2.png ├── teaser.jpg ├── tiktok.png ├── video_play.png ├── zeroshot_1.png └── zeroshot_2.png ├── misc_scripts ├── detect_openpose_map_tiktok.py └── keypoint │ ├── __init__.py │ ├── face_keypoint.py │ └── idls │ ├── base.thrift │ ├── common.thrift │ └── faceattr.thrift ├── model_lib └── ControlNet │ ├── annotator │ ├── canny │ │ └── __init__.py │ ├── ckpts │ │ ├── blip2-opt-2.7b │ │ │ ├── config.json │ │ │ ├── merges.txt │ │ │ ├── preprocessor_config.json │ │ │ ├── special_tokens_map.json │ │ │ ├── tokenizer.json │ │ │ ├── tokenizer_config.json │ │ │ └── vocab.json │ │ └── ckpts.txt │ ├── hed │ │ └── __init__.py │ ├── midas │ │ ├── __init__.py │ │ ├── api.py │ │ ├── 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 │ │ └── utils.py │ ├── mlsd │ │ ├── __init__.py │ │ ├── models │ │ │ ├── mbv2_mlsd_large.py │ │ │ └── mbv2_mlsd_tiny.py │ │ └── utils.py │ ├── openpose │ │ ├── LICENSE │ │ ├── __init__.py │ │ ├── body.py │ │ ├── face.py │ │ ├── hand.py │ │ ├── model.py │ │ └── util.py │ ├── openpose_old │ │ ├── __init__.py │ │ ├── body.py │ │ ├── hand.py │ │ ├── model.py │ │ └── util.py │ ├── uniformer │ │ ├── __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 │ │ ├── exp │ │ │ └── upernet_global_small │ │ │ │ ├── config.py │ │ │ │ ├── run.sh │ │ │ │ ├── test.sh │ │ │ │ ├── test_config_g.py │ │ │ │ ├── test_config_h32.py │ │ │ │ └── test_config_w32.py │ │ ├── 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 │ │ ├── mmcv_custom │ │ │ ├── __init__.py │ │ │ └── checkpoint.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 │ │ │ │ ├── uniformer.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 │ ├── util.py │ └── zoe │ │ ├── LICENSE │ │ ├── __init__.py │ │ └── zoedepth │ │ ├── data │ │ ├── __init__.py │ │ ├── data_mono.py │ │ ├── ddad.py │ │ ├── diml_indoor_test.py │ │ ├── diml_outdoor_test.py │ │ ├── diode.py │ │ ├── hypersim.py │ │ ├── ibims.py │ │ ├── preprocess.py │ │ ├── sun_rgbd_loader.py │ │ ├── transforms.py │ │ ├── vkitti.py │ │ └── vkitti2.py │ │ ├── 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 │ │ │ │ ├── mobile │ │ │ │ ├── README.md │ │ │ │ ├── android │ │ │ │ │ ├── .gitignore │ │ │ │ │ ├── EXPLORE_THE_CODE.md │ │ │ │ │ ├── LICENSE │ │ │ │ │ ├── README.md │ │ │ │ │ ├── app │ │ │ │ │ │ ├── .gitignore │ │ │ │ │ │ ├── build.gradle │ │ │ │ │ │ ├── proguard-rules.pro │ │ │ │ │ │ └── src │ │ │ │ │ │ │ ├── androidTest │ │ │ │ │ │ │ └── java │ │ │ │ │ │ │ │ ├── AndroidManifest.xml │ │ │ │ │ │ │ │ └── org │ │ │ │ │ │ │ │ └── tensorflow │ │ │ │ │ │ │ │ └── lite │ │ │ │ │ │ │ │ └── examples │ │ │ │ │ │ │ │ └── classification │ │ │ │ │ │ │ │ └── ClassifierTest.java │ │ │ │ │ │ │ └── main │ │ │ │ │ │ │ ├── AndroidManifest.xml │ │ │ │ │ │ │ ├── java │ │ │ │ │ │ │ └── org │ │ │ │ │ │ │ │ └── tensorflow │ │ │ │ │ │ │ │ └── lite │ │ │ │ │ │ │ │ └── examples │ │ │ │ │ │ │ │ └── classification │ │ │ │ │ │ │ │ ├── CameraActivity.java │ │ │ │ │ │ │ │ ├── CameraConnectionFragment.java │ │ │ │ │ │ │ │ ├── ClassifierActivity.java │ │ │ │ │ │ │ │ ├── LegacyCameraConnectionFragment.java │ │ │ │ │ │ │ │ └── customview │ │ │ │ │ │ │ │ ├── AutoFitTextureView.java │ │ │ │ │ │ │ │ ├── OverlayView.java │ │ │ │ │ │ │ │ ├── RecognitionScoreView.java │ │ │ │ │ │ │ │ └── ResultsView.java │ │ │ │ │ │ │ └── res │ │ │ │ │ │ │ ├── drawable-v24 │ │ │ │ │ │ │ └── ic_launcher_foreground.xml │ │ │ │ │ │ │ ├── drawable │ │ │ │ │ │ │ ├── bottom_sheet_bg.xml │ │ │ │ │ │ │ ├── ic_baseline_add.xml │ │ │ │ │ │ │ ├── ic_baseline_remove.xml │ │ │ │ │ │ │ ├── ic_launcher_background.xml │ │ │ │ │ │ │ └── rectangle.xml │ │ │ │ │ │ │ ├── layout │ │ │ │ │ │ │ ├── tfe_ic_activity_camera.xml │ │ │ │ │ │ │ ├── tfe_ic_camera_connection_fragment.xml │ │ │ │ │ │ │ └── tfe_ic_layout_bottom_sheet.xml │ │ │ │ │ │ │ ├── mipmap-anydpi-v26 │ │ │ │ │ │ │ ├── ic_launcher.xml │ │ │ │ │ │ │ └── ic_launcher_round.xml │ │ │ │ │ │ │ └── values │ │ │ │ │ │ │ ├── colors.xml │ │ │ │ │ │ │ ├── dimens.xml │ │ │ │ │ │ │ ├── strings.xml │ │ │ │ │ │ │ └── styles.xml │ │ │ │ │ ├── build.gradle │ │ │ │ │ ├── gradle.properties │ │ │ │ │ ├── gradle │ │ │ │ │ │ └── wrapper │ │ │ │ │ │ │ ├── gradle-wrapper.jar │ │ │ │ │ │ │ └── gradle-wrapper.properties │ │ │ │ │ ├── gradlew │ │ │ │ │ ├── gradlew.bat │ │ │ │ │ ├── lib_support │ │ │ │ │ │ ├── build.gradle │ │ │ │ │ │ ├── proguard-rules.pro │ │ │ │ │ │ └── src │ │ │ │ │ │ │ └── main │ │ │ │ │ │ │ ├── AndroidManifest.xml │ │ │ │ │ │ │ └── java │ │ │ │ │ │ │ └── org │ │ │ │ │ │ │ └── tensorflow │ │ │ │ │ │ │ └── lite │ │ │ │ │ │ │ └── examples │ │ │ │ │ │ │ └── classification │ │ │ │ │ │ │ └── tflite │ │ │ │ │ │ │ ├── Classifier.java │ │ │ │ │ │ │ ├── ClassifierFloatEfficientNet.java │ │ │ │ │ │ │ ├── ClassifierFloatMobileNet.java │ │ │ │ │ │ │ ├── ClassifierQuantizedEfficientNet.java │ │ │ │ │ │ │ └── ClassifierQuantizedMobileNet.java │ │ │ │ │ ├── lib_task_api │ │ │ │ │ │ ├── build.gradle │ │ │ │ │ │ ├── proguard-rules.pro │ │ │ │ │ │ └── src │ │ │ │ │ │ │ └── main │ │ │ │ │ │ │ ├── AndroidManifest.xml │ │ │ │ │ │ │ └── java │ │ │ │ │ │ │ └── org │ │ │ │ │ │ │ └── tensorflow │ │ │ │ │ │ │ └── lite │ │ │ │ │ │ │ └── examples │ │ │ │ │ │ │ └── classification │ │ │ │ │ │ │ └── tflite │ │ │ │ │ │ │ ├── Classifier.java │ │ │ │ │ │ │ ├── ClassifierFloatEfficientNet.java │ │ │ │ │ │ │ ├── ClassifierFloatMobileNet.java │ │ │ │ │ │ │ ├── ClassifierQuantizedEfficientNet.java │ │ │ │ │ │ │ └── ClassifierQuantizedMobileNet.java │ │ │ │ │ ├── models │ │ │ │ │ │ ├── build.gradle │ │ │ │ │ │ ├── download.gradle │ │ │ │ │ │ ├── proguard-rules.pro │ │ │ │ │ │ └── src │ │ │ │ │ │ │ └── main │ │ │ │ │ │ │ └── AndroidManifest.xml │ │ │ │ │ └── settings.gradle │ │ │ │ └── ios │ │ │ │ │ ├── .gitignore │ │ │ │ │ ├── LICENSE │ │ │ │ │ ├── Midas.xcodeproj │ │ │ │ │ ├── project.pbxproj │ │ │ │ │ ├── project.xcworkspace │ │ │ │ │ │ ├── contents.xcworkspacedata │ │ │ │ │ │ ├── xcshareddata │ │ │ │ │ │ │ └── IDEWorkspaceChecks.plist │ │ │ │ │ │ └── xcuserdata │ │ │ │ │ │ │ └── admin.xcuserdatad │ │ │ │ │ │ │ └── UserInterfaceState.xcuserstate │ │ │ │ │ └── xcuserdata │ │ │ │ │ │ └── admin.xcuserdatad │ │ │ │ │ │ └── xcschemes │ │ │ │ │ │ └── xcschememanagement.plist │ │ │ │ │ ├── Midas │ │ │ │ │ ├── AppDelegate.swift │ │ │ │ │ ├── Assets.xcassets │ │ │ │ │ │ ├── AppIcon.appiconset │ │ │ │ │ │ │ └── Contents.json │ │ │ │ │ │ └── Contents.json │ │ │ │ │ ├── Camera Feed │ │ │ │ │ │ ├── CameraFeedManager.swift │ │ │ │ │ │ └── PreviewView.swift │ │ │ │ │ ├── Cells │ │ │ │ │ │ └── InfoCell.swift │ │ │ │ │ ├── Constants.swift │ │ │ │ │ ├── Extensions │ │ │ │ │ │ ├── CGSizeExtension.swift │ │ │ │ │ │ ├── CVPixelBufferExtension.swift │ │ │ │ │ │ └── TFLiteExtension.swift │ │ │ │ │ ├── Info.plist │ │ │ │ │ ├── ModelDataHandler │ │ │ │ │ │ └── ModelDataHandler.swift │ │ │ │ │ ├── Storyboards │ │ │ │ │ │ └── Base.lproj │ │ │ │ │ │ │ ├── Launch Screen.storyboard │ │ │ │ │ │ │ └── Main.storyboard │ │ │ │ │ ├── ViewControllers │ │ │ │ │ │ └── ViewController.swift │ │ │ │ │ └── Views │ │ │ │ │ │ └── OverlayView.swift │ │ │ │ │ ├── Podfile │ │ │ │ │ ├── README.md │ │ │ │ │ └── RunScripts │ │ │ │ │ └── download_models.sh │ │ │ │ ├── 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 │ │ ├── trainers │ │ ├── base_trainer.py │ │ ├── builder.py │ │ ├── loss.py │ │ ├── zoedepth_nk_trainer.py │ │ └── zoedepth_trainer.py │ │ └── utils │ │ ├── __init__.py │ │ ├── arg_utils.py │ │ ├── config.py │ │ ├── easydict │ │ └── __init__.py │ │ ├── geometry.py │ │ └── misc.py │ ├── cldm │ ├── cldm.py │ ├── hack.py │ ├── logger.py │ └── model.py │ ├── ldm │ ├── data │ │ ├── __init__.py │ │ └── util.py │ ├── models │ │ ├── autoencoder.py │ │ └── diffusion │ │ │ ├── __init__.py │ │ │ ├── ddim.py │ │ │ ├── ddpm.py │ │ │ ├── dpm_solver │ │ │ ├── __init__.py │ │ │ ├── dpm_solver.py │ │ │ └── sampler.py │ │ │ ├── overlap_sampling.py │ │ │ ├── plms.py │ │ │ └── sampling_util.py │ ├── modules │ │ ├── attention.py │ │ ├── diffusionmodules │ │ │ ├── __init__.py │ │ │ ├── model.py │ │ │ ├── openaimodel.py │ │ │ ├── upscaling.py │ │ │ └── util.py │ │ ├── distributions │ │ │ ├── __init__.py │ │ │ └── distributions.py │ │ ├── ema.py │ │ ├── encoders │ │ │ ├── __init__.py │ │ │ └── modules.py │ │ ├── image_degradation │ │ │ ├── __init__.py │ │ │ ├── bsrgan.py │ │ │ ├── bsrgan_light.py │ │ │ └── utils_image.py │ │ ├── midas │ │ │ ├── __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 │ │ └── motion_module.py │ └── util.py │ └── models │ ├── cldm_v15.yaml │ ├── cldm_v15_reference_only.yaml │ └── cldm_v15_reference_only_pose.yaml ├── pretrained_weights └── put your model ckpts here.txt ├── scripts ├── appearance_control_pretraining.sh ├── appearance_disentangle_pose_control.sh ├── inference_any_image_pose.sh └── inference_tiktok_dataset.sh ├── test_any_image_pose.py ├── test_tiktok.py ├── tool ├── ClipScore.py ├── cleanfid │ ├── __init__.py │ ├── downloads_helper.py │ ├── features.py │ ├── fid.py │ ├── inception_pytorch.py │ ├── inception_torchscript.py │ ├── leaderboard.py │ ├── resize.py │ └── utils.py ├── inception_score.py ├── metrics │ ├── __init__.py │ ├── downloads_helper.py │ ├── features.py │ ├── fid.py │ ├── inception3d.py │ ├── inception_pytorch.py │ ├── inception_torchscript.py │ ├── leaderboard.py │ ├── metric_center.py │ ├── readme.md │ ├── resize.py │ ├── resnet3d.py │ ├── ssim_l1_lpips_psnr.py │ └── utils.py ├── test_SD2 └── video │ ├── gen_gifs_for_fvd.py │ ├── gen_vid.py │ ├── gen_vid_command.py │ ├── gen_vid_folder.py │ ├── reencode_vid_folder_forvis.py │ └── runsh │ ├── process_video.sh │ └── process_video_demo.sh ├── train_tiktok.py └── utils ├── __init__.py ├── checkpoint.py ├── io_utils.py ├── lr_scheduler.py ├── time_utils.py ├── txt_utils.py └── utils.py /TikTok-v4/put the dataset here.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Boese0601/MagicDance/a515a1f4a5fceb9abb3d2cabbc48958ba249e560/TikTok-v4/put the dataset here.txt -------------------------------------------------------------------------------- /dataset/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Boese0601/MagicDance/a515a1f4a5fceb9abb3d2cabbc48958ba249e560/dataset/__init__.py -------------------------------------------------------------------------------- /dataset/transforms.py: -------------------------------------------------------------------------------- 1 | from PIL import Image, ImageChops 2 | import numpy as np 3 | 4 | 5 | class RemoveWhite(object): 6 | def trim(self, im): 7 | bg = Image.new(im.mode, im.size, im.getpixel((0,0))) 8 | diff = ImageChops.difference(im, bg) 9 | diff = ImageChops.add(diff, diff, 2.0, -100) 10 | bbox = diff.getbbox() 11 | if bbox: 12 | return im.crop(bbox) 13 | return im 14 | 15 | def __call__(self, pil_image): 16 | out_image = self.trim(pil_image) 17 | if out_image.size[0] < 0.5*out_image.size[0] or out_image.size[1] < 0.5*out_image.size[1]: 18 | return pil_image 19 | return out_image 20 | 21 | 22 | 23 | class CenterCrop(object): 24 | def __call__(self, pil_image): 25 | # input is a pil image 26 | 27 | width, height = pil_image.size 28 | 29 | if width>height and width/height < 1.3: 30 | return pil_image 31 | elif height>=width and height/width < 1.3: 32 | return pil_image 33 | 34 | new_width = new_height = min(width, height) 35 | 36 | left = int(np.ceil((width - new_width) / 2)) 37 | right = width - int(np.floor((width - new_width) / 2)) 38 | 39 | top = int(np.ceil((height - new_height) / 2)) 40 | bottom = height - int(np.floor((height - new_height) / 2)) 41 | 42 | center_cropped_img = pil_image.crop((left, top, right, bottom)) 43 | 44 | return center_cropped_img -------------------------------------------------------------------------------- /example_data/image/human/0001.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Boese0601/MagicDance/a515a1f4a5fceb9abb3d2cabbc48958ba249e560/example_data/image/human/0001.png -------------------------------------------------------------------------------- /example_data/image/human/0125.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Boese0601/MagicDance/a515a1f4a5fceb9abb3d2cabbc48958ba249e560/example_data/image/human/0125.png -------------------------------------------------------------------------------- /example_data/image/out-of-domain/001.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Boese0601/MagicDance/a515a1f4a5fceb9abb3d2cabbc48958ba249e560/example_data/image/out-of-domain/001.png -------------------------------------------------------------------------------- /example_data/image/out-of-domain/181020.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Boese0601/MagicDance/a515a1f4a5fceb9abb3d2cabbc48958ba249e560/example_data/image/out-of-domain/181020.png -------------------------------------------------------------------------------- /example_data/pose_sequence/001/0001.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Boese0601/MagicDance/a515a1f4a5fceb9abb3d2cabbc48958ba249e560/example_data/pose_sequence/001/0001.png -------------------------------------------------------------------------------- /example_data/pose_sequence/001/0002.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Boese0601/MagicDance/a515a1f4a5fceb9abb3d2cabbc48958ba249e560/example_data/pose_sequence/001/0002.png -------------------------------------------------------------------------------- /example_data/pose_sequence/001/0003.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Boese0601/MagicDance/a515a1f4a5fceb9abb3d2cabbc48958ba249e560/example_data/pose_sequence/001/0003.png -------------------------------------------------------------------------------- /example_data/pose_sequence/001/0004.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Boese0601/MagicDance/a515a1f4a5fceb9abb3d2cabbc48958ba249e560/example_data/pose_sequence/001/0004.png -------------------------------------------------------------------------------- /example_data/pose_sequence/001/0005.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Boese0601/MagicDance/a515a1f4a5fceb9abb3d2cabbc48958ba249e560/example_data/pose_sequence/001/0005.png -------------------------------------------------------------------------------- /example_data/pose_sequence/001/0006.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Boese0601/MagicDance/a515a1f4a5fceb9abb3d2cabbc48958ba249e560/example_data/pose_sequence/001/0006.png -------------------------------------------------------------------------------- /example_data/pose_sequence/001/0007.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Boese0601/MagicDance/a515a1f4a5fceb9abb3d2cabbc48958ba249e560/example_data/pose_sequence/001/0007.png -------------------------------------------------------------------------------- /example_data/pose_sequence/001/0008.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Boese0601/MagicDance/a515a1f4a5fceb9abb3d2cabbc48958ba249e560/example_data/pose_sequence/001/0008.png -------------------------------------------------------------------------------- /example_data/pose_sequence/001/0009.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Boese0601/MagicDance/a515a1f4a5fceb9abb3d2cabbc48958ba249e560/example_data/pose_sequence/001/0009.png -------------------------------------------------------------------------------- /example_data/pose_sequence/001/0010.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Boese0601/MagicDance/a515a1f4a5fceb9abb3d2cabbc48958ba249e560/example_data/pose_sequence/001/0010.png -------------------------------------------------------------------------------- /example_data/pose_sequence/001/0011.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Boese0601/MagicDance/a515a1f4a5fceb9abb3d2cabbc48958ba249e560/example_data/pose_sequence/001/0011.png -------------------------------------------------------------------------------- /example_data/pose_sequence/001/0012.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Boese0601/MagicDance/a515a1f4a5fceb9abb3d2cabbc48958ba249e560/example_data/pose_sequence/001/0012.png -------------------------------------------------------------------------------- /example_data/pose_sequence/001/0013.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Boese0601/MagicDance/a515a1f4a5fceb9abb3d2cabbc48958ba249e560/example_data/pose_sequence/001/0013.png -------------------------------------------------------------------------------- /example_data/pose_sequence/001/0014.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Boese0601/MagicDance/a515a1f4a5fceb9abb3d2cabbc48958ba249e560/example_data/pose_sequence/001/0014.png -------------------------------------------------------------------------------- /example_data/pose_sequence/001/0015.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Boese0601/MagicDance/a515a1f4a5fceb9abb3d2cabbc48958ba249e560/example_data/pose_sequence/001/0015.png -------------------------------------------------------------------------------- /example_data/pose_sequence/001/0016.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Boese0601/MagicDance/a515a1f4a5fceb9abb3d2cabbc48958ba249e560/example_data/pose_sequence/001/0016.png -------------------------------------------------------------------------------- /example_data/pose_sequence/001/0017.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Boese0601/MagicDance/a515a1f4a5fceb9abb3d2cabbc48958ba249e560/example_data/pose_sequence/001/0017.png -------------------------------------------------------------------------------- /example_data/pose_sequence/001/0018.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Boese0601/MagicDance/a515a1f4a5fceb9abb3d2cabbc48958ba249e560/example_data/pose_sequence/001/0018.png -------------------------------------------------------------------------------- /example_data/pose_sequence/001/0019.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Boese0601/MagicDance/a515a1f4a5fceb9abb3d2cabbc48958ba249e560/example_data/pose_sequence/001/0019.png -------------------------------------------------------------------------------- /example_data/pose_sequence/001/0020.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Boese0601/MagicDance/a515a1f4a5fceb9abb3d2cabbc48958ba249e560/example_data/pose_sequence/001/0020.png -------------------------------------------------------------------------------- /example_data/pose_sequence/001/0021.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Boese0601/MagicDance/a515a1f4a5fceb9abb3d2cabbc48958ba249e560/example_data/pose_sequence/001/0021.png -------------------------------------------------------------------------------- /example_data/pose_sequence/001/0022.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Boese0601/MagicDance/a515a1f4a5fceb9abb3d2cabbc48958ba249e560/example_data/pose_sequence/001/0022.png -------------------------------------------------------------------------------- /example_data/pose_sequence/001/0023.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Boese0601/MagicDance/a515a1f4a5fceb9abb3d2cabbc48958ba249e560/example_data/pose_sequence/001/0023.png -------------------------------------------------------------------------------- /example_data/pose_sequence/001/0024.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Boese0601/MagicDance/a515a1f4a5fceb9abb3d2cabbc48958ba249e560/example_data/pose_sequence/001/0024.png -------------------------------------------------------------------------------- /example_data/pose_sequence/001/0025.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Boese0601/MagicDance/a515a1f4a5fceb9abb3d2cabbc48958ba249e560/example_data/pose_sequence/001/0025.png -------------------------------------------------------------------------------- /example_data/pose_sequence/002/0001.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Boese0601/MagicDance/a515a1f4a5fceb9abb3d2cabbc48958ba249e560/example_data/pose_sequence/002/0001.png -------------------------------------------------------------------------------- /example_data/pose_sequence/002/0006.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Boese0601/MagicDance/a515a1f4a5fceb9abb3d2cabbc48958ba249e560/example_data/pose_sequence/002/0006.png -------------------------------------------------------------------------------- /example_data/pose_sequence/002/0011.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Boese0601/MagicDance/a515a1f4a5fceb9abb3d2cabbc48958ba249e560/example_data/pose_sequence/002/0011.png -------------------------------------------------------------------------------- /example_data/pose_sequence/002/0016.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Boese0601/MagicDance/a515a1f4a5fceb9abb3d2cabbc48958ba249e560/example_data/pose_sequence/002/0016.png -------------------------------------------------------------------------------- /example_data/pose_sequence/002/0021.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Boese0601/MagicDance/a515a1f4a5fceb9abb3d2cabbc48958ba249e560/example_data/pose_sequence/002/0021.png -------------------------------------------------------------------------------- /example_data/pose_sequence/002/0026.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Boese0601/MagicDance/a515a1f4a5fceb9abb3d2cabbc48958ba249e560/example_data/pose_sequence/002/0026.png -------------------------------------------------------------------------------- /example_data/pose_sequence/002/0031.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Boese0601/MagicDance/a515a1f4a5fceb9abb3d2cabbc48958ba249e560/example_data/pose_sequence/002/0031.png -------------------------------------------------------------------------------- /example_data/pose_sequence/002/0036.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Boese0601/MagicDance/a515a1f4a5fceb9abb3d2cabbc48958ba249e560/example_data/pose_sequence/002/0036.png -------------------------------------------------------------------------------- /example_data/pose_sequence/002/0041.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Boese0601/MagicDance/a515a1f4a5fceb9abb3d2cabbc48958ba249e560/example_data/pose_sequence/002/0041.png -------------------------------------------------------------------------------- /example_data/pose_sequence/002/0046.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Boese0601/MagicDance/a515a1f4a5fceb9abb3d2cabbc48958ba249e560/example_data/pose_sequence/002/0046.png -------------------------------------------------------------------------------- /example_data/pose_sequence/002/0051.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Boese0601/MagicDance/a515a1f4a5fceb9abb3d2cabbc48958ba249e560/example_data/pose_sequence/002/0051.png -------------------------------------------------------------------------------- /example_data/pose_sequence/002/0056.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Boese0601/MagicDance/a515a1f4a5fceb9abb3d2cabbc48958ba249e560/example_data/pose_sequence/002/0056.png -------------------------------------------------------------------------------- /example_data/pose_sequence/002/0061.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Boese0601/MagicDance/a515a1f4a5fceb9abb3d2cabbc48958ba249e560/example_data/pose_sequence/002/0061.png -------------------------------------------------------------------------------- /example_data/pose_sequence/002/0066.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Boese0601/MagicDance/a515a1f4a5fceb9abb3d2cabbc48958ba249e560/example_data/pose_sequence/002/0066.png -------------------------------------------------------------------------------- /example_data/pose_sequence/002/0071.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Boese0601/MagicDance/a515a1f4a5fceb9abb3d2cabbc48958ba249e560/example_data/pose_sequence/002/0071.png -------------------------------------------------------------------------------- /example_data/pose_sequence/002/0076.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Boese0601/MagicDance/a515a1f4a5fceb9abb3d2cabbc48958ba249e560/example_data/pose_sequence/002/0076.png -------------------------------------------------------------------------------- /example_data/pose_sequence/002/0081.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Boese0601/MagicDance/a515a1f4a5fceb9abb3d2cabbc48958ba249e560/example_data/pose_sequence/002/0081.png -------------------------------------------------------------------------------- /example_data/pose_sequence/002/0086.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Boese0601/MagicDance/a515a1f4a5fceb9abb3d2cabbc48958ba249e560/example_data/pose_sequence/002/0086.png -------------------------------------------------------------------------------- /example_data/pose_sequence/002/0091.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Boese0601/MagicDance/a515a1f4a5fceb9abb3d2cabbc48958ba249e560/example_data/pose_sequence/002/0091.png -------------------------------------------------------------------------------- /example_data/pose_sequence/002/0096.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Boese0601/MagicDance/a515a1f4a5fceb9abb3d2cabbc48958ba249e560/example_data/pose_sequence/002/0096.png -------------------------------------------------------------------------------- /example_data/pose_sequence/002/0101.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Boese0601/MagicDance/a515a1f4a5fceb9abb3d2cabbc48958ba249e560/example_data/pose_sequence/002/0101.png -------------------------------------------------------------------------------- /example_data/pose_sequence/002/0106.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Boese0601/MagicDance/a515a1f4a5fceb9abb3d2cabbc48958ba249e560/example_data/pose_sequence/002/0106.png -------------------------------------------------------------------------------- /example_data/pose_sequence/002/0111.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Boese0601/MagicDance/a515a1f4a5fceb9abb3d2cabbc48958ba249e560/example_data/pose_sequence/002/0111.png -------------------------------------------------------------------------------- /example_data/pose_sequence/002/0116.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Boese0601/MagicDance/a515a1f4a5fceb9abb3d2cabbc48958ba249e560/example_data/pose_sequence/002/0116.png -------------------------------------------------------------------------------- /example_data/pose_sequence/002/0121.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Boese0601/MagicDance/a515a1f4a5fceb9abb3d2cabbc48958ba249e560/example_data/pose_sequence/002/0121.png -------------------------------------------------------------------------------- /example_data/pose_sequence/002/0126.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Boese0601/MagicDance/a515a1f4a5fceb9abb3d2cabbc48958ba249e560/example_data/pose_sequence/002/0126.png -------------------------------------------------------------------------------- /example_data/pose_sequence/002/0131.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Boese0601/MagicDance/a515a1f4a5fceb9abb3d2cabbc48958ba249e560/example_data/pose_sequence/002/0131.png -------------------------------------------------------------------------------- /example_data/pose_sequence/002/0136.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Boese0601/MagicDance/a515a1f4a5fceb9abb3d2cabbc48958ba249e560/example_data/pose_sequence/002/0136.png -------------------------------------------------------------------------------- /example_data/pose_sequence/002/0141.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Boese0601/MagicDance/a515a1f4a5fceb9abb3d2cabbc48958ba249e560/example_data/pose_sequence/002/0141.png -------------------------------------------------------------------------------- /example_data/pose_sequence/002/0146.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Boese0601/MagicDance/a515a1f4a5fceb9abb3d2cabbc48958ba249e560/example_data/pose_sequence/002/0146.png -------------------------------------------------------------------------------- /example_data/pose_sequence/002/0151.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Boese0601/MagicDance/a515a1f4a5fceb9abb3d2cabbc48958ba249e560/example_data/pose_sequence/002/0151.png -------------------------------------------------------------------------------- /example_data/pose_sequence/002/0156.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Boese0601/MagicDance/a515a1f4a5fceb9abb3d2cabbc48958ba249e560/example_data/pose_sequence/002/0156.png -------------------------------------------------------------------------------- /example_data/pose_sequence/002/0161.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Boese0601/MagicDance/a515a1f4a5fceb9abb3d2cabbc48958ba249e560/example_data/pose_sequence/002/0161.png -------------------------------------------------------------------------------- /example_data/pose_sequence/002/0166.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Boese0601/MagicDance/a515a1f4a5fceb9abb3d2cabbc48958ba249e560/example_data/pose_sequence/002/0166.png -------------------------------------------------------------------------------- /example_data/pose_sequence/002/0171.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Boese0601/MagicDance/a515a1f4a5fceb9abb3d2cabbc48958ba249e560/example_data/pose_sequence/002/0171.png -------------------------------------------------------------------------------- /example_data/pose_sequence/002/0176.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Boese0601/MagicDance/a515a1f4a5fceb9abb3d2cabbc48958ba249e560/example_data/pose_sequence/002/0176.png -------------------------------------------------------------------------------- /example_data/pose_sequence/002/0181.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Boese0601/MagicDance/a515a1f4a5fceb9abb3d2cabbc48958ba249e560/example_data/pose_sequence/002/0181.png -------------------------------------------------------------------------------- /example_data/pose_sequence/002/0186.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Boese0601/MagicDance/a515a1f4a5fceb9abb3d2cabbc48958ba249e560/example_data/pose_sequence/002/0186.png -------------------------------------------------------------------------------- /example_data/pose_sequence/002/0191.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Boese0601/MagicDance/a515a1f4a5fceb9abb3d2cabbc48958ba249e560/example_data/pose_sequence/002/0191.png -------------------------------------------------------------------------------- /example_data/pose_sequence/002/0196.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Boese0601/MagicDance/a515a1f4a5fceb9abb3d2cabbc48958ba249e560/example_data/pose_sequence/002/0196.png -------------------------------------------------------------------------------- /example_data/pose_sequence/003/0001.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Boese0601/MagicDance/a515a1f4a5fceb9abb3d2cabbc48958ba249e560/example_data/pose_sequence/003/0001.png -------------------------------------------------------------------------------- /example_data/pose_sequence/003/0006.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Boese0601/MagicDance/a515a1f4a5fceb9abb3d2cabbc48958ba249e560/example_data/pose_sequence/003/0006.png -------------------------------------------------------------------------------- /example_data/pose_sequence/003/0011.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Boese0601/MagicDance/a515a1f4a5fceb9abb3d2cabbc48958ba249e560/example_data/pose_sequence/003/0011.png -------------------------------------------------------------------------------- /example_data/pose_sequence/003/0016.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Boese0601/MagicDance/a515a1f4a5fceb9abb3d2cabbc48958ba249e560/example_data/pose_sequence/003/0016.png -------------------------------------------------------------------------------- /example_data/pose_sequence/003/0021.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Boese0601/MagicDance/a515a1f4a5fceb9abb3d2cabbc48958ba249e560/example_data/pose_sequence/003/0021.png -------------------------------------------------------------------------------- /example_data/pose_sequence/003/0026.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Boese0601/MagicDance/a515a1f4a5fceb9abb3d2cabbc48958ba249e560/example_data/pose_sequence/003/0026.png -------------------------------------------------------------------------------- /example_data/pose_sequence/003/0031.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Boese0601/MagicDance/a515a1f4a5fceb9abb3d2cabbc48958ba249e560/example_data/pose_sequence/003/0031.png -------------------------------------------------------------------------------- /example_data/pose_sequence/003/0036.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Boese0601/MagicDance/a515a1f4a5fceb9abb3d2cabbc48958ba249e560/example_data/pose_sequence/003/0036.png -------------------------------------------------------------------------------- /example_data/pose_sequence/003/0041.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Boese0601/MagicDance/a515a1f4a5fceb9abb3d2cabbc48958ba249e560/example_data/pose_sequence/003/0041.png -------------------------------------------------------------------------------- /example_data/pose_sequence/003/0046.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Boese0601/MagicDance/a515a1f4a5fceb9abb3d2cabbc48958ba249e560/example_data/pose_sequence/003/0046.png -------------------------------------------------------------------------------- /example_data/pose_sequence/003/0051.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Boese0601/MagicDance/a515a1f4a5fceb9abb3d2cabbc48958ba249e560/example_data/pose_sequence/003/0051.png -------------------------------------------------------------------------------- /example_data/pose_sequence/003/0057.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Boese0601/MagicDance/a515a1f4a5fceb9abb3d2cabbc48958ba249e560/example_data/pose_sequence/003/0057.png -------------------------------------------------------------------------------- /example_data/pose_sequence/003/0062.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Boese0601/MagicDance/a515a1f4a5fceb9abb3d2cabbc48958ba249e560/example_data/pose_sequence/003/0062.png -------------------------------------------------------------------------------- /example_data/pose_sequence/003/0067.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Boese0601/MagicDance/a515a1f4a5fceb9abb3d2cabbc48958ba249e560/example_data/pose_sequence/003/0067.png -------------------------------------------------------------------------------- /example_data/pose_sequence/003/0072.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Boese0601/MagicDance/a515a1f4a5fceb9abb3d2cabbc48958ba249e560/example_data/pose_sequence/003/0072.png -------------------------------------------------------------------------------- /example_data/pose_sequence/003/0077.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Boese0601/MagicDance/a515a1f4a5fceb9abb3d2cabbc48958ba249e560/example_data/pose_sequence/003/0077.png -------------------------------------------------------------------------------- /example_data/pose_sequence/003/0082.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Boese0601/MagicDance/a515a1f4a5fceb9abb3d2cabbc48958ba249e560/example_data/pose_sequence/003/0082.png -------------------------------------------------------------------------------- /example_data/pose_sequence/003/0087.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Boese0601/MagicDance/a515a1f4a5fceb9abb3d2cabbc48958ba249e560/example_data/pose_sequence/003/0087.png -------------------------------------------------------------------------------- /example_data/pose_sequence/003/0092.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Boese0601/MagicDance/a515a1f4a5fceb9abb3d2cabbc48958ba249e560/example_data/pose_sequence/003/0092.png -------------------------------------------------------------------------------- /example_data/pose_sequence/003/0097.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Boese0601/MagicDance/a515a1f4a5fceb9abb3d2cabbc48958ba249e560/example_data/pose_sequence/003/0097.png -------------------------------------------------------------------------------- /example_data/pose_sequence/003/0102.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Boese0601/MagicDance/a515a1f4a5fceb9abb3d2cabbc48958ba249e560/example_data/pose_sequence/003/0102.png -------------------------------------------------------------------------------- /example_data/pose_sequence/003/0107.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Boese0601/MagicDance/a515a1f4a5fceb9abb3d2cabbc48958ba249e560/example_data/pose_sequence/003/0107.png -------------------------------------------------------------------------------- /example_data/pose_sequence/003/0112.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Boese0601/MagicDance/a515a1f4a5fceb9abb3d2cabbc48958ba249e560/example_data/pose_sequence/003/0112.png -------------------------------------------------------------------------------- /example_data/pose_sequence/003/0117.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Boese0601/MagicDance/a515a1f4a5fceb9abb3d2cabbc48958ba249e560/example_data/pose_sequence/003/0117.png -------------------------------------------------------------------------------- /example_data/pose_sequence/003/0122.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Boese0601/MagicDance/a515a1f4a5fceb9abb3d2cabbc48958ba249e560/example_data/pose_sequence/003/0122.png -------------------------------------------------------------------------------- /example_data/pose_sequence/003/0127.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Boese0601/MagicDance/a515a1f4a5fceb9abb3d2cabbc48958ba249e560/example_data/pose_sequence/003/0127.png -------------------------------------------------------------------------------- /example_data/pose_sequence/003/0132.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Boese0601/MagicDance/a515a1f4a5fceb9abb3d2cabbc48958ba249e560/example_data/pose_sequence/003/0132.png -------------------------------------------------------------------------------- /example_data/pose_sequence/003/0137.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Boese0601/MagicDance/a515a1f4a5fceb9abb3d2cabbc48958ba249e560/example_data/pose_sequence/003/0137.png -------------------------------------------------------------------------------- /example_data/pose_sequence/003/0142.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Boese0601/MagicDance/a515a1f4a5fceb9abb3d2cabbc48958ba249e560/example_data/pose_sequence/003/0142.png -------------------------------------------------------------------------------- /example_data/pose_sequence/003/0147.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Boese0601/MagicDance/a515a1f4a5fceb9abb3d2cabbc48958ba249e560/example_data/pose_sequence/003/0147.png -------------------------------------------------------------------------------- /example_data/pose_sequence/003/0152.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Boese0601/MagicDance/a515a1f4a5fceb9abb3d2cabbc48958ba249e560/example_data/pose_sequence/003/0152.png -------------------------------------------------------------------------------- /example_data/pose_sequence/003/0157.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Boese0601/MagicDance/a515a1f4a5fceb9abb3d2cabbc48958ba249e560/example_data/pose_sequence/003/0157.png -------------------------------------------------------------------------------- /example_data/pose_sequence/003/0162.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Boese0601/MagicDance/a515a1f4a5fceb9abb3d2cabbc48958ba249e560/example_data/pose_sequence/003/0162.png -------------------------------------------------------------------------------- /example_data/pose_sequence/003/0167.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Boese0601/MagicDance/a515a1f4a5fceb9abb3d2cabbc48958ba249e560/example_data/pose_sequence/003/0167.png -------------------------------------------------------------------------------- /example_data/pose_sequence/003/0172.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Boese0601/MagicDance/a515a1f4a5fceb9abb3d2cabbc48958ba249e560/example_data/pose_sequence/003/0172.png -------------------------------------------------------------------------------- /example_data/pose_sequence/003/0177.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Boese0601/MagicDance/a515a1f4a5fceb9abb3d2cabbc48958ba249e560/example_data/pose_sequence/003/0177.png -------------------------------------------------------------------------------- /example_data/pose_sequence/003/0182.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Boese0601/MagicDance/a515a1f4a5fceb9abb3d2cabbc48958ba249e560/example_data/pose_sequence/003/0182.png -------------------------------------------------------------------------------- /example_data/pose_sequence/003/0187.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Boese0601/MagicDance/a515a1f4a5fceb9abb3d2cabbc48958ba249e560/example_data/pose_sequence/003/0187.png -------------------------------------------------------------------------------- /example_data/pose_sequence/003/0192.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Boese0601/MagicDance/a515a1f4a5fceb9abb3d2cabbc48958ba249e560/example_data/pose_sequence/003/0192.png -------------------------------------------------------------------------------- /example_data/pose_sequence/003/0197.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Boese0601/MagicDance/a515a1f4a5fceb9abb3d2cabbc48958ba249e560/example_data/pose_sequence/003/0197.png -------------------------------------------------------------------------------- /figures/1.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Boese0601/MagicDance/a515a1f4a5fceb9abb3d2cabbc48958ba249e560/figures/1.gif -------------------------------------------------------------------------------- /figures/2.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Boese0601/MagicDance/a515a1f4a5fceb9abb3d2cabbc48958ba249e560/figures/2.gif -------------------------------------------------------------------------------- /figures/Comparison_Animate_Anyone.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Boese0601/MagicDance/a515a1f4a5fceb9abb3d2cabbc48958ba249e560/figures/Comparison_Animate_Anyone.gif -------------------------------------------------------------------------------- /figures/magicanimate_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Boese0601/MagicDance/a515a1f4a5fceb9abb3d2cabbc48958ba249e560/figures/magicanimate_1.png -------------------------------------------------------------------------------- /figures/magicanimate_2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Boese0601/MagicDance/a515a1f4a5fceb9abb3d2cabbc48958ba249e560/figures/magicanimate_2.png -------------------------------------------------------------------------------- /figures/teaser.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Boese0601/MagicDance/a515a1f4a5fceb9abb3d2cabbc48958ba249e560/figures/teaser.jpg -------------------------------------------------------------------------------- /figures/tiktok.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Boese0601/MagicDance/a515a1f4a5fceb9abb3d2cabbc48958ba249e560/figures/tiktok.png -------------------------------------------------------------------------------- /figures/video_play.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Boese0601/MagicDance/a515a1f4a5fceb9abb3d2cabbc48958ba249e560/figures/video_play.png -------------------------------------------------------------------------------- /figures/zeroshot_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Boese0601/MagicDance/a515a1f4a5fceb9abb3d2cabbc48958ba249e560/figures/zeroshot_1.png -------------------------------------------------------------------------------- /figures/zeroshot_2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Boese0601/MagicDance/a515a1f4a5fceb9abb3d2cabbc48958ba249e560/figures/zeroshot_2.png -------------------------------------------------------------------------------- /misc_scripts/keypoint/__init__.py: -------------------------------------------------------------------------------- 1 | from .face_keypoint import FaceKeypointDetector -------------------------------------------------------------------------------- /misc_scripts/keypoint/idls/base.thrift: -------------------------------------------------------------------------------- 1 | namespace py base 2 | namespace go base 3 | namespace cpp base 4 | struct TrafficEnv { 5 | 1: bool Open = false, 6 | 2: string Env = "", 7 | } 8 | struct Base { 9 | 1: string LogID = "", 10 | 2: string Caller = "", 11 | 3: string Addr = "", 12 | 4: string Clientx = "", 13 | 5: optional TrafficEnv trafficEnv, 14 | 6: optional map extra, 15 | } 16 | struct BaseResp { 17 | 1: string StatusMessage = "", 18 | 2: i32 StatusCode = 0, 19 | } 20 | -------------------------------------------------------------------------------- /misc_scripts/keypoint/idls/common.thrift: -------------------------------------------------------------------------------- 1 | include "base.thrift" 2 | namespace py common 3 | namespace go common 4 | namespace cpp common 5 | 6 | struct Rect{ 7 | 1: double left, 8 | 2: double top, 9 | 3: double right, 10 | 4: double bottom, 11 | } 12 | 13 | struct Point{ 14 | 1: double x, 15 | 2: double y 16 | 3: bool status, 17 | } 18 | 19 | struct BaseInfo{ 20 | 1: string image_name, 21 | 2: binary image_data, 22 | 254:string caller="default", 23 | } 24 | 25 | struct VideoBaseInfo{ 26 | 1: string video_name, 27 | 2: optional binary video_data, 28 | 3: optional string video_url, # url or binary 二者至少提供一个 29 | 4: i32 max_frame = -1, # 指定抽帧的帧数(max_frame 和frame_interval 只能二选一) 30 | 5: i32 frame_interval = -1, # 帧采样间隔,每秒采集一帧,那就是25 31 | 254:string caller="default", 32 | } 33 | 34 | struct BaseMeta{ 35 | 1: i32 image_width, 36 | 2: i32 image_height, 37 | } 38 | 39 | struct VideoMQRsp{ 40 | 1: string req_id, 41 | 2: string rsp_url, 42 | 3: string video_url = "", 43 | 4: i32 status, 44 | 5: string message, 45 | } 46 | -------------------------------------------------------------------------------- /model_lib/ControlNet/annotator/canny/__init__.py: -------------------------------------------------------------------------------- 1 | import cv2 2 | 3 | 4 | def apply_canny(img, low_threshold, high_threshold): 5 | return cv2.Canny(img, low_threshold, high_threshold) 6 | -------------------------------------------------------------------------------- /model_lib/ControlNet/annotator/ckpts/blip2-opt-2.7b/preprocessor_config.json: -------------------------------------------------------------------------------- 1 | { 2 | "do_convert_rgb": true, 3 | "do_normalize": true, 4 | "do_rescale": true, 5 | "do_resize": true, 6 | "image_mean": [ 7 | 0.48145466, 8 | 0.4578275, 9 | 0.40821073 10 | ], 11 | "image_processor_type": "BlipImageProcessor", 12 | "image_std": [ 13 | 0.26862954, 14 | 0.26130258, 15 | 0.27577711 16 | ], 17 | "processor_class": "Blip2Processor", 18 | "resample": 3, 19 | "rescale_factor": 0.00392156862745098, 20 | "size": { 21 | "height": 224, 22 | "width": 224 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /model_lib/ControlNet/annotator/ckpts/blip2-opt-2.7b/special_tokens_map.json: -------------------------------------------------------------------------------- 1 | { 2 | "bos_token": { 3 | "content": "", 4 | "lstrip": false, 5 | "normalized": true, 6 | "rstrip": false, 7 | "single_word": false 8 | }, 9 | "eos_token": { 10 | "content": "", 11 | "lstrip": false, 12 | "normalized": true, 13 | "rstrip": false, 14 | "single_word": false 15 | }, 16 | "pad_token": { 17 | "content": "", 18 | "lstrip": false, 19 | "normalized": true, 20 | "rstrip": false, 21 | "single_word": false 22 | }, 23 | "unk_token": { 24 | "content": "", 25 | "lstrip": false, 26 | "normalized": true, 27 | "rstrip": false, 28 | "single_word": false 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /model_lib/ControlNet/annotator/ckpts/blip2-opt-2.7b/tokenizer_config.json: -------------------------------------------------------------------------------- 1 | { 2 | "add_bos_token": true, 3 | "add_prefix_space": false, 4 | "bos_token": { 5 | "__type": "AddedToken", 6 | "content": "", 7 | "lstrip": false, 8 | "normalized": true, 9 | "rstrip": false, 10 | "single_word": false 11 | }, 12 | "clean_up_tokenization_spaces": true, 13 | "eos_token": { 14 | "__type": "AddedToken", 15 | "content": "", 16 | "lstrip": false, 17 | "normalized": true, 18 | "rstrip": false, 19 | "single_word": false 20 | }, 21 | "errors": "replace", 22 | "model_max_length": 1000000000000000019884624838656, 23 | "pad_token": { 24 | "__type": "AddedToken", 25 | "content": "", 26 | "lstrip": false, 27 | "normalized": true, 28 | "rstrip": false, 29 | "single_word": false 30 | }, 31 | "processor_class": "Blip2Processor", 32 | "tokenizer_class": "GPT2Tokenizer", 33 | "unk_token": { 34 | "__type": "AddedToken", 35 | "content": "", 36 | "lstrip": false, 37 | "normalized": true, 38 | "rstrip": false, 39 | "single_word": false 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /model_lib/ControlNet/annotator/ckpts/ckpts.txt: -------------------------------------------------------------------------------- 1 | Weights here. -------------------------------------------------------------------------------- /model_lib/ControlNet/annotator/midas/__init__.py: -------------------------------------------------------------------------------- 1 | import cv2 2 | import numpy as np 3 | import torch 4 | 5 | from einops import rearrange 6 | from .api import MiDaSInference 7 | 8 | model = MiDaSInference(model_type="dpt_beit_large_512").cuda() 9 | 10 | 11 | def apply_midas(input_image, a=np.pi * 2.0, bg_th=0.1): 12 | assert input_image.ndim == 3 13 | image_depth = input_image 14 | with torch.no_grad(): 15 | image_depth = torch.from_numpy(image_depth).float().cuda() 16 | image_depth = image_depth / 127.5 - 1.0 17 | image_depth = rearrange(image_depth, 'h w c -> 1 c h w') 18 | depth = model(image_depth)[0] 19 | 20 | depth_pt = depth.clone() 21 | depth_pt -= torch.min(depth_pt) 22 | depth_pt /= torch.max(depth_pt) 23 | depth_pt = depth_pt.cpu().numpy() 24 | depth_image = (depth_pt * 255.0).clip(0, 255).astype(np.uint8) 25 | 26 | depth_np = depth.cpu().numpy() 27 | x = cv2.Sobel(depth_np, cv2.CV_32F, 1, 0, ksize=3) 28 | y = cv2.Sobel(depth_np, cv2.CV_32F, 0, 1, ksize=3) 29 | z = np.ones_like(x) * a 30 | x[depth_pt < bg_th] = 0 31 | y[depth_pt < bg_th] = 0 32 | normal = np.stack([x, y, z], axis=2) 33 | normal /= np.sum(normal ** 2.0, axis=2, keepdims=True) ** 0.5 34 | normal_image = (normal * 127.5 + 127.5).clip(0, 255).astype(np.uint8) 35 | 36 | return depth_image, normal_image 37 | -------------------------------------------------------------------------------- /model_lib/ControlNet/annotator/midas/midas/backbones/next_vit.py: -------------------------------------------------------------------------------- 1 | import timm 2 | 3 | import torch.nn as nn 4 | 5 | from pathlib import Path 6 | from .utils import activations, forward_default, get_activation 7 | 8 | from ..external.next_vit.classification.nextvit import * 9 | 10 | 11 | def forward_next_vit(pretrained, x): 12 | return forward_default(pretrained, x, "forward") 13 | 14 | 15 | def _make_next_vit_backbone( 16 | model, 17 | hooks=[2, 6, 36, 39], 18 | ): 19 | pretrained = nn.Module() 20 | 21 | pretrained.model = model 22 | pretrained.model.features[hooks[0]].register_forward_hook(get_activation("1")) 23 | pretrained.model.features[hooks[1]].register_forward_hook(get_activation("2")) 24 | pretrained.model.features[hooks[2]].register_forward_hook(get_activation("3")) 25 | pretrained.model.features[hooks[3]].register_forward_hook(get_activation("4")) 26 | 27 | pretrained.activations = activations 28 | 29 | return pretrained 30 | 31 | 32 | def _make_pretrained_next_vit_large_6m(hooks=None): 33 | model = timm.create_model("nextvit_large") 34 | 35 | hooks = [2, 6, 36, 39] if hooks == None else hooks 36 | return _make_next_vit_backbone( 37 | model, 38 | hooks=hooks, 39 | ) 40 | -------------------------------------------------------------------------------- /model_lib/ControlNet/annotator/midas/midas/backbones/swin.py: -------------------------------------------------------------------------------- 1 | import timm 2 | 3 | from .swin_common import _make_swin_backbone 4 | 5 | 6 | def _make_pretrained_swinl12_384(pretrained, hooks=None): 7 | model = timm.create_model("swin_large_patch4_window12_384", pretrained=pretrained) 8 | 9 | hooks = [1, 1, 17, 1] if hooks == None else hooks 10 | return _make_swin_backbone( 11 | model, 12 | hooks=hooks 13 | ) 14 | -------------------------------------------------------------------------------- /model_lib/ControlNet/annotator/midas/midas/backbones/swin2.py: -------------------------------------------------------------------------------- 1 | import timm 2 | 3 | from .swin_common import _make_swin_backbone 4 | 5 | 6 | def _make_pretrained_swin2l24_384(pretrained, hooks=None): 7 | model = timm.create_model("swinv2_large_window12to24_192to384_22kft1k", pretrained=pretrained) 8 | 9 | hooks = [1, 1, 17, 1] if hooks == None else hooks 10 | return _make_swin_backbone( 11 | model, 12 | hooks=hooks 13 | ) 14 | 15 | 16 | def _make_pretrained_swin2b24_384(pretrained, hooks=None): 17 | model = timm.create_model("swinv2_base_window12to24_192to384_22kft1k", pretrained=pretrained) 18 | 19 | hooks = [1, 1, 17, 1] if hooks == None else hooks 20 | return _make_swin_backbone( 21 | model, 22 | hooks=hooks 23 | ) 24 | 25 | 26 | def _make_pretrained_swin2t16_256(pretrained, hooks=None): 27 | model = timm.create_model("swinv2_tiny_window16_256", pretrained=pretrained) 28 | 29 | hooks = [1, 1, 5, 1] if hooks == None else hooks 30 | return _make_swin_backbone( 31 | model, 32 | hooks=hooks, 33 | patch_grid=[64, 64] 34 | ) 35 | -------------------------------------------------------------------------------- /model_lib/ControlNet/annotator/midas/midas/base_model.py: -------------------------------------------------------------------------------- 1 | import torch 2 | 3 | 4 | class BaseModel(torch.nn.Module): 5 | def load(self, path): 6 | """Load model from file. 7 | 8 | Args: 9 | path (str): file path 10 | """ 11 | parameters = torch.load(path, map_location=torch.device('cpu')) 12 | 13 | if "optimizer" in parameters: 14 | parameters = parameters["model"] 15 | 16 | self.load_state_dict(parameters) 17 | -------------------------------------------------------------------------------- /model_lib/ControlNet/annotator/mlsd/__init__.py: -------------------------------------------------------------------------------- 1 | import cv2 2 | import numpy as np 3 | import torch 4 | import os 5 | 6 | from einops import rearrange 7 | from .models.mbv2_mlsd_tiny import MobileV2_MLSD_Tiny 8 | from .models.mbv2_mlsd_large import MobileV2_MLSD_Large 9 | from .utils import pred_lines 10 | 11 | 12 | model_path = './annotator/ckpts/mlsd_large_512_fp32.pth' 13 | model = MobileV2_MLSD_Large() 14 | model.load_state_dict(torch.load(model_path), strict=True) 15 | model = model.cuda().eval() 16 | 17 | 18 | def apply_mlsd(input_image, thr_v, thr_d): 19 | assert input_image.ndim == 3 20 | img = input_image 21 | img_output = np.zeros_like(img) 22 | try: 23 | with torch.no_grad(): 24 | lines = pred_lines(img, model, [img.shape[0], img.shape[1]], thr_v, thr_d) 25 | for line in lines: 26 | x_start, y_start, x_end, y_end = [int(val) for val in line] 27 | cv2.line(img_output, (x_start, y_start), (x_end, y_end), [255, 255, 255], 1) 28 | except Exception as e: 29 | pass 30 | return img_output[:, :, 0] 31 | -------------------------------------------------------------------------------- /model_lib/ControlNet/annotator/uniformer/__init__.py: -------------------------------------------------------------------------------- 1 | from annotator.uniformer.mmseg.apis import init_segmentor, inference_segmentor, show_result_pyplot 2 | from annotator.uniformer.mmseg.core.evaluation import get_palette 3 | 4 | 5 | checkpoint_file = "annotator/ckpts/upernet_global_small.pth" 6 | config_file = 'annotator/uniformer/exp/upernet_global_small/config.py' 7 | model = init_segmentor(config_file, checkpoint_file).cuda() 8 | 9 | 10 | def apply_uniformer(img): 11 | result = inference_segmentor(model, img) 12 | res_img = show_result_pyplot(model, img, result, get_palette('ade'), opacity=1) 13 | return res_img 14 | -------------------------------------------------------------------------------- /model_lib/ControlNet/annotator/uniformer/configs/_base_/datasets/cityscapes_769x769.py: -------------------------------------------------------------------------------- 1 | _base_ = './cityscapes.py' 2 | img_norm_cfg = dict( 3 | mean=[123.675, 116.28, 103.53], std=[58.395, 57.12, 57.375], to_rgb=True) 4 | crop_size = (769, 769) 5 | train_pipeline = [ 6 | dict(type='LoadImageFromFile'), 7 | dict(type='LoadAnnotations'), 8 | dict(type='Resize', img_scale=(2049, 1025), ratio_range=(0.5, 2.0)), 9 | dict(type='RandomCrop', crop_size=crop_size, cat_max_ratio=0.75), 10 | dict(type='RandomFlip', prob=0.5), 11 | dict(type='PhotoMetricDistortion'), 12 | dict(type='Normalize', **img_norm_cfg), 13 | dict(type='Pad', size=crop_size, pad_val=0, seg_pad_val=255), 14 | dict(type='DefaultFormatBundle'), 15 | dict(type='Collect', keys=['img', 'gt_semantic_seg']), 16 | ] 17 | test_pipeline = [ 18 | dict(type='LoadImageFromFile'), 19 | dict( 20 | type='MultiScaleFlipAug', 21 | img_scale=(2049, 1025), 22 | # img_ratios=[0.5, 0.75, 1.0, 1.25, 1.5, 1.75], 23 | flip=False, 24 | transforms=[ 25 | dict(type='Resize', keep_ratio=True), 26 | dict(type='RandomFlip'), 27 | dict(type='Normalize', **img_norm_cfg), 28 | dict(type='ImageToTensor', keys=['img']), 29 | dict(type='Collect', keys=['img']), 30 | ]) 31 | ] 32 | data = dict( 33 | train=dict(pipeline=train_pipeline), 34 | val=dict(pipeline=test_pipeline), 35 | test=dict(pipeline=test_pipeline)) 36 | -------------------------------------------------------------------------------- /model_lib/ControlNet/annotator/uniformer/configs/_base_/datasets/pascal_voc12_aug.py: -------------------------------------------------------------------------------- 1 | _base_ = './pascal_voc12.py' 2 | # dataset settings 3 | data = dict( 4 | train=dict( 5 | ann_dir=['SegmentationClass', 'SegmentationClassAug'], 6 | split=[ 7 | 'ImageSets/Segmentation/train.txt', 8 | 'ImageSets/Segmentation/aug.txt' 9 | ])) 10 | -------------------------------------------------------------------------------- /model_lib/ControlNet/annotator/uniformer/configs/_base_/default_runtime.py: -------------------------------------------------------------------------------- 1 | # yapf:disable 2 | log_config = dict( 3 | interval=50, 4 | hooks=[ 5 | dict(type='TextLoggerHook', by_epoch=False), 6 | # dict(type='TensorboardLoggerHook') 7 | ]) 8 | # yapf:enable 9 | dist_params = dict(backend='nccl') 10 | log_level = 'INFO' 11 | load_from = None 12 | resume_from = None 13 | workflow = [('train', 1)] 14 | cudnn_benchmark = True 15 | -------------------------------------------------------------------------------- /model_lib/ControlNet/annotator/uniformer/configs/_base_/models/apcnet_r50-d8.py: -------------------------------------------------------------------------------- 1 | # model settings 2 | norm_cfg = dict(type='SyncBN', requires_grad=True) 3 | model = dict( 4 | type='EncoderDecoder', 5 | pretrained='open-mmlab://resnet50_v1c', 6 | backbone=dict( 7 | type='ResNetV1c', 8 | depth=50, 9 | num_stages=4, 10 | out_indices=(0, 1, 2, 3), 11 | dilations=(1, 1, 2, 4), 12 | strides=(1, 2, 1, 1), 13 | norm_cfg=norm_cfg, 14 | norm_eval=False, 15 | style='pytorch', 16 | contract_dilation=True), 17 | decode_head=dict( 18 | type='APCHead', 19 | in_channels=2048, 20 | in_index=3, 21 | channels=512, 22 | pool_scales=(1, 2, 3, 6), 23 | dropout_ratio=0.1, 24 | num_classes=19, 25 | norm_cfg=dict(type='SyncBN', requires_grad=True), 26 | align_corners=False, 27 | loss_decode=dict( 28 | type='CrossEntropyLoss', use_sigmoid=False, loss_weight=1.0)), 29 | auxiliary_head=dict( 30 | type='FCNHead', 31 | in_channels=1024, 32 | in_index=2, 33 | channels=256, 34 | num_convs=1, 35 | concat_input=False, 36 | dropout_ratio=0.1, 37 | num_classes=19, 38 | norm_cfg=norm_cfg, 39 | align_corners=False, 40 | loss_decode=dict( 41 | type='CrossEntropyLoss', use_sigmoid=False, loss_weight=0.4)), 42 | # model training and testing settings 43 | train_cfg=dict(), 44 | test_cfg=dict(mode='whole')) 45 | -------------------------------------------------------------------------------- /model_lib/ControlNet/annotator/uniformer/configs/_base_/models/ccnet_r50-d8.py: -------------------------------------------------------------------------------- 1 | # model settings 2 | norm_cfg = dict(type='SyncBN', requires_grad=True) 3 | model = dict( 4 | type='EncoderDecoder', 5 | pretrained='open-mmlab://resnet50_v1c', 6 | backbone=dict( 7 | type='ResNetV1c', 8 | depth=50, 9 | num_stages=4, 10 | out_indices=(0, 1, 2, 3), 11 | dilations=(1, 1, 2, 4), 12 | strides=(1, 2, 1, 1), 13 | norm_cfg=norm_cfg, 14 | norm_eval=False, 15 | style='pytorch', 16 | contract_dilation=True), 17 | decode_head=dict( 18 | type='CCHead', 19 | in_channels=2048, 20 | in_index=3, 21 | channels=512, 22 | recurrence=2, 23 | dropout_ratio=0.1, 24 | num_classes=19, 25 | norm_cfg=norm_cfg, 26 | align_corners=False, 27 | loss_decode=dict( 28 | type='CrossEntropyLoss', use_sigmoid=False, loss_weight=1.0)), 29 | auxiliary_head=dict( 30 | type='FCNHead', 31 | in_channels=1024, 32 | in_index=2, 33 | channels=256, 34 | num_convs=1, 35 | concat_input=False, 36 | dropout_ratio=0.1, 37 | num_classes=19, 38 | norm_cfg=norm_cfg, 39 | align_corners=False, 40 | loss_decode=dict( 41 | type='CrossEntropyLoss', use_sigmoid=False, loss_weight=0.4)), 42 | # model training and testing settings 43 | train_cfg=dict(), 44 | test_cfg=dict(mode='whole')) 45 | -------------------------------------------------------------------------------- /model_lib/ControlNet/annotator/uniformer/configs/_base_/models/cgnet.py: -------------------------------------------------------------------------------- 1 | # model settings 2 | norm_cfg = dict(type='SyncBN', eps=1e-03, requires_grad=True) 3 | model = dict( 4 | type='EncoderDecoder', 5 | backbone=dict( 6 | type='CGNet', 7 | norm_cfg=norm_cfg, 8 | in_channels=3, 9 | num_channels=(32, 64, 128), 10 | num_blocks=(3, 21), 11 | dilations=(2, 4), 12 | reductions=(8, 16)), 13 | decode_head=dict( 14 | type='FCNHead', 15 | in_channels=256, 16 | in_index=2, 17 | channels=256, 18 | num_convs=0, 19 | concat_input=False, 20 | dropout_ratio=0, 21 | num_classes=19, 22 | norm_cfg=norm_cfg, 23 | loss_decode=dict( 24 | type='CrossEntropyLoss', 25 | use_sigmoid=False, 26 | loss_weight=1.0, 27 | class_weight=[ 28 | 2.5959933, 6.7415504, 3.5354059, 9.8663225, 9.690899, 9.369352, 29 | 10.289121, 9.953208, 4.3097677, 9.490387, 7.674431, 9.396905, 30 | 10.347791, 6.3927646, 10.226669, 10.241062, 10.280587, 31 | 10.396974, 10.055647 32 | ])), 33 | # model training and testing settings 34 | train_cfg=dict(sampler=None), 35 | test_cfg=dict(mode='whole')) 36 | -------------------------------------------------------------------------------- /model_lib/ControlNet/annotator/uniformer/configs/_base_/models/danet_r50-d8.py: -------------------------------------------------------------------------------- 1 | # model settings 2 | norm_cfg = dict(type='SyncBN', requires_grad=True) 3 | model = dict( 4 | type='EncoderDecoder', 5 | pretrained='open-mmlab://resnet50_v1c', 6 | backbone=dict( 7 | type='ResNetV1c', 8 | depth=50, 9 | num_stages=4, 10 | out_indices=(0, 1, 2, 3), 11 | dilations=(1, 1, 2, 4), 12 | strides=(1, 2, 1, 1), 13 | norm_cfg=norm_cfg, 14 | norm_eval=False, 15 | style='pytorch', 16 | contract_dilation=True), 17 | decode_head=dict( 18 | type='DAHead', 19 | in_channels=2048, 20 | in_index=3, 21 | channels=512, 22 | pam_channels=64, 23 | dropout_ratio=0.1, 24 | num_classes=19, 25 | norm_cfg=norm_cfg, 26 | align_corners=False, 27 | loss_decode=dict( 28 | type='CrossEntropyLoss', use_sigmoid=False, loss_weight=1.0)), 29 | auxiliary_head=dict( 30 | type='FCNHead', 31 | in_channels=1024, 32 | in_index=2, 33 | channels=256, 34 | num_convs=1, 35 | concat_input=False, 36 | dropout_ratio=0.1, 37 | num_classes=19, 38 | norm_cfg=norm_cfg, 39 | align_corners=False, 40 | loss_decode=dict( 41 | type='CrossEntropyLoss', use_sigmoid=False, loss_weight=0.4)), 42 | # model training and testing settings 43 | train_cfg=dict(), 44 | test_cfg=dict(mode='whole')) 45 | -------------------------------------------------------------------------------- /model_lib/ControlNet/annotator/uniformer/configs/_base_/models/deeplabv3_r50-d8.py: -------------------------------------------------------------------------------- 1 | # model settings 2 | norm_cfg = dict(type='SyncBN', requires_grad=True) 3 | model = dict( 4 | type='EncoderDecoder', 5 | pretrained='open-mmlab://resnet50_v1c', 6 | backbone=dict( 7 | type='ResNetV1c', 8 | depth=50, 9 | num_stages=4, 10 | out_indices=(0, 1, 2, 3), 11 | dilations=(1, 1, 2, 4), 12 | strides=(1, 2, 1, 1), 13 | norm_cfg=norm_cfg, 14 | norm_eval=False, 15 | style='pytorch', 16 | contract_dilation=True), 17 | decode_head=dict( 18 | type='ASPPHead', 19 | in_channels=2048, 20 | in_index=3, 21 | channels=512, 22 | dilations=(1, 12, 24, 36), 23 | dropout_ratio=0.1, 24 | num_classes=19, 25 | norm_cfg=norm_cfg, 26 | align_corners=False, 27 | loss_decode=dict( 28 | type='CrossEntropyLoss', use_sigmoid=False, loss_weight=1.0)), 29 | auxiliary_head=dict( 30 | type='FCNHead', 31 | in_channels=1024, 32 | in_index=2, 33 | channels=256, 34 | num_convs=1, 35 | concat_input=False, 36 | dropout_ratio=0.1, 37 | num_classes=19, 38 | norm_cfg=norm_cfg, 39 | align_corners=False, 40 | loss_decode=dict( 41 | type='CrossEntropyLoss', use_sigmoid=False, loss_weight=0.4)), 42 | # model training and testing settings 43 | train_cfg=dict(), 44 | test_cfg=dict(mode='whole')) 45 | -------------------------------------------------------------------------------- /model_lib/ControlNet/annotator/uniformer/configs/_base_/models/dmnet_r50-d8.py: -------------------------------------------------------------------------------- 1 | # model settings 2 | norm_cfg = dict(type='SyncBN', requires_grad=True) 3 | model = dict( 4 | type='EncoderDecoder', 5 | pretrained='open-mmlab://resnet50_v1c', 6 | backbone=dict( 7 | type='ResNetV1c', 8 | depth=50, 9 | num_stages=4, 10 | out_indices=(0, 1, 2, 3), 11 | dilations=(1, 1, 2, 4), 12 | strides=(1, 2, 1, 1), 13 | norm_cfg=norm_cfg, 14 | norm_eval=False, 15 | style='pytorch', 16 | contract_dilation=True), 17 | decode_head=dict( 18 | type='DMHead', 19 | in_channels=2048, 20 | in_index=3, 21 | channels=512, 22 | filter_sizes=(1, 3, 5, 7), 23 | dropout_ratio=0.1, 24 | num_classes=19, 25 | norm_cfg=dict(type='SyncBN', requires_grad=True), 26 | align_corners=False, 27 | loss_decode=dict( 28 | type='CrossEntropyLoss', use_sigmoid=False, loss_weight=1.0)), 29 | auxiliary_head=dict( 30 | type='FCNHead', 31 | in_channels=1024, 32 | in_index=2, 33 | channels=256, 34 | num_convs=1, 35 | concat_input=False, 36 | dropout_ratio=0.1, 37 | num_classes=19, 38 | norm_cfg=norm_cfg, 39 | align_corners=False, 40 | loss_decode=dict( 41 | type='CrossEntropyLoss', use_sigmoid=False, loss_weight=0.4)), 42 | # model training and testing settings 43 | train_cfg=dict(), 44 | test_cfg=dict(mode='whole')) 45 | -------------------------------------------------------------------------------- /model_lib/ControlNet/annotator/uniformer/configs/_base_/models/fcn_r50-d8.py: -------------------------------------------------------------------------------- 1 | # model settings 2 | norm_cfg = dict(type='SyncBN', requires_grad=True) 3 | model = dict( 4 | type='EncoderDecoder', 5 | pretrained='open-mmlab://resnet50_v1c', 6 | backbone=dict( 7 | type='ResNetV1c', 8 | depth=50, 9 | num_stages=4, 10 | out_indices=(0, 1, 2, 3), 11 | dilations=(1, 1, 2, 4), 12 | strides=(1, 2, 1, 1), 13 | norm_cfg=norm_cfg, 14 | norm_eval=False, 15 | style='pytorch', 16 | contract_dilation=True), 17 | decode_head=dict( 18 | type='FCNHead', 19 | in_channels=2048, 20 | in_index=3, 21 | channels=512, 22 | num_convs=2, 23 | concat_input=True, 24 | dropout_ratio=0.1, 25 | num_classes=19, 26 | norm_cfg=norm_cfg, 27 | align_corners=False, 28 | loss_decode=dict( 29 | type='CrossEntropyLoss', use_sigmoid=False, loss_weight=1.0)), 30 | auxiliary_head=dict( 31 | type='FCNHead', 32 | in_channels=1024, 33 | in_index=2, 34 | channels=256, 35 | num_convs=1, 36 | concat_input=False, 37 | dropout_ratio=0.1, 38 | num_classes=19, 39 | norm_cfg=norm_cfg, 40 | align_corners=False, 41 | loss_decode=dict( 42 | type='CrossEntropyLoss', use_sigmoid=False, loss_weight=0.4)), 43 | # model training and testing settings 44 | train_cfg=dict(), 45 | test_cfg=dict(mode='whole')) 46 | -------------------------------------------------------------------------------- /model_lib/ControlNet/annotator/uniformer/configs/_base_/models/fpn_r50.py: -------------------------------------------------------------------------------- 1 | # model settings 2 | norm_cfg = dict(type='SyncBN', requires_grad=True) 3 | model = dict( 4 | type='EncoderDecoder', 5 | pretrained='open-mmlab://resnet50_v1c', 6 | backbone=dict( 7 | type='ResNetV1c', 8 | depth=50, 9 | num_stages=4, 10 | out_indices=(0, 1, 2, 3), 11 | dilations=(1, 1, 1, 1), 12 | strides=(1, 2, 2, 2), 13 | norm_cfg=norm_cfg, 14 | norm_eval=False, 15 | style='pytorch', 16 | contract_dilation=True), 17 | neck=dict( 18 | type='FPN', 19 | in_channels=[256, 512, 1024, 2048], 20 | out_channels=256, 21 | num_outs=4), 22 | decode_head=dict( 23 | type='FPNHead', 24 | in_channels=[256, 256, 256, 256], 25 | in_index=[0, 1, 2, 3], 26 | feature_strides=[4, 8, 16, 32], 27 | channels=128, 28 | dropout_ratio=0.1, 29 | num_classes=19, 30 | norm_cfg=norm_cfg, 31 | align_corners=False, 32 | loss_decode=dict( 33 | type='CrossEntropyLoss', use_sigmoid=False, loss_weight=1.0)), 34 | # model training and testing settings 35 | train_cfg=dict(), 36 | test_cfg=dict(mode='whole')) 37 | -------------------------------------------------------------------------------- /model_lib/ControlNet/annotator/uniformer/configs/_base_/models/fpn_uniformer.py: -------------------------------------------------------------------------------- 1 | # model settings 2 | norm_cfg = dict(type='SyncBN', requires_grad=True) 3 | model = dict( 4 | type='EncoderDecoder', 5 | backbone=dict( 6 | type='UniFormer', 7 | embed_dim=[64, 128, 320, 512], 8 | layers=[3, 4, 8, 3], 9 | head_dim=64, 10 | mlp_ratio=4., 11 | qkv_bias=True, 12 | drop_rate=0., 13 | attn_drop_rate=0., 14 | drop_path_rate=0.1), 15 | neck=dict( 16 | type='FPN', 17 | in_channels=[64, 128, 320, 512], 18 | out_channels=256, 19 | num_outs=4), 20 | decode_head=dict( 21 | type='FPNHead', 22 | in_channels=[256, 256, 256, 256], 23 | in_index=[0, 1, 2, 3], 24 | feature_strides=[4, 8, 16, 32], 25 | channels=128, 26 | dropout_ratio=0.1, 27 | num_classes=150, 28 | norm_cfg=norm_cfg, 29 | align_corners=False, 30 | loss_decode=dict( 31 | type='CrossEntropyLoss', use_sigmoid=False, loss_weight=1.0)), 32 | # model training and testing settings 33 | train_cfg=dict(), 34 | test_cfg=dict(mode='whole') 35 | ) 36 | -------------------------------------------------------------------------------- /model_lib/ControlNet/annotator/uniformer/configs/_base_/models/lraspp_m-v3-d8.py: -------------------------------------------------------------------------------- 1 | # model settings 2 | norm_cfg = dict(type='SyncBN', eps=0.001, requires_grad=True) 3 | model = dict( 4 | type='EncoderDecoder', 5 | backbone=dict( 6 | type='MobileNetV3', 7 | arch='large', 8 | out_indices=(1, 3, 16), 9 | norm_cfg=norm_cfg), 10 | decode_head=dict( 11 | type='LRASPPHead', 12 | in_channels=(16, 24, 960), 13 | in_index=(0, 1, 2), 14 | channels=128, 15 | input_transform='multiple_select', 16 | dropout_ratio=0.1, 17 | num_classes=19, 18 | norm_cfg=norm_cfg, 19 | act_cfg=dict(type='ReLU'), 20 | align_corners=False, 21 | loss_decode=dict( 22 | type='CrossEntropyLoss', use_sigmoid=False, loss_weight=1.0)), 23 | # model training and testing settings 24 | train_cfg=dict(), 25 | test_cfg=dict(mode='whole')) 26 | -------------------------------------------------------------------------------- /model_lib/ControlNet/annotator/uniformer/configs/_base_/models/pspnet_r50-d8.py: -------------------------------------------------------------------------------- 1 | # model settings 2 | norm_cfg = dict(type='SyncBN', requires_grad=True) 3 | model = dict( 4 | type='EncoderDecoder', 5 | pretrained='open-mmlab://resnet50_v1c', 6 | backbone=dict( 7 | type='ResNetV1c', 8 | depth=50, 9 | num_stages=4, 10 | out_indices=(0, 1, 2, 3), 11 | dilations=(1, 1, 2, 4), 12 | strides=(1, 2, 1, 1), 13 | norm_cfg=norm_cfg, 14 | norm_eval=False, 15 | style='pytorch', 16 | contract_dilation=True), 17 | decode_head=dict( 18 | type='PSPHead', 19 | in_channels=2048, 20 | in_index=3, 21 | channels=512, 22 | pool_scales=(1, 2, 3, 6), 23 | dropout_ratio=0.1, 24 | num_classes=19, 25 | norm_cfg=norm_cfg, 26 | align_corners=False, 27 | loss_decode=dict( 28 | type='CrossEntropyLoss', use_sigmoid=False, loss_weight=1.0)), 29 | auxiliary_head=dict( 30 | type='FCNHead', 31 | in_channels=1024, 32 | in_index=2, 33 | channels=256, 34 | num_convs=1, 35 | concat_input=False, 36 | dropout_ratio=0.1, 37 | num_classes=19, 38 | norm_cfg=norm_cfg, 39 | align_corners=False, 40 | loss_decode=dict( 41 | type='CrossEntropyLoss', use_sigmoid=False, loss_weight=0.4)), 42 | # model training and testing settings 43 | train_cfg=dict(), 44 | test_cfg=dict(mode='whole')) 45 | -------------------------------------------------------------------------------- /model_lib/ControlNet/annotator/uniformer/configs/_base_/models/upernet_r50.py: -------------------------------------------------------------------------------- 1 | # model settings 2 | norm_cfg = dict(type='SyncBN', requires_grad=True) 3 | model = dict( 4 | type='EncoderDecoder', 5 | pretrained='open-mmlab://resnet50_v1c', 6 | backbone=dict( 7 | type='ResNetV1c', 8 | depth=50, 9 | num_stages=4, 10 | out_indices=(0, 1, 2, 3), 11 | dilations=(1, 1, 1, 1), 12 | strides=(1, 2, 2, 2), 13 | norm_cfg=norm_cfg, 14 | norm_eval=False, 15 | style='pytorch', 16 | contract_dilation=True), 17 | decode_head=dict( 18 | type='UPerHead', 19 | in_channels=[256, 512, 1024, 2048], 20 | in_index=[0, 1, 2, 3], 21 | pool_scales=(1, 2, 3, 6), 22 | channels=512, 23 | dropout_ratio=0.1, 24 | num_classes=19, 25 | norm_cfg=norm_cfg, 26 | align_corners=False, 27 | loss_decode=dict( 28 | type='CrossEntropyLoss', use_sigmoid=False, loss_weight=1.0)), 29 | auxiliary_head=dict( 30 | type='FCNHead', 31 | in_channels=1024, 32 | in_index=2, 33 | channels=256, 34 | num_convs=1, 35 | concat_input=False, 36 | dropout_ratio=0.1, 37 | num_classes=19, 38 | norm_cfg=norm_cfg, 39 | align_corners=False, 40 | loss_decode=dict( 41 | type='CrossEntropyLoss', use_sigmoid=False, loss_weight=0.4)), 42 | # model training and testing settings 43 | train_cfg=dict(), 44 | test_cfg=dict(mode='whole')) 45 | -------------------------------------------------------------------------------- /model_lib/ControlNet/annotator/uniformer/configs/_base_/models/upernet_uniformer.py: -------------------------------------------------------------------------------- 1 | # model settings 2 | norm_cfg = dict(type='BN', requires_grad=True) 3 | model = dict( 4 | type='EncoderDecoder', 5 | pretrained=None, 6 | backbone=dict( 7 | type='UniFormer', 8 | embed_dim=[64, 128, 320, 512], 9 | layers=[3, 4, 8, 3], 10 | head_dim=64, 11 | mlp_ratio=4., 12 | qkv_bias=True, 13 | drop_rate=0., 14 | attn_drop_rate=0., 15 | drop_path_rate=0.1), 16 | decode_head=dict( 17 | type='UPerHead', 18 | in_channels=[64, 128, 320, 512], 19 | in_index=[0, 1, 2, 3], 20 | pool_scales=(1, 2, 3, 6), 21 | channels=512, 22 | dropout_ratio=0.1, 23 | num_classes=19, 24 | norm_cfg=norm_cfg, 25 | align_corners=False, 26 | loss_decode=dict( 27 | type='CrossEntropyLoss', use_sigmoid=False, loss_weight=1.0)), 28 | auxiliary_head=dict( 29 | type='FCNHead', 30 | in_channels=320, 31 | in_index=2, 32 | channels=256, 33 | num_convs=1, 34 | concat_input=False, 35 | dropout_ratio=0.1, 36 | num_classes=19, 37 | norm_cfg=norm_cfg, 38 | align_corners=False, 39 | loss_decode=dict( 40 | type='CrossEntropyLoss', use_sigmoid=False, loss_weight=0.4)), 41 | # model training and testing settings 42 | train_cfg=dict(), 43 | test_cfg=dict(mode='whole')) -------------------------------------------------------------------------------- /model_lib/ControlNet/annotator/uniformer/configs/_base_/schedules/schedule_160k.py: -------------------------------------------------------------------------------- 1 | # optimizer 2 | optimizer = dict(type='SGD', lr=0.01, momentum=0.9, weight_decay=0.0005) 3 | optimizer_config = dict() 4 | # learning policy 5 | lr_config = dict(policy='poly', power=0.9, min_lr=1e-4, by_epoch=False) 6 | # runtime settings 7 | runner = dict(type='IterBasedRunner', max_iters=160000) 8 | checkpoint_config = dict(by_epoch=False, interval=16000) 9 | evaluation = dict(interval=16000, metric='mIoU') 10 | -------------------------------------------------------------------------------- /model_lib/ControlNet/annotator/uniformer/configs/_base_/schedules/schedule_20k.py: -------------------------------------------------------------------------------- 1 | # optimizer 2 | optimizer = dict(type='SGD', lr=0.01, momentum=0.9, weight_decay=0.0005) 3 | optimizer_config = dict() 4 | # learning policy 5 | lr_config = dict(policy='poly', power=0.9, min_lr=1e-4, by_epoch=False) 6 | # runtime settings 7 | runner = dict(type='IterBasedRunner', max_iters=20000) 8 | checkpoint_config = dict(by_epoch=False, interval=2000) 9 | evaluation = dict(interval=2000, metric='mIoU') 10 | -------------------------------------------------------------------------------- /model_lib/ControlNet/annotator/uniformer/configs/_base_/schedules/schedule_40k.py: -------------------------------------------------------------------------------- 1 | # optimizer 2 | optimizer = dict(type='SGD', lr=0.01, momentum=0.9, weight_decay=0.0005) 3 | optimizer_config = dict() 4 | # learning policy 5 | lr_config = dict(policy='poly', power=0.9, min_lr=1e-4, by_epoch=False) 6 | # runtime settings 7 | runner = dict(type='IterBasedRunner', max_iters=40000) 8 | checkpoint_config = dict(by_epoch=False, interval=4000) 9 | evaluation = dict(interval=4000, metric='mIoU') 10 | -------------------------------------------------------------------------------- /model_lib/ControlNet/annotator/uniformer/configs/_base_/schedules/schedule_80k.py: -------------------------------------------------------------------------------- 1 | # optimizer 2 | optimizer = dict(type='SGD', lr=0.01, momentum=0.9, weight_decay=0.0005) 3 | optimizer_config = dict() 4 | # learning policy 5 | lr_config = dict(policy='poly', power=0.9, min_lr=1e-4, by_epoch=False) 6 | # runtime settings 7 | runner = dict(type='IterBasedRunner', max_iters=80000) 8 | checkpoint_config = dict(by_epoch=False, interval=8000) 9 | evaluation = dict(interval=8000, metric='mIoU') 10 | -------------------------------------------------------------------------------- /model_lib/ControlNet/annotator/uniformer/exp/upernet_global_small/config.py: -------------------------------------------------------------------------------- 1 | _base_ = [ 2 | '../../configs/_base_/models/upernet_uniformer.py', 3 | '../../configs/_base_/datasets/ade20k.py', 4 | '../../configs/_base_/default_runtime.py', 5 | '../../configs/_base_/schedules/schedule_160k.py' 6 | ] 7 | model = dict( 8 | backbone=dict( 9 | type='UniFormer', 10 | embed_dim=[64, 128, 320, 512], 11 | layers=[3, 4, 8, 3], 12 | head_dim=64, 13 | drop_path_rate=0.25, 14 | windows=False, 15 | hybrid=False 16 | ), 17 | decode_head=dict( 18 | in_channels=[64, 128, 320, 512], 19 | num_classes=150 20 | ), 21 | auxiliary_head=dict( 22 | in_channels=320, 23 | num_classes=150 24 | )) 25 | 26 | # AdamW optimizer, no weight decay for position embedding & layer norm in backbone 27 | optimizer = dict(_delete_=True, type='AdamW', lr=0.00006, betas=(0.9, 0.999), weight_decay=0.01, 28 | paramwise_cfg=dict(custom_keys={'absolute_pos_embed': dict(decay_mult=0.), 29 | 'relative_position_bias_table': dict(decay_mult=0.), 30 | 'norm': dict(decay_mult=0.)})) 31 | 32 | lr_config = dict(_delete_=True, policy='poly', 33 | warmup='linear', 34 | warmup_iters=1500, 35 | warmup_ratio=1e-6, 36 | power=1.0, min_lr=0.0, by_epoch=False) 37 | 38 | data=dict(samples_per_gpu=2) -------------------------------------------------------------------------------- /model_lib/ControlNet/annotator/uniformer/exp/upernet_global_small/run.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | work_path=$(dirname $0) 4 | PYTHONPATH="$(dirname $0)/../../":$PYTHONPATH \ 5 | python -m torch.distributed.launch --nproc_per_node=8 \ 6 | tools/train.py ${work_path}/config.py \ 7 | --launcher pytorch \ 8 | --options model.backbone.pretrained_path='your_model_path/uniformer_small_in1k.pth' \ 9 | --work-dir ${work_path}/ckpt \ 10 | 2>&1 | tee -a ${work_path}/log.txt 11 | -------------------------------------------------------------------------------- /model_lib/ControlNet/annotator/uniformer/exp/upernet_global_small/test.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | work_path=$(dirname $0) 4 | PYTHONPATH="$(dirname $0)/../../":$PYTHONPATH \ 5 | python -m torch.distributed.launch --nproc_per_node=8 \ 6 | tools/test.py ${work_path}/test_config_h32.py \ 7 | ${work_path}/ckpt/latest.pth \ 8 | --launcher pytorch \ 9 | --eval mIoU \ 10 | 2>&1 | tee -a ${work_path}/log.txt 11 | -------------------------------------------------------------------------------- /model_lib/ControlNet/annotator/uniformer/exp/upernet_global_small/test_config_g.py: -------------------------------------------------------------------------------- 1 | _base_ = [ 2 | '../../configs/_base_/models/upernet_uniformer.py', 3 | '../../configs/_base_/datasets/ade20k.py', 4 | '../../configs/_base_/default_runtime.py', 5 | '../../configs/_base_/schedules/schedule_160k.py' 6 | ] 7 | model = dict( 8 | backbone=dict( 9 | type='UniFormer', 10 | embed_dim=[64, 128, 320, 512], 11 | layers=[3, 4, 8, 3], 12 | head_dim=64, 13 | drop_path_rate=0.25, 14 | windows=False, 15 | hybrid=False, 16 | ), 17 | decode_head=dict( 18 | in_channels=[64, 128, 320, 512], 19 | num_classes=150 20 | ), 21 | auxiliary_head=dict( 22 | in_channels=320, 23 | num_classes=150 24 | )) 25 | 26 | # AdamW optimizer, no weight decay for position embedding & layer norm in backbone 27 | optimizer = dict(_delete_=True, type='AdamW', lr=0.00006, betas=(0.9, 0.999), weight_decay=0.01, 28 | paramwise_cfg=dict(custom_keys={'absolute_pos_embed': dict(decay_mult=0.), 29 | 'relative_position_bias_table': dict(decay_mult=0.), 30 | 'norm': dict(decay_mult=0.)})) 31 | 32 | lr_config = dict(_delete_=True, policy='poly', 33 | warmup='linear', 34 | warmup_iters=1500, 35 | warmup_ratio=1e-6, 36 | power=1.0, min_lr=0.0, by_epoch=False) 37 | 38 | data=dict(samples_per_gpu=2) -------------------------------------------------------------------------------- /model_lib/ControlNet/annotator/uniformer/mmcv/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) OpenMMLab. All rights reserved. 2 | # flake8: noqa 3 | from .arraymisc import * 4 | from .fileio import * 5 | from .image import * 6 | from .utils import * 7 | from .version import * 8 | from .video import * 9 | from .visualization import * 10 | 11 | # The following modules are not imported to this level, so mmcv may be used 12 | # without PyTorch. 13 | # - runner 14 | # - parallel 15 | # - op 16 | -------------------------------------------------------------------------------- /model_lib/ControlNet/annotator/uniformer/mmcv/arraymisc/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) OpenMMLab. All rights reserved. 2 | from .quantization import dequantize, quantize 3 | 4 | __all__ = ['quantize', 'dequantize'] 5 | -------------------------------------------------------------------------------- /model_lib/ControlNet/annotator/uniformer/mmcv/cnn/bricks/hsigmoid.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) OpenMMLab. All rights reserved. 2 | import torch.nn as nn 3 | 4 | from .registry import ACTIVATION_LAYERS 5 | 6 | 7 | @ACTIVATION_LAYERS.register_module() 8 | class HSigmoid(nn.Module): 9 | """Hard Sigmoid Module. Apply the hard sigmoid function: 10 | Hsigmoid(x) = min(max((x + bias) / divisor, min_value), max_value) 11 | Default: Hsigmoid(x) = min(max((x + 1) / 2, 0), 1) 12 | 13 | Args: 14 | bias (float): Bias of the input feature map. Default: 1.0. 15 | divisor (float): Divisor of the input feature map. Default: 2.0. 16 | min_value (float): Lower bound value. Default: 0.0. 17 | max_value (float): Upper bound value. Default: 1.0. 18 | 19 | Returns: 20 | Tensor: The output tensor. 21 | """ 22 | 23 | def __init__(self, bias=1.0, divisor=2.0, min_value=0.0, max_value=1.0): 24 | super(HSigmoid, self).__init__() 25 | self.bias = bias 26 | self.divisor = divisor 27 | assert self.divisor != 0 28 | self.min_value = min_value 29 | self.max_value = max_value 30 | 31 | def forward(self, x): 32 | x = (x + self.bias) / self.divisor 33 | 34 | return x.clamp_(self.min_value, self.max_value) 35 | -------------------------------------------------------------------------------- /model_lib/ControlNet/annotator/uniformer/mmcv/cnn/bricks/hswish.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) OpenMMLab. All rights reserved. 2 | import torch.nn as nn 3 | 4 | from .registry import ACTIVATION_LAYERS 5 | 6 | 7 | @ACTIVATION_LAYERS.register_module() 8 | class HSwish(nn.Module): 9 | """Hard Swish Module. 10 | 11 | This module applies the hard swish function: 12 | 13 | .. math:: 14 | Hswish(x) = x * ReLU6(x + 3) / 6 15 | 16 | Args: 17 | inplace (bool): can optionally do the operation in-place. 18 | Default: False. 19 | 20 | Returns: 21 | Tensor: The output tensor. 22 | """ 23 | 24 | def __init__(self, inplace=False): 25 | super(HSwish, self).__init__() 26 | self.act = nn.ReLU6(inplace) 27 | 28 | def forward(self, x): 29 | return x * self.act(x + 3) / 6 30 | -------------------------------------------------------------------------------- /model_lib/ControlNet/annotator/uniformer/mmcv/cnn/bricks/padding.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) OpenMMLab. All rights reserved. 2 | import torch.nn as nn 3 | 4 | from .registry import PADDING_LAYERS 5 | 6 | PADDING_LAYERS.register_module('zero', module=nn.ZeroPad2d) 7 | PADDING_LAYERS.register_module('reflect', module=nn.ReflectionPad2d) 8 | PADDING_LAYERS.register_module('replicate', module=nn.ReplicationPad2d) 9 | 10 | 11 | def build_padding_layer(cfg, *args, **kwargs): 12 | """Build padding layer. 13 | 14 | Args: 15 | cfg (None or dict): The padding layer config, which should contain: 16 | - type (str): Layer type. 17 | - layer args: Args needed to instantiate a padding layer. 18 | 19 | Returns: 20 | nn.Module: Created padding layer. 21 | """ 22 | if not isinstance(cfg, dict): 23 | raise TypeError('cfg must be a dict') 24 | if 'type' not in cfg: 25 | raise KeyError('the cfg dict must contain the key "type"') 26 | 27 | cfg_ = cfg.copy() 28 | padding_type = cfg_.pop('type') 29 | if padding_type not in PADDING_LAYERS: 30 | raise KeyError(f'Unrecognized padding type {padding_type}.') 31 | else: 32 | padding_layer = PADDING_LAYERS.get(padding_type) 33 | 34 | layer = padding_layer(*args, **kwargs, **cfg_) 35 | 36 | return layer 37 | -------------------------------------------------------------------------------- /model_lib/ControlNet/annotator/uniformer/mmcv/cnn/bricks/registry.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) OpenMMLab. All rights reserved. 2 | from annotator.uniformer.mmcv.utils import Registry 3 | 4 | CONV_LAYERS = Registry('conv layer') 5 | NORM_LAYERS = Registry('norm layer') 6 | ACTIVATION_LAYERS = Registry('activation layer') 7 | PADDING_LAYERS = Registry('padding layer') 8 | UPSAMPLE_LAYERS = Registry('upsample layer') 9 | PLUGIN_LAYERS = Registry('plugin layer') 10 | 11 | DROPOUT_LAYERS = Registry('drop out layers') 12 | POSITIONAL_ENCODING = Registry('position encoding') 13 | ATTENTION = Registry('attention') 14 | FEEDFORWARD_NETWORK = Registry('feed-forward Network') 15 | TRANSFORMER_LAYER = Registry('transformerLayer') 16 | TRANSFORMER_LAYER_SEQUENCE = Registry('transformer-layers sequence') 17 | -------------------------------------------------------------------------------- /model_lib/ControlNet/annotator/uniformer/mmcv/cnn/bricks/scale.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) OpenMMLab. All rights reserved. 2 | import torch 3 | import torch.nn as nn 4 | 5 | 6 | class Scale(nn.Module): 7 | """A learnable scale parameter. 8 | 9 | This layer scales the input by a learnable factor. It multiplies a 10 | learnable scale parameter of shape (1,) with input of any shape. 11 | 12 | Args: 13 | scale (float): Initial value of scale factor. Default: 1.0 14 | """ 15 | 16 | def __init__(self, scale=1.0): 17 | super(Scale, self).__init__() 18 | self.scale = nn.Parameter(torch.tensor(scale, dtype=torch.float)) 19 | 20 | def forward(self, x): 21 | return x * self.scale 22 | -------------------------------------------------------------------------------- /model_lib/ControlNet/annotator/uniformer/mmcv/cnn/bricks/swish.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) OpenMMLab. All rights reserved. 2 | import torch 3 | import torch.nn as nn 4 | 5 | from .registry import ACTIVATION_LAYERS 6 | 7 | 8 | @ACTIVATION_LAYERS.register_module() 9 | class Swish(nn.Module): 10 | """Swish Module. 11 | 12 | This module applies the swish function: 13 | 14 | .. math:: 15 | Swish(x) = x * Sigmoid(x) 16 | 17 | Returns: 18 | Tensor: The output tensor. 19 | """ 20 | 21 | def __init__(self): 22 | super(Swish, self).__init__() 23 | 24 | def forward(self, x): 25 | return x * torch.sigmoid(x) 26 | -------------------------------------------------------------------------------- /model_lib/ControlNet/annotator/uniformer/mmcv/cnn/builder.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) OpenMMLab. All rights reserved. 2 | from ..runner import Sequential 3 | from ..utils import Registry, build_from_cfg 4 | 5 | 6 | def build_model_from_cfg(cfg, registry, default_args=None): 7 | """Build a PyTorch model from config dict(s). Different from 8 | ``build_from_cfg``, if cfg is a list, a ``nn.Sequential`` will be built. 9 | 10 | Args: 11 | cfg (dict, list[dict]): The config of modules, is is either a config 12 | dict or a list of config dicts. If cfg is a list, a 13 | the built modules will be wrapped with ``nn.Sequential``. 14 | registry (:obj:`Registry`): A registry the module belongs to. 15 | default_args (dict, optional): Default arguments to build the module. 16 | Defaults to None. 17 | 18 | Returns: 19 | nn.Module: A built nn module. 20 | """ 21 | if isinstance(cfg, list): 22 | modules = [ 23 | build_from_cfg(cfg_, registry, default_args) for cfg_ in cfg 24 | ] 25 | return Sequential(*modules) 26 | else: 27 | return build_from_cfg(cfg, registry, default_args) 28 | 29 | 30 | MODELS = Registry('model', build_func=build_model_from_cfg) 31 | -------------------------------------------------------------------------------- /model_lib/ControlNet/annotator/uniformer/mmcv/cnn/utils/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) OpenMMLab. All rights reserved. 2 | from .flops_counter import get_model_complexity_info 3 | from .fuse_conv_bn import fuse_conv_bn 4 | from .sync_bn import revert_sync_batchnorm 5 | from .weight_init import (INITIALIZERS, Caffe2XavierInit, ConstantInit, 6 | KaimingInit, NormalInit, PretrainedInit, 7 | TruncNormalInit, UniformInit, XavierInit, 8 | bias_init_with_prob, caffe2_xavier_init, 9 | constant_init, initialize, kaiming_init, normal_init, 10 | trunc_normal_init, uniform_init, xavier_init) 11 | 12 | __all__ = [ 13 | 'get_model_complexity_info', 'bias_init_with_prob', 'caffe2_xavier_init', 14 | 'constant_init', 'kaiming_init', 'normal_init', 'trunc_normal_init', 15 | 'uniform_init', 'xavier_init', 'fuse_conv_bn', 'initialize', 16 | 'INITIALIZERS', 'ConstantInit', 'XavierInit', 'NormalInit', 17 | 'TruncNormalInit', 'UniformInit', 'KaimingInit', 'PretrainedInit', 18 | 'Caffe2XavierInit', 'revert_sync_batchnorm' 19 | ] 20 | -------------------------------------------------------------------------------- /model_lib/ControlNet/annotator/uniformer/mmcv/engine/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) OpenMMLab. All rights reserved. 2 | from .test import (collect_results_cpu, collect_results_gpu, multi_gpu_test, 3 | single_gpu_test) 4 | 5 | __all__ = [ 6 | 'collect_results_cpu', 'collect_results_gpu', 'multi_gpu_test', 7 | 'single_gpu_test' 8 | ] 9 | -------------------------------------------------------------------------------- /model_lib/ControlNet/annotator/uniformer/mmcv/fileio/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) OpenMMLab. All rights reserved. 2 | from .file_client import BaseStorageBackend, FileClient 3 | from .handlers import BaseFileHandler, JsonHandler, PickleHandler, YamlHandler 4 | from .io import dump, load, register_handler 5 | from .parse import dict_from_file, list_from_file 6 | 7 | __all__ = [ 8 | 'BaseStorageBackend', 'FileClient', 'load', 'dump', 'register_handler', 9 | 'BaseFileHandler', 'JsonHandler', 'PickleHandler', 'YamlHandler', 10 | 'list_from_file', 'dict_from_file' 11 | ] 12 | -------------------------------------------------------------------------------- /model_lib/ControlNet/annotator/uniformer/mmcv/fileio/handlers/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) OpenMMLab. All rights reserved. 2 | from .base import BaseFileHandler 3 | from .json_handler import JsonHandler 4 | from .pickle_handler import PickleHandler 5 | from .yaml_handler import YamlHandler 6 | 7 | __all__ = ['BaseFileHandler', 'JsonHandler', 'PickleHandler', 'YamlHandler'] 8 | -------------------------------------------------------------------------------- /model_lib/ControlNet/annotator/uniformer/mmcv/fileio/handlers/base.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) OpenMMLab. All rights reserved. 2 | from abc import ABCMeta, abstractmethod 3 | 4 | 5 | class BaseFileHandler(metaclass=ABCMeta): 6 | # `str_like` is a flag to indicate whether the type of file object is 7 | # str-like object or bytes-like object. Pickle only processes bytes-like 8 | # objects but json only processes str-like object. If it is str-like 9 | # object, `StringIO` will be used to process the buffer. 10 | str_like = True 11 | 12 | @abstractmethod 13 | def load_from_fileobj(self, file, **kwargs): 14 | pass 15 | 16 | @abstractmethod 17 | def dump_to_fileobj(self, obj, file, **kwargs): 18 | pass 19 | 20 | @abstractmethod 21 | def dump_to_str(self, obj, **kwargs): 22 | pass 23 | 24 | def load_from_path(self, filepath, mode='r', **kwargs): 25 | with open(filepath, mode) as f: 26 | return self.load_from_fileobj(f, **kwargs) 27 | 28 | def dump_to_path(self, obj, filepath, mode='w', **kwargs): 29 | with open(filepath, mode) as f: 30 | self.dump_to_fileobj(obj, f, **kwargs) 31 | -------------------------------------------------------------------------------- /model_lib/ControlNet/annotator/uniformer/mmcv/fileio/handlers/json_handler.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) OpenMMLab. All rights reserved. 2 | import json 3 | 4 | import numpy as np 5 | 6 | from .base import BaseFileHandler 7 | 8 | 9 | def set_default(obj): 10 | """Set default json values for non-serializable values. 11 | 12 | It helps convert ``set``, ``range`` and ``np.ndarray`` data types to list. 13 | It also converts ``np.generic`` (including ``np.int32``, ``np.float32``, 14 | etc.) into plain numbers of plain python built-in types. 15 | """ 16 | if isinstance(obj, (set, range)): 17 | return list(obj) 18 | elif isinstance(obj, np.ndarray): 19 | return obj.tolist() 20 | elif isinstance(obj, np.generic): 21 | return obj.item() 22 | raise TypeError(f'{type(obj)} is unsupported for json dump') 23 | 24 | 25 | class JsonHandler(BaseFileHandler): 26 | 27 | def load_from_fileobj(self, file): 28 | return json.load(file) 29 | 30 | def dump_to_fileobj(self, obj, file, **kwargs): 31 | kwargs.setdefault('default', set_default) 32 | json.dump(obj, file, **kwargs) 33 | 34 | def dump_to_str(self, obj, **kwargs): 35 | kwargs.setdefault('default', set_default) 36 | return json.dumps(obj, **kwargs) 37 | -------------------------------------------------------------------------------- /model_lib/ControlNet/annotator/uniformer/mmcv/fileio/handlers/pickle_handler.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) OpenMMLab. All rights reserved. 2 | import pickle 3 | 4 | from .base import BaseFileHandler 5 | 6 | 7 | class PickleHandler(BaseFileHandler): 8 | 9 | str_like = False 10 | 11 | def load_from_fileobj(self, file, **kwargs): 12 | return pickle.load(file, **kwargs) 13 | 14 | def load_from_path(self, filepath, **kwargs): 15 | return super(PickleHandler, self).load_from_path( 16 | filepath, mode='rb', **kwargs) 17 | 18 | def dump_to_str(self, obj, **kwargs): 19 | kwargs.setdefault('protocol', 2) 20 | return pickle.dumps(obj, **kwargs) 21 | 22 | def dump_to_fileobj(self, obj, file, **kwargs): 23 | kwargs.setdefault('protocol', 2) 24 | pickle.dump(obj, file, **kwargs) 25 | 26 | def dump_to_path(self, obj, filepath, **kwargs): 27 | super(PickleHandler, self).dump_to_path( 28 | obj, filepath, mode='wb', **kwargs) 29 | -------------------------------------------------------------------------------- /model_lib/ControlNet/annotator/uniformer/mmcv/fileio/handlers/yaml_handler.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) OpenMMLab. All rights reserved. 2 | import yaml 3 | 4 | try: 5 | from yaml import CLoader as Loader, CDumper as Dumper 6 | except ImportError: 7 | from yaml import Loader, Dumper 8 | 9 | from .base import BaseFileHandler # isort:skip 10 | 11 | 12 | class YamlHandler(BaseFileHandler): 13 | 14 | def load_from_fileobj(self, file, **kwargs): 15 | kwargs.setdefault('Loader', Loader) 16 | return yaml.load(file, **kwargs) 17 | 18 | def dump_to_fileobj(self, obj, file, **kwargs): 19 | kwargs.setdefault('Dumper', Dumper) 20 | yaml.dump(obj, file, **kwargs) 21 | 22 | def dump_to_str(self, obj, **kwargs): 23 | kwargs.setdefault('Dumper', Dumper) 24 | return yaml.dump(obj, **kwargs) 25 | -------------------------------------------------------------------------------- /model_lib/ControlNet/annotator/uniformer/mmcv/model_zoo/deprecated.json: -------------------------------------------------------------------------------- 1 | { 2 | "resnet50_caffe": "detectron/resnet50_caffe", 3 | "resnet50_caffe_bgr": "detectron2/resnet50_caffe_bgr", 4 | "resnet101_caffe": "detectron/resnet101_caffe", 5 | "resnet101_caffe_bgr": "detectron2/resnet101_caffe_bgr" 6 | } 7 | -------------------------------------------------------------------------------- /model_lib/ControlNet/annotator/uniformer/mmcv/ops/info.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) OpenMMLab. All rights reserved. 2 | import glob 3 | import os 4 | 5 | import torch 6 | 7 | if torch.__version__ == 'parrots': 8 | import parrots 9 | 10 | def get_compiler_version(): 11 | return 'GCC ' + parrots.version.compiler 12 | 13 | def get_compiling_cuda_version(): 14 | return parrots.version.cuda 15 | else: 16 | from ..utils import ext_loader 17 | ext_module = ext_loader.load_ext( 18 | '_ext', ['get_compiler_version', 'get_compiling_cuda_version']) 19 | 20 | def get_compiler_version(): 21 | return ext_module.get_compiler_version() 22 | 23 | def get_compiling_cuda_version(): 24 | return ext_module.get_compiling_cuda_version() 25 | 26 | 27 | def get_onnxruntime_op_path(): 28 | wildcard = os.path.join( 29 | os.path.abspath(os.path.dirname(os.path.dirname(__file__))), 30 | '_ext_ort.*.so') 31 | 32 | paths = glob.glob(wildcard) 33 | if len(paths) > 0: 34 | return paths[0] 35 | else: 36 | return '' 37 | -------------------------------------------------------------------------------- /model_lib/ControlNet/annotator/uniformer/mmcv/parallel/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) OpenMMLab. All rights reserved. 2 | from .collate import collate 3 | from .data_container import DataContainer 4 | from .data_parallel import MMDataParallel 5 | from .distributed import MMDistributedDataParallel 6 | from .registry import MODULE_WRAPPERS 7 | from .scatter_gather import scatter, scatter_kwargs 8 | from .utils import is_module_wrapper 9 | 10 | __all__ = [ 11 | 'collate', 'DataContainer', 'MMDataParallel', 'MMDistributedDataParallel', 12 | 'scatter', 'scatter_kwargs', 'is_module_wrapper', 'MODULE_WRAPPERS' 13 | ] 14 | -------------------------------------------------------------------------------- /model_lib/ControlNet/annotator/uniformer/mmcv/parallel/registry.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) OpenMMLab. All rights reserved. 2 | from torch.nn.parallel import DataParallel, DistributedDataParallel 3 | 4 | from annotator.uniformer.mmcv.utils import Registry 5 | 6 | MODULE_WRAPPERS = Registry('module wrapper') 7 | MODULE_WRAPPERS.register_module(module=DataParallel) 8 | MODULE_WRAPPERS.register_module(module=DistributedDataParallel) 9 | -------------------------------------------------------------------------------- /model_lib/ControlNet/annotator/uniformer/mmcv/parallel/utils.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) OpenMMLab. All rights reserved. 2 | from .registry import MODULE_WRAPPERS 3 | 4 | 5 | def is_module_wrapper(module): 6 | """Check if a module is a module wrapper. 7 | 8 | The following 3 modules in MMCV (and their subclasses) are regarded as 9 | module wrappers: DataParallel, DistributedDataParallel, 10 | MMDistributedDataParallel (the deprecated version). You may add you own 11 | module wrapper by registering it to mmcv.parallel.MODULE_WRAPPERS. 12 | 13 | Args: 14 | module (nn.Module): The module to be checked. 15 | 16 | Returns: 17 | bool: True if the input module is a module wrapper. 18 | """ 19 | module_wrappers = tuple(MODULE_WRAPPERS.module_dict.values()) 20 | return isinstance(module, module_wrappers) 21 | -------------------------------------------------------------------------------- /model_lib/ControlNet/annotator/uniformer/mmcv/runner/builder.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) OpenMMLab. All rights reserved. 2 | import copy 3 | 4 | from ..utils import Registry 5 | 6 | RUNNERS = Registry('runner') 7 | RUNNER_BUILDERS = Registry('runner builder') 8 | 9 | 10 | def build_runner_constructor(cfg): 11 | return RUNNER_BUILDERS.build(cfg) 12 | 13 | 14 | def build_runner(cfg, default_args=None): 15 | runner_cfg = copy.deepcopy(cfg) 16 | constructor_type = runner_cfg.pop('constructor', 17 | 'DefaultRunnerConstructor') 18 | runner_constructor = build_runner_constructor( 19 | dict( 20 | type=constructor_type, 21 | runner_cfg=runner_cfg, 22 | default_args=default_args)) 23 | runner = runner_constructor() 24 | return runner 25 | -------------------------------------------------------------------------------- /model_lib/ControlNet/annotator/uniformer/mmcv/runner/hooks/closure.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) OpenMMLab. All rights reserved. 2 | from .hook import HOOKS, Hook 3 | 4 | 5 | @HOOKS.register_module() 6 | class ClosureHook(Hook): 7 | 8 | def __init__(self, fn_name, fn): 9 | assert hasattr(self, fn_name) 10 | assert callable(fn) 11 | setattr(self, fn_name, fn) 12 | -------------------------------------------------------------------------------- /model_lib/ControlNet/annotator/uniformer/mmcv/runner/hooks/iter_timer.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) OpenMMLab. All rights reserved. 2 | import time 3 | 4 | from .hook import HOOKS, Hook 5 | 6 | 7 | @HOOKS.register_module() 8 | class IterTimerHook(Hook): 9 | 10 | def before_epoch(self, runner): 11 | self.t = time.time() 12 | 13 | def before_iter(self, runner): 14 | runner.log_buffer.update({'data_time': time.time() - self.t}) 15 | 16 | def after_iter(self, runner): 17 | runner.log_buffer.update({'time': time.time() - self.t}) 18 | self.t = time.time() 19 | -------------------------------------------------------------------------------- /model_lib/ControlNet/annotator/uniformer/mmcv/runner/hooks/logger/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) OpenMMLab. All rights reserved. 2 | from .base import LoggerHook 3 | from .dvclive import DvcliveLoggerHook 4 | from .mlflow import MlflowLoggerHook 5 | from .neptune import NeptuneLoggerHook 6 | from .pavi import PaviLoggerHook 7 | from .tensorboard import TensorboardLoggerHook 8 | from .text import TextLoggerHook 9 | from .wandb import WandbLoggerHook 10 | 11 | __all__ = [ 12 | 'LoggerHook', 'MlflowLoggerHook', 'PaviLoggerHook', 13 | 'TensorboardLoggerHook', 'TextLoggerHook', 'WandbLoggerHook', 14 | 'NeptuneLoggerHook', 'DvcliveLoggerHook' 15 | ] 16 | -------------------------------------------------------------------------------- /model_lib/ControlNet/annotator/uniformer/mmcv/runner/hooks/memory.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) OpenMMLab. All rights reserved. 2 | import torch 3 | 4 | from .hook import HOOKS, Hook 5 | 6 | 7 | @HOOKS.register_module() 8 | class EmptyCacheHook(Hook): 9 | 10 | def __init__(self, before_epoch=False, after_epoch=True, after_iter=False): 11 | self._before_epoch = before_epoch 12 | self._after_epoch = after_epoch 13 | self._after_iter = after_iter 14 | 15 | def after_iter(self, runner): 16 | if self._after_iter: 17 | torch.cuda.empty_cache() 18 | 19 | def before_epoch(self, runner): 20 | if self._before_epoch: 21 | torch.cuda.empty_cache() 22 | 23 | def after_epoch(self, runner): 24 | if self._after_epoch: 25 | torch.cuda.empty_cache() 26 | -------------------------------------------------------------------------------- /model_lib/ControlNet/annotator/uniformer/mmcv/runner/hooks/sampler_seed.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) OpenMMLab. All rights reserved. 2 | from .hook import HOOKS, Hook 3 | 4 | 5 | @HOOKS.register_module() 6 | class DistSamplerSeedHook(Hook): 7 | """Data-loading sampler for distributed training. 8 | 9 | When distributed training, it is only useful in conjunction with 10 | :obj:`EpochBasedRunner`, while :obj:`IterBasedRunner` achieves the same 11 | purpose with :obj:`IterLoader`. 12 | """ 13 | 14 | def before_epoch(self, runner): 15 | if hasattr(runner.data_loader.sampler, 'set_epoch'): 16 | # in case the data loader uses `SequentialSampler` in Pytorch 17 | runner.data_loader.sampler.set_epoch(runner.epoch) 18 | elif hasattr(runner.data_loader.batch_sampler.sampler, 'set_epoch'): 19 | # batch sampler in pytorch warps the sampler as its attributes. 20 | runner.data_loader.batch_sampler.sampler.set_epoch(runner.epoch) 21 | -------------------------------------------------------------------------------- /model_lib/ControlNet/annotator/uniformer/mmcv/runner/hooks/sync_buffer.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) OpenMMLab. All rights reserved. 2 | from ..dist_utils import allreduce_params 3 | from .hook import HOOKS, Hook 4 | 5 | 6 | @HOOKS.register_module() 7 | class SyncBuffersHook(Hook): 8 | """Synchronize model buffers such as running_mean and running_var in BN at 9 | the end of each epoch. 10 | 11 | Args: 12 | distributed (bool): Whether distributed training is used. It is 13 | effective only for distributed training. Defaults to True. 14 | """ 15 | 16 | def __init__(self, distributed=True): 17 | self.distributed = distributed 18 | 19 | def after_epoch(self, runner): 20 | """All-reduce model buffers at the end of each epoch.""" 21 | if self.distributed: 22 | allreduce_params(runner.model.buffers()) 23 | -------------------------------------------------------------------------------- /model_lib/ControlNet/annotator/uniformer/mmcv/runner/log_buffer.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) OpenMMLab. All rights reserved. 2 | from collections import OrderedDict 3 | 4 | import numpy as np 5 | 6 | 7 | class LogBuffer: 8 | 9 | def __init__(self): 10 | self.val_history = OrderedDict() 11 | self.n_history = OrderedDict() 12 | self.output = OrderedDict() 13 | self.ready = False 14 | 15 | def clear(self): 16 | self.val_history.clear() 17 | self.n_history.clear() 18 | self.clear_output() 19 | 20 | def clear_output(self): 21 | self.output.clear() 22 | self.ready = False 23 | 24 | def update(self, vars, count=1): 25 | assert isinstance(vars, dict) 26 | for key, var in vars.items(): 27 | if key not in self.val_history: 28 | self.val_history[key] = [] 29 | self.n_history[key] = [] 30 | self.val_history[key].append(var) 31 | self.n_history[key].append(count) 32 | 33 | def average(self, n=0): 34 | """Average latest n values or all values.""" 35 | assert n >= 0 36 | for key in self.val_history: 37 | values = np.array(self.val_history[key][-n:]) 38 | nums = np.array(self.n_history[key][-n:]) 39 | avg = np.sum(values * nums) / np.sum(nums) 40 | self.output[key] = avg 41 | self.ready = True 42 | -------------------------------------------------------------------------------- /model_lib/ControlNet/annotator/uniformer/mmcv/runner/optimizer/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) OpenMMLab. All rights reserved. 2 | from .builder import (OPTIMIZER_BUILDERS, OPTIMIZERS, build_optimizer, 3 | build_optimizer_constructor) 4 | from .default_constructor import DefaultOptimizerConstructor 5 | 6 | __all__ = [ 7 | 'OPTIMIZER_BUILDERS', 'OPTIMIZERS', 'DefaultOptimizerConstructor', 8 | 'build_optimizer', 'build_optimizer_constructor' 9 | ] 10 | -------------------------------------------------------------------------------- /model_lib/ControlNet/annotator/uniformer/mmcv/utils/parrots_jit.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) OpenMMLab. All rights reserved. 2 | import os 3 | 4 | from .parrots_wrapper import TORCH_VERSION 5 | 6 | parrots_jit_option = os.getenv('PARROTS_JIT_OPTION') 7 | 8 | if TORCH_VERSION == 'parrots' and parrots_jit_option == 'ON': 9 | from parrots.jit import pat as jit 10 | else: 11 | 12 | def jit(func=None, 13 | check_input=None, 14 | full_shape=True, 15 | derivate=False, 16 | coderize=False, 17 | optimize=False): 18 | 19 | def wrapper(func): 20 | 21 | def wrapper_inner(*args, **kargs): 22 | return func(*args, **kargs) 23 | 24 | return wrapper_inner 25 | 26 | if func is None: 27 | return wrapper 28 | else: 29 | return func 30 | 31 | 32 | if TORCH_VERSION == 'parrots': 33 | from parrots.utils.tester import skip_no_elena 34 | else: 35 | 36 | def skip_no_elena(func): 37 | 38 | def wrapper(*args, **kargs): 39 | return func(*args, **kargs) 40 | 41 | return wrapper 42 | -------------------------------------------------------------------------------- /model_lib/ControlNet/annotator/uniformer/mmcv/utils/trace.py: -------------------------------------------------------------------------------- 1 | import warnings 2 | 3 | import torch 4 | 5 | from annotator.uniformer.mmcv.utils import digit_version 6 | 7 | 8 | def is_jit_tracing() -> bool: 9 | if (torch.__version__ != 'parrots' 10 | and digit_version(torch.__version__) >= digit_version('1.6.0')): 11 | on_trace = torch.jit.is_tracing() 12 | # In PyTorch 1.6, torch.jit.is_tracing has a bug. 13 | # Refers to https://github.com/pytorch/pytorch/issues/42448 14 | if isinstance(on_trace, bool): 15 | return on_trace 16 | else: 17 | return torch._C._is_tracing() 18 | else: 19 | warnings.warn( 20 | 'torch.jit.is_tracing is only supported after v1.6.0. ' 21 | 'Therefore is_tracing returns False automatically. Please ' 22 | 'set on_trace manually if you are using trace.', UserWarning) 23 | return False 24 | -------------------------------------------------------------------------------- /model_lib/ControlNet/annotator/uniformer/mmcv/version.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) OpenMMLab. All rights reserved. 2 | __version__ = '1.3.17' 3 | 4 | 5 | def parse_version_info(version_str: str, length: int = 4) -> tuple: 6 | """Parse a version string into a tuple. 7 | 8 | Args: 9 | version_str (str): The version string. 10 | length (int): The maximum number of version levels. Default: 4. 11 | 12 | Returns: 13 | tuple[int | str]: The version info, e.g., "1.3.0" is parsed into 14 | (1, 3, 0, 0, 0, 0), and "2.0.0rc1" is parsed into 15 | (2, 0, 0, 0, 'rc', 1) (when length is set to 4). 16 | """ 17 | from packaging.version import parse 18 | version = parse(version_str) 19 | assert version.release, f'failed to parse version {version_str}' 20 | release = list(version.release) 21 | release = release[:length] 22 | if len(release) < length: 23 | release = release + [0] * (length - len(release)) 24 | if version.is_prerelease: 25 | release.extend(list(version.pre)) 26 | elif version.is_postrelease: 27 | release.extend(list(version.post)) 28 | else: 29 | release.extend([0, 0]) 30 | return tuple(release) 31 | 32 | 33 | version_info = tuple(int(x) for x in __version__.split('.')[:3]) 34 | 35 | __all__ = ['__version__', 'version_info', 'parse_version_info'] 36 | -------------------------------------------------------------------------------- /model_lib/ControlNet/annotator/uniformer/mmcv/video/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) OpenMMLab. All rights reserved. 2 | from .io import Cache, VideoReader, frames2video 3 | from .optflow import (dequantize_flow, flow_from_bytes, flow_warp, flowread, 4 | flowwrite, quantize_flow, sparse_flow_from_bytes) 5 | from .processing import concat_video, convert_video, cut_video, resize_video 6 | 7 | __all__ = [ 8 | 'Cache', 'VideoReader', 'frames2video', 'convert_video', 'resize_video', 9 | 'cut_video', 'concat_video', 'flowread', 'flowwrite', 'quantize_flow', 10 | 'dequantize_flow', 'flow_warp', 'flow_from_bytes', 'sparse_flow_from_bytes' 11 | ] 12 | -------------------------------------------------------------------------------- /model_lib/ControlNet/annotator/uniformer/mmcv/visualization/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) OpenMMLab. All rights reserved. 2 | from .color import Color, color_val 3 | from .image import imshow, imshow_bboxes, imshow_det_bboxes 4 | from .optflow import flow2rgb, flowshow, make_color_wheel 5 | 6 | __all__ = [ 7 | 'Color', 'color_val', 'imshow', 'imshow_bboxes', 'imshow_det_bboxes', 8 | 'flowshow', 'flow2rgb', 'make_color_wheel' 9 | ] 10 | -------------------------------------------------------------------------------- /model_lib/ControlNet/annotator/uniformer/mmcv_custom/__init__.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | 3 | from .checkpoint import load_checkpoint 4 | 5 | __all__ = ['load_checkpoint'] -------------------------------------------------------------------------------- /model_lib/ControlNet/annotator/uniformer/mmseg/apis/__init__.py: -------------------------------------------------------------------------------- 1 | from .inference import inference_segmentor, init_segmentor, show_result_pyplot 2 | from .test import multi_gpu_test, single_gpu_test 3 | from .train import get_root_logger, set_random_seed, train_segmentor 4 | 5 | __all__ = [ 6 | 'get_root_logger', 'set_random_seed', 'train_segmentor', 'init_segmentor', 7 | 'inference_segmentor', 'multi_gpu_test', 'single_gpu_test', 8 | 'show_result_pyplot' 9 | ] 10 | -------------------------------------------------------------------------------- /model_lib/ControlNet/annotator/uniformer/mmseg/core/__init__.py: -------------------------------------------------------------------------------- 1 | from .evaluation import * # noqa: F401, F403 2 | from .seg import * # noqa: F401, F403 3 | from .utils import * # noqa: F401, F403 4 | -------------------------------------------------------------------------------- /model_lib/ControlNet/annotator/uniformer/mmseg/core/evaluation/__init__.py: -------------------------------------------------------------------------------- 1 | from .class_names import get_classes, get_palette 2 | from .eval_hooks import DistEvalHook, EvalHook 3 | from .metrics import eval_metrics, mean_dice, mean_fscore, mean_iou 4 | 5 | __all__ = [ 6 | 'EvalHook', 'DistEvalHook', 'mean_dice', 'mean_iou', 'mean_fscore', 7 | 'eval_metrics', 'get_classes', 'get_palette' 8 | ] 9 | -------------------------------------------------------------------------------- /model_lib/ControlNet/annotator/uniformer/mmseg/core/seg/__init__.py: -------------------------------------------------------------------------------- 1 | from .builder import build_pixel_sampler 2 | from .sampler import BasePixelSampler, OHEMPixelSampler 3 | 4 | __all__ = ['build_pixel_sampler', 'BasePixelSampler', 'OHEMPixelSampler'] 5 | -------------------------------------------------------------------------------- /model_lib/ControlNet/annotator/uniformer/mmseg/core/seg/builder.py: -------------------------------------------------------------------------------- 1 | from annotator.uniformer.mmcv.utils import Registry, build_from_cfg 2 | 3 | PIXEL_SAMPLERS = Registry('pixel sampler') 4 | 5 | 6 | def build_pixel_sampler(cfg, **default_args): 7 | """Build pixel sampler for segmentation map.""" 8 | return build_from_cfg(cfg, PIXEL_SAMPLERS, default_args) 9 | -------------------------------------------------------------------------------- /model_lib/ControlNet/annotator/uniformer/mmseg/core/seg/sampler/__init__.py: -------------------------------------------------------------------------------- 1 | from .base_pixel_sampler import BasePixelSampler 2 | from .ohem_pixel_sampler import OHEMPixelSampler 3 | 4 | __all__ = ['BasePixelSampler', 'OHEMPixelSampler'] 5 | -------------------------------------------------------------------------------- /model_lib/ControlNet/annotator/uniformer/mmseg/core/seg/sampler/base_pixel_sampler.py: -------------------------------------------------------------------------------- 1 | from abc import ABCMeta, abstractmethod 2 | 3 | 4 | class BasePixelSampler(metaclass=ABCMeta): 5 | """Base class of pixel sampler.""" 6 | 7 | def __init__(self, **kwargs): 8 | pass 9 | 10 | @abstractmethod 11 | def sample(self, seg_logit, seg_label): 12 | """Placeholder for sample function.""" 13 | -------------------------------------------------------------------------------- /model_lib/ControlNet/annotator/uniformer/mmseg/core/utils/__init__.py: -------------------------------------------------------------------------------- 1 | from .misc import add_prefix 2 | 3 | __all__ = ['add_prefix'] 4 | -------------------------------------------------------------------------------- /model_lib/ControlNet/annotator/uniformer/mmseg/core/utils/misc.py: -------------------------------------------------------------------------------- 1 | def add_prefix(inputs, prefix): 2 | """Add prefix for dict. 3 | 4 | Args: 5 | inputs (dict): The input dict with str keys. 6 | prefix (str): The prefix to add. 7 | 8 | Returns: 9 | 10 | dict: The dict with keys updated with ``prefix``. 11 | """ 12 | 13 | outputs = dict() 14 | for name, value in inputs.items(): 15 | outputs[f'{prefix}.{name}'] = value 16 | 17 | return outputs 18 | -------------------------------------------------------------------------------- /model_lib/ControlNet/annotator/uniformer/mmseg/datasets/__init__.py: -------------------------------------------------------------------------------- 1 | from .ade import ADE20KDataset 2 | from .builder import DATASETS, PIPELINES, build_dataloader, build_dataset 3 | from .chase_db1 import ChaseDB1Dataset 4 | from .cityscapes import CityscapesDataset 5 | from .custom import CustomDataset 6 | from .dataset_wrappers import ConcatDataset, RepeatDataset 7 | from .drive import DRIVEDataset 8 | from .hrf import HRFDataset 9 | from .pascal_context import PascalContextDataset, PascalContextDataset59 10 | from .stare import STAREDataset 11 | from .voc import PascalVOCDataset 12 | 13 | __all__ = [ 14 | 'CustomDataset', 'build_dataloader', 'ConcatDataset', 'RepeatDataset', 15 | 'DATASETS', 'build_dataset', 'PIPELINES', 'CityscapesDataset', 16 | 'PascalVOCDataset', 'ADE20KDataset', 'PascalContextDataset', 17 | 'PascalContextDataset59', 'ChaseDB1Dataset', 'DRIVEDataset', 'HRFDataset', 18 | 'STAREDataset' 19 | ] 20 | -------------------------------------------------------------------------------- /model_lib/ControlNet/annotator/uniformer/mmseg/datasets/chase_db1.py: -------------------------------------------------------------------------------- 1 | import os.path as osp 2 | 3 | from .builder import DATASETS 4 | from .custom import CustomDataset 5 | 6 | 7 | @DATASETS.register_module() 8 | class ChaseDB1Dataset(CustomDataset): 9 | """Chase_db1 dataset. 10 | 11 | In segmentation map annotation for Chase_db1, 0 stands for background, 12 | which is included in 2 categories. ``reduce_zero_label`` is fixed to False. 13 | The ``img_suffix`` is fixed to '.png' and ``seg_map_suffix`` is fixed to 14 | '_1stHO.png'. 15 | """ 16 | 17 | CLASSES = ('background', 'vessel') 18 | 19 | PALETTE = [[120, 120, 120], [6, 230, 230]] 20 | 21 | def __init__(self, **kwargs): 22 | super(ChaseDB1Dataset, self).__init__( 23 | img_suffix='.png', 24 | seg_map_suffix='_1stHO.png', 25 | reduce_zero_label=False, 26 | **kwargs) 27 | assert osp.exists(self.img_dir) 28 | -------------------------------------------------------------------------------- /model_lib/ControlNet/annotator/uniformer/mmseg/datasets/drive.py: -------------------------------------------------------------------------------- 1 | import os.path as osp 2 | 3 | from .builder import DATASETS 4 | from .custom import CustomDataset 5 | 6 | 7 | @DATASETS.register_module() 8 | class DRIVEDataset(CustomDataset): 9 | """DRIVE dataset. 10 | 11 | In segmentation map annotation for DRIVE, 0 stands for background, which is 12 | included in 2 categories. ``reduce_zero_label`` is fixed to False. The 13 | ``img_suffix`` is fixed to '.png' and ``seg_map_suffix`` is fixed to 14 | '_manual1.png'. 15 | """ 16 | 17 | CLASSES = ('background', 'vessel') 18 | 19 | PALETTE = [[120, 120, 120], [6, 230, 230]] 20 | 21 | def __init__(self, **kwargs): 22 | super(DRIVEDataset, self).__init__( 23 | img_suffix='.png', 24 | seg_map_suffix='_manual1.png', 25 | reduce_zero_label=False, 26 | **kwargs) 27 | assert osp.exists(self.img_dir) 28 | -------------------------------------------------------------------------------- /model_lib/ControlNet/annotator/uniformer/mmseg/datasets/hrf.py: -------------------------------------------------------------------------------- 1 | import os.path as osp 2 | 3 | from .builder import DATASETS 4 | from .custom import CustomDataset 5 | 6 | 7 | @DATASETS.register_module() 8 | class HRFDataset(CustomDataset): 9 | """HRF dataset. 10 | 11 | In segmentation map annotation for HRF, 0 stands for background, which is 12 | included in 2 categories. ``reduce_zero_label`` is fixed to False. The 13 | ``img_suffix`` is fixed to '.png' and ``seg_map_suffix`` is fixed to 14 | '.png'. 15 | """ 16 | 17 | CLASSES = ('background', 'vessel') 18 | 19 | PALETTE = [[120, 120, 120], [6, 230, 230]] 20 | 21 | def __init__(self, **kwargs): 22 | super(HRFDataset, self).__init__( 23 | img_suffix='.png', 24 | seg_map_suffix='.png', 25 | reduce_zero_label=False, 26 | **kwargs) 27 | assert osp.exists(self.img_dir) 28 | -------------------------------------------------------------------------------- /model_lib/ControlNet/annotator/uniformer/mmseg/datasets/pipelines/__init__.py: -------------------------------------------------------------------------------- 1 | from .compose import Compose 2 | from .formating import (Collect, ImageToTensor, ToDataContainer, ToTensor, 3 | Transpose, to_tensor) 4 | from .loading import LoadAnnotations, LoadImageFromFile 5 | from .test_time_aug import MultiScaleFlipAug 6 | from .transforms import (CLAHE, AdjustGamma, Normalize, Pad, 7 | PhotoMetricDistortion, RandomCrop, RandomFlip, 8 | RandomRotate, Rerange, Resize, RGB2Gray, SegRescale) 9 | 10 | __all__ = [ 11 | 'Compose', 'to_tensor', 'ToTensor', 'ImageToTensor', 'ToDataContainer', 12 | 'Transpose', 'Collect', 'LoadAnnotations', 'LoadImageFromFile', 13 | 'MultiScaleFlipAug', 'Resize', 'RandomFlip', 'Pad', 'RandomCrop', 14 | 'Normalize', 'SegRescale', 'PhotoMetricDistortion', 'RandomRotate', 15 | 'AdjustGamma', 'CLAHE', 'Rerange', 'RGB2Gray' 16 | ] 17 | -------------------------------------------------------------------------------- /model_lib/ControlNet/annotator/uniformer/mmseg/datasets/stare.py: -------------------------------------------------------------------------------- 1 | import os.path as osp 2 | 3 | from .builder import DATASETS 4 | from .custom import CustomDataset 5 | 6 | 7 | @DATASETS.register_module() 8 | class STAREDataset(CustomDataset): 9 | """STARE dataset. 10 | 11 | In segmentation map annotation for STARE, 0 stands for background, which is 12 | included in 2 categories. ``reduce_zero_label`` is fixed to False. The 13 | ``img_suffix`` is fixed to '.png' and ``seg_map_suffix`` is fixed to 14 | '.ah.png'. 15 | """ 16 | 17 | CLASSES = ('background', 'vessel') 18 | 19 | PALETTE = [[120, 120, 120], [6, 230, 230]] 20 | 21 | def __init__(self, **kwargs): 22 | super(STAREDataset, self).__init__( 23 | img_suffix='.png', 24 | seg_map_suffix='.ah.png', 25 | reduce_zero_label=False, 26 | **kwargs) 27 | assert osp.exists(self.img_dir) 28 | -------------------------------------------------------------------------------- /model_lib/ControlNet/annotator/uniformer/mmseg/datasets/voc.py: -------------------------------------------------------------------------------- 1 | import os.path as osp 2 | 3 | from .builder import DATASETS 4 | from .custom import CustomDataset 5 | 6 | 7 | @DATASETS.register_module() 8 | class PascalVOCDataset(CustomDataset): 9 | """Pascal VOC dataset. 10 | 11 | Args: 12 | split (str): Split txt file for Pascal VOC. 13 | """ 14 | 15 | CLASSES = ('background', 'aeroplane', 'bicycle', 'bird', 'boat', 'bottle', 16 | 'bus', 'car', 'cat', 'chair', 'cow', 'diningtable', 'dog', 17 | 'horse', 'motorbike', 'person', 'pottedplant', 'sheep', 'sofa', 18 | 'train', 'tvmonitor') 19 | 20 | PALETTE = [[0, 0, 0], [128, 0, 0], [0, 128, 0], [128, 128, 0], [0, 0, 128], 21 | [128, 0, 128], [0, 128, 128], [128, 128, 128], [64, 0, 0], 22 | [192, 0, 0], [64, 128, 0], [192, 128, 0], [64, 0, 128], 23 | [192, 0, 128], [64, 128, 128], [192, 128, 128], [0, 64, 0], 24 | [128, 64, 0], [0, 192, 0], [128, 192, 0], [0, 64, 128]] 25 | 26 | def __init__(self, split, **kwargs): 27 | super(PascalVOCDataset, self).__init__( 28 | img_suffix='.jpg', seg_map_suffix='.png', split=split, **kwargs) 29 | assert osp.exists(self.img_dir) and self.split is not None 30 | -------------------------------------------------------------------------------- /model_lib/ControlNet/annotator/uniformer/mmseg/models/__init__.py: -------------------------------------------------------------------------------- 1 | from .backbones import * # noqa: F401,F403 2 | from .builder import (BACKBONES, HEADS, LOSSES, SEGMENTORS, build_backbone, 3 | build_head, build_loss, build_segmentor) 4 | from .decode_heads import * # noqa: F401,F403 5 | from .losses import * # noqa: F401,F403 6 | from .necks import * # noqa: F401,F403 7 | from .segmentors import * # noqa: F401,F403 8 | 9 | __all__ = [ 10 | 'BACKBONES', 'HEADS', 'LOSSES', 'SEGMENTORS', 'build_backbone', 11 | 'build_head', 'build_loss', 'build_segmentor' 12 | ] 13 | -------------------------------------------------------------------------------- /model_lib/ControlNet/annotator/uniformer/mmseg/models/backbones/__init__.py: -------------------------------------------------------------------------------- 1 | from .cgnet import CGNet 2 | # from .fast_scnn import FastSCNN 3 | from .hrnet import HRNet 4 | from .mobilenet_v2 import MobileNetV2 5 | from .mobilenet_v3 import MobileNetV3 6 | from .resnest import ResNeSt 7 | from .resnet import ResNet, ResNetV1c, ResNetV1d 8 | from .resnext import ResNeXt 9 | from .unet import UNet 10 | from .vit import VisionTransformer 11 | from .uniformer import UniFormer 12 | 13 | __all__ = [ 14 | 'ResNet', 'ResNetV1c', 'ResNetV1d', 'ResNeXt', 'HRNet', 15 | 'ResNeSt', 'MobileNetV2', 'UNet', 'CGNet', 'MobileNetV3', 16 | 'VisionTransformer', 'UniFormer' 17 | ] 18 | -------------------------------------------------------------------------------- /model_lib/ControlNet/annotator/uniformer/mmseg/models/builder.py: -------------------------------------------------------------------------------- 1 | import warnings 2 | 3 | from annotator.uniformer.mmcv.cnn import MODELS as MMCV_MODELS 4 | from annotator.uniformer.mmcv.utils import Registry 5 | 6 | MODELS = Registry('models', parent=MMCV_MODELS) 7 | 8 | BACKBONES = MODELS 9 | NECKS = MODELS 10 | HEADS = MODELS 11 | LOSSES = MODELS 12 | SEGMENTORS = MODELS 13 | 14 | 15 | def build_backbone(cfg): 16 | """Build backbone.""" 17 | return BACKBONES.build(cfg) 18 | 19 | 20 | def build_neck(cfg): 21 | """Build neck.""" 22 | return NECKS.build(cfg) 23 | 24 | 25 | def build_head(cfg): 26 | """Build head.""" 27 | return HEADS.build(cfg) 28 | 29 | 30 | def build_loss(cfg): 31 | """Build loss.""" 32 | return LOSSES.build(cfg) 33 | 34 | 35 | def build_segmentor(cfg, train_cfg=None, test_cfg=None): 36 | """Build segmentor.""" 37 | if train_cfg is not None or test_cfg is not None: 38 | warnings.warn( 39 | 'train_cfg and test_cfg is deprecated, ' 40 | 'please specify them in model', UserWarning) 41 | assert cfg.get('train_cfg') is None or train_cfg is None, \ 42 | 'train_cfg specified in both outer field and model field ' 43 | assert cfg.get('test_cfg') is None or test_cfg is None, \ 44 | 'test_cfg specified in both outer field and model field ' 45 | return SEGMENTORS.build( 46 | cfg, default_args=dict(train_cfg=train_cfg, test_cfg=test_cfg)) 47 | -------------------------------------------------------------------------------- /model_lib/ControlNet/annotator/uniformer/mmseg/models/decode_heads/__init__.py: -------------------------------------------------------------------------------- 1 | from .ann_head import ANNHead 2 | from .apc_head import APCHead 3 | from .aspp_head import ASPPHead 4 | from .cc_head import CCHead 5 | from .da_head import DAHead 6 | from .dm_head import DMHead 7 | from .dnl_head import DNLHead 8 | from .ema_head import EMAHead 9 | from .enc_head import EncHead 10 | from .fcn_head import FCNHead 11 | from .fpn_head import FPNHead 12 | from .gc_head import GCHead 13 | from .lraspp_head import LRASPPHead 14 | from .nl_head import NLHead 15 | from .ocr_head import OCRHead 16 | # from .point_head import PointHead 17 | from .psa_head import PSAHead 18 | from .psp_head import PSPHead 19 | from .sep_aspp_head import DepthwiseSeparableASPPHead 20 | from .sep_fcn_head import DepthwiseSeparableFCNHead 21 | from .uper_head import UPerHead 22 | 23 | __all__ = [ 24 | 'FCNHead', 'PSPHead', 'ASPPHead', 'PSAHead', 'NLHead', 'GCHead', 'CCHead', 25 | 'UPerHead', 'DepthwiseSeparableASPPHead', 'ANNHead', 'DAHead', 'OCRHead', 26 | 'EncHead', 'DepthwiseSeparableFCNHead', 'FPNHead', 'EMAHead', 'DNLHead', 27 | 'APCHead', 'DMHead', 'LRASPPHead' 28 | ] 29 | -------------------------------------------------------------------------------- /model_lib/ControlNet/annotator/uniformer/mmseg/models/decode_heads/cc_head.py: -------------------------------------------------------------------------------- 1 | import torch 2 | 3 | from ..builder import HEADS 4 | from .fcn_head import FCNHead 5 | 6 | try: 7 | from annotator.uniformer.mmcv.ops import CrissCrossAttention 8 | except ModuleNotFoundError: 9 | CrissCrossAttention = None 10 | 11 | 12 | @HEADS.register_module() 13 | class CCHead(FCNHead): 14 | """CCNet: Criss-Cross Attention for Semantic Segmentation. 15 | 16 | This head is the implementation of `CCNet 17 | `_. 18 | 19 | Args: 20 | recurrence (int): Number of recurrence of Criss Cross Attention 21 | module. Default: 2. 22 | """ 23 | 24 | def __init__(self, recurrence=2, **kwargs): 25 | if CrissCrossAttention is None: 26 | raise RuntimeError('Please install mmcv-full for ' 27 | 'CrissCrossAttention ops') 28 | super(CCHead, self).__init__(num_convs=2, **kwargs) 29 | self.recurrence = recurrence 30 | self.cca = CrissCrossAttention(self.channels) 31 | 32 | def forward(self, inputs): 33 | """Forward function.""" 34 | x = self._transform_inputs(inputs) 35 | output = self.convs[0](x) 36 | for _ in range(self.recurrence): 37 | output = self.cca(output) 38 | output = self.convs[1](output) 39 | if self.concat_input: 40 | output = self.conv_cat(torch.cat([x, output], dim=1)) 41 | output = self.cls_seg(output) 42 | return output 43 | -------------------------------------------------------------------------------- /model_lib/ControlNet/annotator/uniformer/mmseg/models/losses/__init__.py: -------------------------------------------------------------------------------- 1 | from .accuracy import Accuracy, accuracy 2 | from .cross_entropy_loss import (CrossEntropyLoss, binary_cross_entropy, 3 | cross_entropy, mask_cross_entropy) 4 | from .dice_loss import DiceLoss 5 | from .lovasz_loss import LovaszLoss 6 | from .utils import reduce_loss, weight_reduce_loss, weighted_loss 7 | 8 | __all__ = [ 9 | 'accuracy', 'Accuracy', 'cross_entropy', 'binary_cross_entropy', 10 | 'mask_cross_entropy', 'CrossEntropyLoss', 'reduce_loss', 11 | 'weight_reduce_loss', 'weighted_loss', 'LovaszLoss', 'DiceLoss' 12 | ] 13 | -------------------------------------------------------------------------------- /model_lib/ControlNet/annotator/uniformer/mmseg/models/necks/__init__.py: -------------------------------------------------------------------------------- 1 | from .fpn import FPN 2 | from .multilevel_neck import MultiLevelNeck 3 | 4 | __all__ = ['FPN', 'MultiLevelNeck'] 5 | -------------------------------------------------------------------------------- /model_lib/ControlNet/annotator/uniformer/mmseg/models/segmentors/__init__.py: -------------------------------------------------------------------------------- 1 | from .base import BaseSegmentor 2 | from .cascade_encoder_decoder import CascadeEncoderDecoder 3 | from .encoder_decoder import EncoderDecoder 4 | 5 | __all__ = ['BaseSegmentor', 'EncoderDecoder', 'CascadeEncoderDecoder'] 6 | -------------------------------------------------------------------------------- /model_lib/ControlNet/annotator/uniformer/mmseg/models/utils/__init__.py: -------------------------------------------------------------------------------- 1 | from .drop import DropPath 2 | from .inverted_residual import InvertedResidual, InvertedResidualV3 3 | from .make_divisible import make_divisible 4 | from .res_layer import ResLayer 5 | from .se_layer import SELayer 6 | from .self_attention_block import SelfAttentionBlock 7 | from .up_conv_block import UpConvBlock 8 | from .weight_init import trunc_normal_ 9 | 10 | __all__ = [ 11 | 'ResLayer', 'SelfAttentionBlock', 'make_divisible', 'InvertedResidual', 12 | 'UpConvBlock', 'InvertedResidualV3', 'SELayer', 'DropPath', 'trunc_normal_' 13 | ] 14 | -------------------------------------------------------------------------------- /model_lib/ControlNet/annotator/uniformer/mmseg/models/utils/drop.py: -------------------------------------------------------------------------------- 1 | """Modified from https://github.com/rwightman/pytorch-image- 2 | models/blob/master/timm/models/layers/drop.py.""" 3 | 4 | import torch 5 | from torch import nn 6 | 7 | 8 | class DropPath(nn.Module): 9 | """Drop paths (Stochastic Depth) per sample (when applied in main path of 10 | residual blocks). 11 | 12 | Args: 13 | drop_prob (float): Drop rate for paths of model. Dropout rate has 14 | to be between 0 and 1. Default: 0. 15 | """ 16 | 17 | def __init__(self, drop_prob=0.): 18 | super(DropPath, self).__init__() 19 | self.drop_prob = drop_prob 20 | self.keep_prob = 1 - drop_prob 21 | 22 | def forward(self, x): 23 | if self.drop_prob == 0. or not self.training: 24 | return x 25 | shape = (x.shape[0], ) + (1, ) * ( 26 | x.ndim - 1) # work with diff dim tensors, not just 2D ConvNets 27 | random_tensor = self.keep_prob + torch.rand( 28 | shape, dtype=x.dtype, device=x.device) 29 | random_tensor.floor_() # binarize 30 | output = x.div(self.keep_prob) * random_tensor 31 | return output 32 | -------------------------------------------------------------------------------- /model_lib/ControlNet/annotator/uniformer/mmseg/models/utils/make_divisible.py: -------------------------------------------------------------------------------- 1 | def make_divisible(value, divisor, min_value=None, min_ratio=0.9): 2 | """Make divisible function. 3 | 4 | This function rounds the channel number to the nearest value that can be 5 | divisible by the divisor. It is taken from the original tf repo. It ensures 6 | that all layers have a channel number that is divisible by divisor. It can 7 | be seen here: https://github.com/tensorflow/models/blob/master/research/slim/nets/mobilenet/mobilenet.py # noqa 8 | 9 | Args: 10 | value (int): The original channel number. 11 | divisor (int): The divisor to fully divide the channel number. 12 | min_value (int): The minimum value of the output channel. 13 | Default: None, means that the minimum value equal to the divisor. 14 | min_ratio (float): The minimum ratio of the rounded channel number to 15 | the original channel number. Default: 0.9. 16 | 17 | Returns: 18 | int: The modified output channel number. 19 | """ 20 | 21 | if min_value is None: 22 | min_value = divisor 23 | new_value = max(min_value, int(value + divisor / 2) // divisor * divisor) 24 | # Make sure that round down does not go down by more than (1-min_ratio). 25 | if new_value < min_ratio * value: 26 | new_value += divisor 27 | return new_value 28 | -------------------------------------------------------------------------------- /model_lib/ControlNet/annotator/uniformer/mmseg/ops/__init__.py: -------------------------------------------------------------------------------- 1 | from .encoding import Encoding 2 | from .wrappers import Upsample, resize 3 | 4 | __all__ = ['Upsample', 'resize', 'Encoding'] 5 | -------------------------------------------------------------------------------- /model_lib/ControlNet/annotator/uniformer/mmseg/utils/__init__.py: -------------------------------------------------------------------------------- 1 | from .collect_env import collect_env 2 | from .logger import get_root_logger 3 | 4 | __all__ = ['get_root_logger', 'collect_env'] 5 | -------------------------------------------------------------------------------- /model_lib/ControlNet/annotator/uniformer/mmseg/utils/collect_env.py: -------------------------------------------------------------------------------- 1 | from annotator.uniformer.mmcv.utils import collect_env as collect_base_env 2 | from annotator.uniformer.mmcv.utils import get_git_hash 3 | 4 | import annotator.uniformer.mmseg as mmseg 5 | 6 | 7 | def collect_env(): 8 | """Collect the information of the running environments.""" 9 | env_info = collect_base_env() 10 | env_info['MMSegmentation'] = f'{mmseg.__version__}+{get_git_hash()[:7]}' 11 | 12 | return env_info 13 | 14 | 15 | if __name__ == '__main__': 16 | for name, val in collect_env().items(): 17 | print('{}: {}'.format(name, val)) 18 | -------------------------------------------------------------------------------- /model_lib/ControlNet/annotator/uniformer/mmseg/utils/logger.py: -------------------------------------------------------------------------------- 1 | import logging 2 | 3 | from annotator.uniformer.mmcv.utils import get_logger 4 | 5 | 6 | def get_root_logger(log_file=None, log_level=logging.INFO): 7 | """Get the root logger. 8 | 9 | The logger will be initialized if it has not been initialized. By default a 10 | StreamHandler will be added. If `log_file` is specified, a FileHandler will 11 | also be added. The name of the root logger is the top-level package name, 12 | e.g., "mmseg". 13 | 14 | Args: 15 | log_file (str | None): The log filename. If specified, a FileHandler 16 | will be added to the root logger. 17 | log_level (int): The root logger level. Note that only the process of 18 | rank 0 is affected, while other processes will set the level to 19 | "Error" and be silent most of the time. 20 | 21 | Returns: 22 | logging.Logger: The root logger. 23 | """ 24 | 25 | logger = get_logger(name='mmseg', log_file=log_file, log_level=log_level) 26 | 27 | return logger 28 | -------------------------------------------------------------------------------- /model_lib/ControlNet/annotator/util.py: -------------------------------------------------------------------------------- 1 | import random 2 | 3 | import numpy as np 4 | import cv2 5 | import os 6 | 7 | annotator_ckpts_path = os.path.join(os.path.dirname(__file__), 'ckpts') 8 | 9 | def HWC3(x): 10 | assert x.dtype == np.uint8 11 | if x.ndim == 2: 12 | x = x[:, :, None] 13 | assert x.ndim == 3 14 | H, W, C = x.shape 15 | assert C == 1 or C == 3 or C == 4 16 | if C == 3: 17 | return x 18 | if C == 1: 19 | return np.concatenate([x, x, x], axis=2) 20 | if C == 4: 21 | color = x[:, :, 0:3].astype(np.float32) 22 | alpha = x[:, :, 3:4].astype(np.float32) / 255.0 23 | y = color * alpha + 255.0 * (1.0 - alpha) 24 | y = y.clip(0, 255).astype(np.uint8) 25 | return y 26 | 27 | 28 | def resize_image(input_image, resolution): 29 | H, W, C = input_image.shape 30 | H = float(H) 31 | W = float(W) 32 | k = float(resolution) / min(H, W) 33 | H *= k 34 | W *= k 35 | H = int(np.round(H / 64.0)) * 64 36 | W = int(np.round(W / 64.0)) * 64 37 | img = cv2.resize(input_image, (W, H), interpolation=cv2.INTER_LANCZOS4 if k > 1 else cv2.INTER_AREA) 38 | return img 39 | 40 | def crop_img(image, fix_area): 41 | h, w = image.shape[:2] 42 | ratio = (h * w) / fix_area 43 | new_height = int( h / np.sqrt(ratio) ) 44 | new_width = int( w / np.sqrt(ratio) ) 45 | new_height = round(new_height/64)*64 46 | new_width = round(new_width/64)*64 47 | image=cv2.resize(image,(new_width,new_height)) 48 | return image 49 | 50 | -------------------------------------------------------------------------------- /model_lib/ControlNet/annotator/zoe/LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2022 Intelligent Systems Lab Org 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. -------------------------------------------------------------------------------- /model_lib/ControlNet/annotator/zoe/zoedepth/data/__init__.py: -------------------------------------------------------------------------------- 1 | # MIT License 2 | 3 | # Copyright (c) 2022 Intelligent Systems Lab Org 4 | 5 | # Permission is hereby granted, free of charge, to any person obtaining a copy 6 | # of this software and associated documentation files (the "Software"), to deal 7 | # in the Software without restriction, including without limitation the rights 8 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | # copies of the Software, and to permit persons to whom the Software is 10 | # furnished to do so, subject to the following conditions: 11 | 12 | # The above copyright notice and this permission notice shall be included in all 13 | # copies or substantial portions of the Software. 14 | 15 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | # SOFTWARE. 22 | 23 | # File author: Shariq Farooq Bhat 24 | 25 | -------------------------------------------------------------------------------- /model_lib/ControlNet/annotator/zoe/zoedepth/models/__init__.py: -------------------------------------------------------------------------------- 1 | # MIT License 2 | 3 | # Copyright (c) 2022 Intelligent Systems Lab Org 4 | 5 | # Permission is hereby granted, free of charge, to any person obtaining a copy 6 | # of this software and associated documentation files (the "Software"), to deal 7 | # in the Software without restriction, including without limitation the rights 8 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | # copies of the Software, and to permit persons to whom the Software is 10 | # furnished to do so, subject to the following conditions: 11 | 12 | # The above copyright notice and this permission notice shall be included in all 13 | # copies or substantial portions of the Software. 14 | 15 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | # SOFTWARE. 22 | 23 | # File author: Shariq Farooq Bhat 24 | 25 | -------------------------------------------------------------------------------- /model_lib/ControlNet/annotator/zoe/zoedepth/models/base_models/__init__.py: -------------------------------------------------------------------------------- 1 | # MIT License 2 | 3 | # Copyright (c) 2022 Intelligent Systems Lab Org 4 | 5 | # Permission is hereby granted, free of charge, to any person obtaining a copy 6 | # of this software and associated documentation files (the "Software"), to deal 7 | # in the Software without restriction, including without limitation the rights 8 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | # copies of the Software, and to permit persons to whom the Software is 10 | # furnished to do so, subject to the following conditions: 11 | 12 | # The above copyright notice and this permission notice shall be included in all 13 | # copies or substantial portions of the Software. 14 | 15 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | # SOFTWARE. 22 | 23 | # File author: Shariq Farooq Bhat 24 | 25 | -------------------------------------------------------------------------------- /model_lib/ControlNet/annotator/zoe/zoedepth/models/base_models/midas_repo/Dockerfile: -------------------------------------------------------------------------------- 1 | # enables cuda support in docker 2 | FROM nvidia/cuda:10.2-cudnn7-runtime-ubuntu18.04 3 | 4 | # install python 3.6, pip and requirements for opencv-python 5 | # (see https://github.com/NVIDIA/nvidia-docker/issues/864) 6 | RUN apt-get update && apt-get -y install \ 7 | python3 \ 8 | python3-pip \ 9 | libsm6 \ 10 | libxext6 \ 11 | libxrender-dev \ 12 | curl \ 13 | && rm -rf /var/lib/apt/lists/* 14 | 15 | # install python dependencies 16 | RUN pip3 install --upgrade pip 17 | RUN pip3 install torch~=1.8 torchvision opencv-python-headless~=3.4 timm 18 | 19 | # copy inference code 20 | WORKDIR /opt/MiDaS 21 | COPY ./midas ./midas 22 | COPY ./*.py ./ 23 | 24 | # download model weights so the docker image can be used offline 25 | RUN cd weights && {curl -OL https://github.com/isl-org/MiDaS/releases/download/v3/dpt_hybrid_384.pt; cd -; } 26 | RUN python3 run.py --model_type dpt_hybrid; exit 0 27 | 28 | # entrypoint (dont forget to mount input and output directories) 29 | CMD python3 run.py --model_type dpt_hybrid 30 | -------------------------------------------------------------------------------- /model_lib/ControlNet/annotator/zoe/zoedepth/models/base_models/midas_repo/LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2019 Intel ISL (Intel Intelligent Systems Lab) 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /model_lib/ControlNet/annotator/zoe/zoedepth/models/base_models/midas_repo/environment.yaml: -------------------------------------------------------------------------------- 1 | name: midas-py310 2 | channels: 3 | - pytorch 4 | - defaults 5 | dependencies: 6 | - nvidia::cudatoolkit=11.7 7 | - python=3.10.8 8 | - pytorch::pytorch=1.13.0 9 | - torchvision=0.14.0 10 | - pip=22.3.1 11 | - numpy=1.23.4 12 | - pip: 13 | - opencv-python==4.6.0.66 14 | - imutils==0.5.4 15 | - timm==0.6.12 16 | - einops==0.6.0 -------------------------------------------------------------------------------- /model_lib/ControlNet/annotator/zoe/zoedepth/models/base_models/midas_repo/input/.placeholder: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Boese0601/MagicDance/a515a1f4a5fceb9abb3d2cabbc48958ba249e560/model_lib/ControlNet/annotator/zoe/zoedepth/models/base_models/midas_repo/input/.placeholder -------------------------------------------------------------------------------- /model_lib/ControlNet/annotator/zoe/zoedepth/models/base_models/midas_repo/midas/backbones/next_vit.py: -------------------------------------------------------------------------------- 1 | import timm 2 | 3 | import torch.nn as nn 4 | 5 | from pathlib import Path 6 | from .utils import activations, forward_default, get_activation 7 | 8 | from ..external.next_vit.classification.nextvit import * 9 | 10 | 11 | def forward_next_vit(pretrained, x): 12 | return forward_default(pretrained, x, "forward") 13 | 14 | 15 | def _make_next_vit_backbone( 16 | model, 17 | hooks=[2, 6, 36, 39], 18 | ): 19 | pretrained = nn.Module() 20 | 21 | pretrained.model = model 22 | pretrained.model.features[hooks[0]].register_forward_hook(get_activation("1")) 23 | pretrained.model.features[hooks[1]].register_forward_hook(get_activation("2")) 24 | pretrained.model.features[hooks[2]].register_forward_hook(get_activation("3")) 25 | pretrained.model.features[hooks[3]].register_forward_hook(get_activation("4")) 26 | 27 | pretrained.activations = activations 28 | 29 | return pretrained 30 | 31 | 32 | def _make_pretrained_next_vit_large_6m(hooks=None): 33 | model = timm.create_model("nextvit_large") 34 | 35 | hooks = [2, 6, 36, 39] if hooks == None else hooks 36 | return _make_next_vit_backbone( 37 | model, 38 | hooks=hooks, 39 | ) 40 | -------------------------------------------------------------------------------- /model_lib/ControlNet/annotator/zoe/zoedepth/models/base_models/midas_repo/midas/backbones/swin.py: -------------------------------------------------------------------------------- 1 | import timm 2 | 3 | from .swin_common import _make_swin_backbone 4 | 5 | 6 | def _make_pretrained_swinl12_384(pretrained, hooks=None): 7 | model = timm.create_model("swin_large_patch4_window12_384", pretrained=pretrained) 8 | 9 | hooks = [1, 1, 17, 1] if hooks == None else hooks 10 | return _make_swin_backbone( 11 | model, 12 | hooks=hooks 13 | ) 14 | -------------------------------------------------------------------------------- /model_lib/ControlNet/annotator/zoe/zoedepth/models/base_models/midas_repo/midas/backbones/swin2.py: -------------------------------------------------------------------------------- 1 | import timm 2 | 3 | from .swin_common import _make_swin_backbone 4 | 5 | 6 | def _make_pretrained_swin2l24_384(pretrained, hooks=None): 7 | model = timm.create_model("swinv2_large_window12to24_192to384_22kft1k", pretrained=pretrained) 8 | 9 | hooks = [1, 1, 17, 1] if hooks == None else hooks 10 | return _make_swin_backbone( 11 | model, 12 | hooks=hooks 13 | ) 14 | 15 | 16 | def _make_pretrained_swin2b24_384(pretrained, hooks=None): 17 | model = timm.create_model("swinv2_base_window12to24_192to384_22kft1k", pretrained=pretrained) 18 | 19 | hooks = [1, 1, 17, 1] if hooks == None else hooks 20 | return _make_swin_backbone( 21 | model, 22 | hooks=hooks 23 | ) 24 | 25 | 26 | def _make_pretrained_swin2t16_256(pretrained, hooks=None): 27 | model = timm.create_model("swinv2_tiny_window16_256", pretrained=pretrained) 28 | 29 | hooks = [1, 1, 5, 1] if hooks == None else hooks 30 | return _make_swin_backbone( 31 | model, 32 | hooks=hooks, 33 | patch_grid=[64, 64] 34 | ) 35 | -------------------------------------------------------------------------------- /model_lib/ControlNet/annotator/zoe/zoedepth/models/base_models/midas_repo/midas/base_model.py: -------------------------------------------------------------------------------- 1 | import torch 2 | 3 | 4 | class BaseModel(torch.nn.Module): 5 | def load(self, path): 6 | """Load model from file. 7 | 8 | Args: 9 | path (str): file path 10 | """ 11 | parameters = torch.load(path, map_location=torch.device('cpu')) 12 | 13 | if "optimizer" in parameters: 14 | parameters = parameters["model"] 15 | 16 | self.load_state_dict(parameters) 17 | -------------------------------------------------------------------------------- /model_lib/ControlNet/annotator/zoe/zoedepth/models/base_models/midas_repo/mobile/android/.gitignore: -------------------------------------------------------------------------------- 1 | *.iml 2 | .gradle 3 | /local.properties 4 | /.idea/libraries 5 | /.idea/modules.xml 6 | /.idea/workspace.xml 7 | .DS_Store 8 | /build 9 | /captures 10 | .externalNativeBuild 11 | 12 | /.gradle/ 13 | /.idea/ -------------------------------------------------------------------------------- /model_lib/ControlNet/annotator/zoe/zoedepth/models/base_models/midas_repo/mobile/android/LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2020 Alexey 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /model_lib/ControlNet/annotator/zoe/zoedepth/models/base_models/midas_repo/mobile/android/README.md: -------------------------------------------------------------------------------- 1 | # MiDaS on Android smartphone by using TensorFlow-lite (TFLite) 2 | 3 | 4 | * Either use Android Studio for compilation. 5 | 6 | * Or use ready to install apk-file: 7 | * Or use URL: https://i.diawi.com/CVb8a9 8 | * Or use QR-code: 9 | 10 | Scan QR-code or open URL -> Press `Install application` -> Press `Download` and wait for download -> Open -> Install -> Open -> Press: Allow MiDaS to take photo and video from the camera While using the APP 11 | 12 | ![CVb8a9](https://user-images.githubusercontent.com/4096485/97727213-38552500-1ae1-11eb-8b76-4ea11216f76d.png) 13 | 14 | ---- 15 | 16 | To use another model, you should convert it to `model_opt.tflite` and place it to the directory: `models\src\main\assets` 17 | 18 | 19 | ---- 20 | 21 | Original repository: https://github.com/isl-org/MiDaS 22 | -------------------------------------------------------------------------------- /model_lib/ControlNet/annotator/zoe/zoedepth/models/base_models/midas_repo/mobile/android/app/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | 3 | /build/ -------------------------------------------------------------------------------- /model_lib/ControlNet/annotator/zoe/zoedepth/models/base_models/midas_repo/mobile/android/app/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # You can control the set of applied configuration files using the 3 | # proguardFiles setting in build.gradle. 4 | # 5 | # For more details, see 6 | # http://developer.android.com/guide/developing/tools/proguard.html 7 | 8 | # If your project uses WebView with JS, uncomment the following 9 | # and specify the fully qualified class name to the JavaScript interface 10 | # class: 11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 12 | # public *; 13 | #} 14 | 15 | # Uncomment this to preserve the line number information for 16 | # debugging stack traces. 17 | #-keepattributes SourceFile,LineNumberTable 18 | 19 | # If you keep the line number information, uncomment this to 20 | # hide the original source file name. 21 | #-renamesourcefileattribute SourceFile 22 | -------------------------------------------------------------------------------- /model_lib/ControlNet/annotator/zoe/zoedepth/models/base_models/midas_repo/mobile/android/app/src/androidTest/java/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | -------------------------------------------------------------------------------- /model_lib/ControlNet/annotator/zoe/zoedepth/models/base_models/midas_repo/mobile/android/app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 18 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | -------------------------------------------------------------------------------- /model_lib/ControlNet/annotator/zoe/zoedepth/models/base_models/midas_repo/mobile/android/app/src/main/java/org/tensorflow/lite/examples/classification/customview/ResultsView.java: -------------------------------------------------------------------------------- 1 | /* Copyright 2019 The TensorFlow Authors. All Rights Reserved. 2 | 3 | Licensed under the Apache License, Version 2.0 (the "License"); 4 | you may not use this file except in compliance with the License. 5 | You may obtain a copy of the License at 6 | 7 | http://www.apache.org/licenses/LICENSE-2.0 8 | 9 | Unless required by applicable law or agreed to in writing, software 10 | distributed under the License is distributed on an "AS IS" BASIS, 11 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | See the License for the specific language governing permissions and 13 | limitations under the License. 14 | ==============================================================================*/ 15 | 16 | package org.tensorflow.lite.examples.classification.customview; 17 | 18 | import java.util.List; 19 | import org.tensorflow.lite.examples.classification.tflite.Classifier.Recognition; 20 | 21 | public interface ResultsView { 22 | public void setResults(final List results); 23 | } 24 | -------------------------------------------------------------------------------- /model_lib/ControlNet/annotator/zoe/zoedepth/models/base_models/midas_repo/mobile/android/app/src/main/res/drawable/bottom_sheet_bg.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /model_lib/ControlNet/annotator/zoe/zoedepth/models/base_models/midas_repo/mobile/android/app/src/main/res/drawable/ic_baseline_add.xml: -------------------------------------------------------------------------------- 1 | 6 | 9 | 10 | -------------------------------------------------------------------------------- /model_lib/ControlNet/annotator/zoe/zoedepth/models/base_models/midas_repo/mobile/android/app/src/main/res/drawable/ic_baseline_remove.xml: -------------------------------------------------------------------------------- 1 | 6 | 9 | 10 | -------------------------------------------------------------------------------- /model_lib/ControlNet/annotator/zoe/zoedepth/models/base_models/midas_repo/mobile/android/app/src/main/res/drawable/rectangle.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 7 | 12 | 13 | -------------------------------------------------------------------------------- /model_lib/ControlNet/annotator/zoe/zoedepth/models/base_models/midas_repo/mobile/android/app/src/main/res/layout/tfe_ic_camera_connection_fragment.xml: -------------------------------------------------------------------------------- 1 | 16 | 19 | 20 | 25 | 26 | 30 | 31 | 32 | 33 | -------------------------------------------------------------------------------- /model_lib/ControlNet/annotator/zoe/zoedepth/models/base_models/midas_repo/mobile/android/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /model_lib/ControlNet/annotator/zoe/zoedepth/models/base_models/midas_repo/mobile/android/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /model_lib/ControlNet/annotator/zoe/zoedepth/models/base_models/midas_repo/mobile/android/app/src/main/res/values/colors.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | #ffa800 4 | #ff6f00 5 | #425066 6 | 7 | #66000000 8 | 9 | -------------------------------------------------------------------------------- /model_lib/ControlNet/annotator/zoe/zoedepth/models/base_models/midas_repo/mobile/android/app/src/main/res/values/dimens.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 15dp 4 | 8dp 5 | -------------------------------------------------------------------------------- /model_lib/ControlNet/annotator/zoe/zoedepth/models/base_models/midas_repo/mobile/android/app/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | Midas 3 | This device doesn\'t support Camera2 API. 4 | GPU does not yet supported quantized models. 5 | Model: 6 | 7 | Float_EfficientNet 8 | 13 | 14 | 15 | Device: 16 | 17 | GPU 18 | CPU 19 | NNAPI 20 | 21 | 22 | -------------------------------------------------------------------------------- /model_lib/ControlNet/annotator/zoe/zoedepth/models/base_models/midas_repo/mobile/android/app/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /model_lib/ControlNet/annotator/zoe/zoedepth/models/base_models/midas_repo/mobile/android/build.gradle: -------------------------------------------------------------------------------- 1 | // Top-level build file where you can add configuration options common to all sub-projects/modules. 2 | 3 | buildscript { 4 | 5 | repositories { 6 | google() 7 | jcenter() 8 | } 9 | dependencies { 10 | classpath 'com.android.tools.build:gradle:4.0.0' 11 | classpath 'de.undercouch:gradle-download-task:4.0.2' 12 | // NOTE: Do not place your application dependencies here; they belong 13 | // in the individual module build.gradle files 14 | } 15 | } 16 | 17 | allprojects { 18 | repositories { 19 | google() 20 | jcenter() 21 | } 22 | } 23 | 24 | task clean(type: Delete) { 25 | delete rootProject.buildDir 26 | } 27 | 28 | -------------------------------------------------------------------------------- /model_lib/ControlNet/annotator/zoe/zoedepth/models/base_models/midas_repo/mobile/android/gradle.properties: -------------------------------------------------------------------------------- 1 | # Project-wide Gradle settings. 2 | # IDE (e.g. Android Studio) users: 3 | # Gradle settings configured through the IDE *will override* 4 | # any settings specified in this file. 5 | # For more details on how to configure your build environment visit 6 | # http://www.gradle.org/docs/current/userguide/build_environment.html 7 | # Specifies the JVM arguments used for the daemon process. 8 | # The setting is particularly useful for tweaking memory settings. 9 | org.gradle.jvmargs=-Xmx1536m 10 | # When configured, Gradle will run in incubating parallel mode. 11 | # This option should only be used with decoupled projects. More details, visit 12 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects 13 | # org.gradle.parallel=true 14 | android.useAndroidX=true 15 | android.enableJetifier=true 16 | -------------------------------------------------------------------------------- /model_lib/ControlNet/annotator/zoe/zoedepth/models/base_models/midas_repo/mobile/android/gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Boese0601/MagicDance/a515a1f4a5fceb9abb3d2cabbc48958ba249e560/model_lib/ControlNet/annotator/zoe/zoedepth/models/base_models/midas_repo/mobile/android/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /model_lib/ControlNet/annotator/zoe/zoedepth/models/base_models/midas_repo/mobile/android/gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionBase=GRADLE_USER_HOME 2 | distributionPath=wrapper/dists 3 | distributionUrl=https\://services.gradle.org/distributions/gradle-6.1.1-bin.zip 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | -------------------------------------------------------------------------------- /model_lib/ControlNet/annotator/zoe/zoedepth/models/base_models/midas_repo/mobile/android/lib_support/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # You can control the set of applied configuration files using the 3 | # proguardFiles setting in build.gradle. 4 | # 5 | # For more details, see 6 | # http://developer.android.com/guide/developing/tools/proguard.html 7 | 8 | # If your project uses WebView with JS, uncomment the following 9 | # and specify the fully qualified class name to the JavaScript interface 10 | # class: 11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 12 | # public *; 13 | #} 14 | 15 | # Uncomment this to preserve the line number information for 16 | # debugging stack traces. 17 | #-keepattributes SourceFile,LineNumberTable 18 | 19 | # If you keep the line number information, uncomment this to 20 | # hide the original source file name. 21 | #-renamesourcefileattribute SourceFile 22 | -------------------------------------------------------------------------------- /model_lib/ControlNet/annotator/zoe/zoedepth/models/base_models/midas_repo/mobile/android/lib_support/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 3 | 4 | -------------------------------------------------------------------------------- /model_lib/ControlNet/annotator/zoe/zoedepth/models/base_models/midas_repo/mobile/android/lib_task_api/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # You can control the set of applied configuration files using the 3 | # proguardFiles setting in build.gradle. 4 | # 5 | # For more details, see 6 | # http://developer.android.com/guide/developing/tools/proguard.html 7 | 8 | # If your project uses WebView with JS, uncomment the following 9 | # and specify the fully qualified class name to the JavaScript interface 10 | # class: 11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 12 | # public *; 13 | #} 14 | 15 | # Uncomment this to preserve the line number information for 16 | # debugging stack traces. 17 | #-keepattributes SourceFile,LineNumberTable 18 | 19 | # If you keep the line number information, uncomment this to 20 | # hide the original source file name. 21 | #-renamesourcefileattribute SourceFile 22 | -------------------------------------------------------------------------------- /model_lib/ControlNet/annotator/zoe/zoedepth/models/base_models/midas_repo/mobile/android/lib_task_api/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 3 | 4 | -------------------------------------------------------------------------------- /model_lib/ControlNet/annotator/zoe/zoedepth/models/base_models/midas_repo/mobile/android/models/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.library' 2 | apply plugin: 'de.undercouch.download' 3 | 4 | android { 5 | compileSdkVersion 28 6 | buildToolsVersion "28.0.0" 7 | 8 | defaultConfig { 9 | minSdkVersion 21 10 | targetSdkVersion 28 11 | versionCode 1 12 | versionName "1.0" 13 | 14 | testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" 15 | 16 | } 17 | 18 | buildTypes { 19 | release { 20 | minifyEnabled false 21 | proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' 22 | } 23 | } 24 | 25 | aaptOptions { 26 | noCompress "tflite" 27 | } 28 | 29 | lintOptions { 30 | checkReleaseBuilds false 31 | // Or, if you prefer, you can continue to check for errors in release builds, 32 | // but continue the build even when errors are found: 33 | abortOnError false 34 | } 35 | } 36 | 37 | // Download default models; if you wish to use your own models then 38 | // place them in the "assets" directory and comment out this line. 39 | project.ext.ASSET_DIR = projectDir.toString() + '/src/main/assets' 40 | apply from:'download.gradle' 41 | -------------------------------------------------------------------------------- /model_lib/ControlNet/annotator/zoe/zoedepth/models/base_models/midas_repo/mobile/android/models/download.gradle: -------------------------------------------------------------------------------- 1 | def modelFloatDownloadUrl = "https://github.com/isl-org/MiDaS/releases/download/v2_1/model_opt.tflite" 2 | def modelFloatFile = "model_opt.tflite" 3 | 4 | task downloadModelFloat(type: Download) { 5 | src "${modelFloatDownloadUrl}" 6 | dest project.ext.ASSET_DIR + "/${modelFloatFile}" 7 | overwrite false 8 | } 9 | 10 | preBuild.dependsOn downloadModelFloat 11 | -------------------------------------------------------------------------------- /model_lib/ControlNet/annotator/zoe/zoedepth/models/base_models/midas_repo/mobile/android/models/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # You can control the set of applied configuration files using the 3 | # proguardFiles setting in build.gradle. 4 | # 5 | # For more details, see 6 | # http://developer.android.com/guide/developing/tools/proguard.html 7 | 8 | # If your project uses WebView with JS, uncomment the following 9 | # and specify the fully qualified class name to the JavaScript interface 10 | # class: 11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 12 | # public *; 13 | #} 14 | 15 | # Uncomment this to preserve the line number information for 16 | # debugging stack traces. 17 | #-keepattributes SourceFile,LineNumberTable 18 | 19 | # If you keep the line number information, uncomment this to 20 | # hide the original source file name. 21 | #-renamesourcefileattribute SourceFile 22 | -------------------------------------------------------------------------------- /model_lib/ControlNet/annotator/zoe/zoedepth/models/base_models/midas_repo/mobile/android/models/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 3 | 4 | -------------------------------------------------------------------------------- /model_lib/ControlNet/annotator/zoe/zoedepth/models/base_models/midas_repo/mobile/android/settings.gradle: -------------------------------------------------------------------------------- 1 | rootProject.name = 'TFLite Image Classification Demo App' 2 | include ':app', ':lib_support', ':lib_task_api', ':models' -------------------------------------------------------------------------------- /model_lib/ControlNet/annotator/zoe/zoedepth/models/base_models/midas_repo/mobile/ios/.gitignore: -------------------------------------------------------------------------------- 1 | # ignore model file 2 | #*.tflite 3 | -------------------------------------------------------------------------------- /model_lib/ControlNet/annotator/zoe/zoedepth/models/base_models/midas_repo/mobile/ios/Midas.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /model_lib/ControlNet/annotator/zoe/zoedepth/models/base_models/midas_repo/mobile/ios/Midas.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /model_lib/ControlNet/annotator/zoe/zoedepth/models/base_models/midas_repo/mobile/ios/Midas.xcodeproj/project.xcworkspace/xcuserdata/admin.xcuserdatad/UserInterfaceState.xcuserstate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Boese0601/MagicDance/a515a1f4a5fceb9abb3d2cabbc48958ba249e560/model_lib/ControlNet/annotator/zoe/zoedepth/models/base_models/midas_repo/mobile/ios/Midas.xcodeproj/project.xcworkspace/xcuserdata/admin.xcuserdatad/UserInterfaceState.xcuserstate -------------------------------------------------------------------------------- /model_lib/ControlNet/annotator/zoe/zoedepth/models/base_models/midas_repo/mobile/ios/Midas.xcodeproj/xcuserdata/admin.xcuserdatad/xcschemes/xcschememanagement.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SchemeUserState 6 | 7 | PoseNet.xcscheme_^#shared#^_ 8 | 9 | orderHint 10 | 3 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /model_lib/ControlNet/annotator/zoe/zoedepth/models/base_models/midas_repo/mobile/ios/Midas/AppDelegate.swift: -------------------------------------------------------------------------------- 1 | // Copyright 2019 The TensorFlow Authors. All Rights Reserved. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | import UIKit 16 | 17 | @UIApplicationMain 18 | class AppDelegate: UIResponder, UIApplicationDelegate { 19 | 20 | var window: UIWindow? 21 | 22 | func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool { 23 | return true 24 | } 25 | 26 | func applicationWillResignActive(_ application: UIApplication) { 27 | } 28 | 29 | func applicationDidEnterBackground(_ application: UIApplication) { 30 | } 31 | 32 | func applicationWillEnterForeground(_ application: UIApplication) { 33 | } 34 | 35 | func applicationDidBecomeActive(_ application: UIApplication) { 36 | } 37 | 38 | func applicationWillTerminate(_ application: UIApplication) { 39 | } 40 | } 41 | 42 | -------------------------------------------------------------------------------- /model_lib/ControlNet/annotator/zoe/zoedepth/models/base_models/midas_repo/mobile/ios/Midas/Assets.xcassets/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "info" : { 3 | "version" : 1, 4 | "author" : "xcode" 5 | } 6 | } -------------------------------------------------------------------------------- /model_lib/ControlNet/annotator/zoe/zoedepth/models/base_models/midas_repo/mobile/ios/Midas/Camera Feed/PreviewView.swift: -------------------------------------------------------------------------------- 1 | // Copyright 2019 The TensorFlow Authors. All Rights Reserved. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | import UIKit 16 | import AVFoundation 17 | 18 | /// The camera frame is displayed on this view. 19 | class PreviewView: UIView { 20 | var previewLayer: AVCaptureVideoPreviewLayer { 21 | guard let layer = layer as? AVCaptureVideoPreviewLayer else { 22 | fatalError("Layer expected is of type VideoPreviewLayer") 23 | } 24 | return layer 25 | } 26 | 27 | var session: AVCaptureSession? { 28 | get { 29 | return previewLayer.session 30 | } 31 | set { 32 | previewLayer.session = newValue 33 | } 34 | } 35 | 36 | override class var layerClass: AnyClass { 37 | return AVCaptureVideoPreviewLayer.self 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /model_lib/ControlNet/annotator/zoe/zoedepth/models/base_models/midas_repo/mobile/ios/Midas/Cells/InfoCell.swift: -------------------------------------------------------------------------------- 1 | // Copyright 2019 The TensorFlow Authors. All Rights Reserved. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | import UIKit 16 | 17 | /// Table cell for inference result in bottom view. 18 | class InfoCell: UITableViewCell { 19 | @IBOutlet weak var fieldNameLabel: UILabel! 20 | @IBOutlet weak var infoLabel: UILabel! 21 | } 22 | -------------------------------------------------------------------------------- /model_lib/ControlNet/annotator/zoe/zoedepth/models/base_models/midas_repo/mobile/ios/Midas/Constants.swift: -------------------------------------------------------------------------------- 1 | // Copyright 2020 The TensorFlow Authors. All Rights Reserved. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | // ============================================================================= 15 | 16 | enum Constants { 17 | // MARK: - Constants related to the image processing 18 | static let bgraPixel = (channels: 4, alphaComponent: 3, lastBgrComponent: 2) 19 | static let rgbPixelChannels = 3 20 | static let maxRGBValue: Float32 = 255.0 21 | 22 | // MARK: - Constants related to the model interperter 23 | static let defaultThreadCount = 2 24 | static let defaultDelegate: Delegates = .CPU 25 | } 26 | -------------------------------------------------------------------------------- /model_lib/ControlNet/annotator/zoe/zoedepth/models/base_models/midas_repo/mobile/ios/Podfile: -------------------------------------------------------------------------------- 1 | # Uncomment the next line to define a global platform for your project 2 | platform :ios, '12.0' 3 | 4 | target 'Midas' do 5 | # Comment the next line if you're not using Swift and don't want to use dynamic frameworks 6 | use_frameworks! 7 | 8 | # Pods for Midas 9 | pod 'TensorFlowLiteSwift', '~> 0.0.1-nightly' 10 | pod 'TensorFlowLiteSwift/CoreML', '~> 0.0.1-nightly' 11 | pod 'TensorFlowLiteSwift/Metal', '~> 0.0.1-nightly' 12 | end 13 | -------------------------------------------------------------------------------- /model_lib/ControlNet/annotator/zoe/zoedepth/models/base_models/midas_repo/mobile/ios/RunScripts/download_models.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # Download TF Lite model from the internet if it does not exist. 3 | 4 | TFLITE_MODEL="model_opt.tflite" 5 | TFLITE_FILE="Midas/Model/${TFLITE_MODEL}" 6 | MODEL_SRC="https://github.com/isl-org/MiDaS/releases/download/v2/${TFLITE_MODEL}" 7 | 8 | if test -f "${TFLITE_FILE}"; then 9 | echo "INFO: TF Lite model already exists. Skip downloading and use the local model." 10 | else 11 | curl --create-dirs -o "${TFLITE_FILE}" -LJO "${MODEL_SRC}" 12 | echo "INFO: Downloaded TensorFlow Lite model to ${TFLITE_FILE}." 13 | fi 14 | 15 | -------------------------------------------------------------------------------- /model_lib/ControlNet/annotator/zoe/zoedepth/models/base_models/midas_repo/output/.placeholder: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Boese0601/MagicDance/a515a1f4a5fceb9abb3d2cabbc48958ba249e560/model_lib/ControlNet/annotator/zoe/zoedepth/models/base_models/midas_repo/output/.placeholder -------------------------------------------------------------------------------- /model_lib/ControlNet/annotator/zoe/zoedepth/models/base_models/midas_repo/ros/LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2020 Alexey 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /model_lib/ControlNet/annotator/zoe/zoedepth/models/base_models/midas_repo/ros/additions/do_catkin_make.sh: -------------------------------------------------------------------------------- 1 | mkdir src 2 | catkin_make 3 | source devel/setup.bash 4 | echo $ROS_PACKAGE_PATH 5 | chmod +x ./devel/setup.bash 6 | -------------------------------------------------------------------------------- /model_lib/ControlNet/annotator/zoe/zoedepth/models/base_models/midas_repo/ros/additions/downloads.sh: -------------------------------------------------------------------------------- 1 | mkdir ~/.ros 2 | wget https://github.com/isl-org/MiDaS/releases/download/v2_1/model-small-traced.pt 3 | cp ./model-small-traced.pt ~/.ros/model-small-traced.pt 4 | 5 | 6 | -------------------------------------------------------------------------------- /model_lib/ControlNet/annotator/zoe/zoedepth/models/base_models/midas_repo/ros/additions/install_ros_melodic_ubuntu_17_18.sh: -------------------------------------------------------------------------------- 1 | #@title { display-mode: "code" } 2 | 3 | #from http://wiki.ros.org/indigo/Installation/Ubuntu 4 | 5 | #1.2 Setup sources.list 6 | sudo sh -c 'echo "deb http://packages.ros.org/ros/ubuntu $(lsb_release -sc) main" > /etc/apt/sources.list.d/ros-latest.list' 7 | 8 | # 1.3 Setup keys 9 | sudo apt-key adv --keyserver 'hkp://keyserver.ubuntu.com:80' --recv-key C1CF6E31E6BADE8868B172B4F42ED6FBAB17C654 10 | sudo apt-key adv --keyserver 'hkp://ha.pool.sks-keyservers.net:80' --recv-key 421C365BD9FF1F717815A3895523BAEEB01FA116 11 | 12 | curl -sSL 'http://keyserver.ubuntu.com/pks/lookup?op=get&search=0xC1CF6E31E6BADE8868B172B4F42ED6FBAB17C654' | sudo apt-key add - 13 | 14 | # 1.4 Installation 15 | sudo apt-get update 16 | sudo apt-get upgrade 17 | 18 | # Desktop-Full Install: 19 | sudo apt-get install ros-melodic-desktop-full 20 | 21 | printf "\nsource /opt/ros/melodic/setup.bash\n" >> ~/.bashrc 22 | 23 | # 1.5 Initialize rosdep 24 | sudo rosdep init 25 | rosdep update 26 | 27 | 28 | # 1.7 Getting rosinstall (python) 29 | sudo apt-get install python-rosinstall 30 | sudo apt-get install python-catkin-tools 31 | sudo apt-get install python-rospy 32 | sudo apt-get install python-rosdep 33 | sudo apt-get install python-roscd 34 | sudo apt-get install python-pip -------------------------------------------------------------------------------- /model_lib/ControlNet/annotator/zoe/zoedepth/models/base_models/midas_repo/ros/additions/install_ros_noetic_ubuntu_20.sh: -------------------------------------------------------------------------------- 1 | #@title { display-mode: "code" } 2 | 3 | #from http://wiki.ros.org/indigo/Installation/Ubuntu 4 | 5 | #1.2 Setup sources.list 6 | sudo sh -c 'echo "deb http://packages.ros.org/ros/ubuntu $(lsb_release -sc) main" > /etc/apt/sources.list.d/ros-latest.list' 7 | 8 | # 1.3 Setup keys 9 | sudo apt-key adv --keyserver 'hkp://keyserver.ubuntu.com:80' --recv-key C1CF6E31E6BADE8868B172B4F42ED6FBAB17C654 10 | 11 | curl -sSL 'http://keyserver.ubuntu.com/pks/lookup?op=get&search=0xC1CF6E31E6BADE8868B172B4F42ED6FBAB17C654' | sudo apt-key add - 12 | 13 | # 1.4 Installation 14 | sudo apt-get update 15 | sudo apt-get upgrade 16 | 17 | # Desktop-Full Install: 18 | sudo apt-get install ros-noetic-desktop-full 19 | 20 | printf "\nsource /opt/ros/noetic/setup.bash\n" >> ~/.bashrc 21 | 22 | # 1.5 Initialize rosdep 23 | sudo rosdep init 24 | rosdep update 25 | 26 | 27 | # 1.7 Getting rosinstall (python) 28 | sudo apt-get install python3-rosinstall 29 | sudo apt-get install python3-catkin-tools 30 | sudo apt-get install python3-rospy 31 | sudo apt-get install python3-rosdep 32 | sudo apt-get install python3-roscd 33 | sudo apt-get install python3-pip -------------------------------------------------------------------------------- /model_lib/ControlNet/annotator/zoe/zoedepth/models/base_models/midas_repo/ros/additions/make_package_cpp.sh: -------------------------------------------------------------------------------- 1 | cd ~/catkin_ws/src 2 | catkin_create_pkg midas_cpp std_msgs roscpp cv_bridge sensor_msgs image_transport 3 | cd ~/catkin_ws 4 | catkin_make 5 | 6 | chmod +x ~/catkin_ws/devel/setup.bash 7 | printf "\nsource ~/catkin_ws/devel/setup.bash" >> ~/.bashrc 8 | source ~/catkin_ws/devel/setup.bash 9 | 10 | 11 | sudo rosdep init 12 | rosdep update 13 | #rospack depends1 midas_cpp 14 | roscd midas_cpp 15 | #cat package.xml 16 | #rospack depends midas_cpp -------------------------------------------------------------------------------- /model_lib/ControlNet/annotator/zoe/zoedepth/models/base_models/midas_repo/ros/launch_midas_cpp.sh: -------------------------------------------------------------------------------- 1 | source ~/catkin_ws/devel/setup.bash 2 | roslaunch midas_cpp midas_cpp.launch model_name:="model-small-traced.pt" input_topic:="image_topic" output_topic:="midas_topic" out_orig_size:="true" -------------------------------------------------------------------------------- /model_lib/ControlNet/annotator/zoe/zoedepth/models/base_models/midas_repo/ros/midas_cpp/launch/midas_cpp.launch: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /model_lib/ControlNet/annotator/zoe/zoedepth/models/base_models/midas_repo/ros/midas_cpp/launch/midas_talker_listener.launch: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /model_lib/ControlNet/annotator/zoe/zoedepth/models/base_models/midas_repo/ros/run_talker_listener_test.sh: -------------------------------------------------------------------------------- 1 | # place any test.mp4 file near with this file 2 | 3 | # roscore 4 | # rosnode kill -a 5 | 6 | source ~/catkin_ws/devel/setup.bash 7 | 8 | roscore & 9 | P1=$! 10 | rosrun midas_cpp talker.py & 11 | P2=$! 12 | rosrun midas_cpp listener_original.py & 13 | P3=$! 14 | rosrun midas_cpp listener.py & 15 | P4=$! 16 | wait $P1 $P2 $P3 $P4 -------------------------------------------------------------------------------- /model_lib/ControlNet/annotator/zoe/zoedepth/models/base_models/midas_repo/tf/input/.placeholder: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Boese0601/MagicDance/a515a1f4a5fceb9abb3d2cabbc48958ba249e560/model_lib/ControlNet/annotator/zoe/zoedepth/models/base_models/midas_repo/tf/input/.placeholder -------------------------------------------------------------------------------- /model_lib/ControlNet/annotator/zoe/zoedepth/models/base_models/midas_repo/tf/output/.placeholder: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Boese0601/MagicDance/a515a1f4a5fceb9abb3d2cabbc48958ba249e560/model_lib/ControlNet/annotator/zoe/zoedepth/models/base_models/midas_repo/tf/output/.placeholder -------------------------------------------------------------------------------- /model_lib/ControlNet/annotator/zoe/zoedepth/models/base_models/midas_repo/weights/.placeholder: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Boese0601/MagicDance/a515a1f4a5fceb9abb3d2cabbc48958ba249e560/model_lib/ControlNet/annotator/zoe/zoedepth/models/base_models/midas_repo/weights/.placeholder -------------------------------------------------------------------------------- /model_lib/ControlNet/annotator/zoe/zoedepth/models/zoedepth/__init__.py: -------------------------------------------------------------------------------- 1 | # MIT License 2 | 3 | # Copyright (c) 2022 Intelligent Systems Lab Org 4 | 5 | # Permission is hereby granted, free of charge, to any person obtaining a copy 6 | # of this software and associated documentation files (the "Software"), to deal 7 | # in the Software without restriction, including without limitation the rights 8 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | # copies of the Software, and to permit persons to whom the Software is 10 | # furnished to do so, subject to the following conditions: 11 | 12 | # The above copyright notice and this permission notice shall be included in all 13 | # copies or substantial portions of the Software. 14 | 15 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | # SOFTWARE. 22 | 23 | # File author: Shariq Farooq Bhat 24 | 25 | from .zoedepth_v1 import ZoeDepth 26 | 27 | all_versions = { 28 | "v1": ZoeDepth, 29 | } 30 | 31 | get_version = lambda v : all_versions[v] -------------------------------------------------------------------------------- /model_lib/ControlNet/annotator/zoe/zoedepth/models/zoedepth/config_zoedepth_kitti.json: -------------------------------------------------------------------------------- 1 | { 2 | "model": { 3 | "bin_centers_type": "normed", 4 | "img_size": [384, 768] 5 | }, 6 | 7 | "train": { 8 | }, 9 | 10 | "infer":{ 11 | "train_midas": false, 12 | "use_pretrained_midas": false, 13 | "pretrained_resource" : "url::https://github.com/isl-org/ZoeDepth/releases/download/v1.0/ZoeD_M12_K.pt", 14 | "force_keep_ar": true 15 | }, 16 | 17 | "eval":{ 18 | "train_midas": false, 19 | "use_pretrained_midas": false, 20 | "pretrained_resource" : "url::https://github.com/isl-org/ZoeDepth/releases/download/v1.0/ZoeD_M12_K.pt" 21 | } 22 | } -------------------------------------------------------------------------------- /model_lib/ControlNet/annotator/zoe/zoedepth/models/zoedepth_nk/__init__.py: -------------------------------------------------------------------------------- 1 | # MIT License 2 | 3 | # Copyright (c) 2022 Intelligent Systems Lab Org 4 | 5 | # Permission is hereby granted, free of charge, to any person obtaining a copy 6 | # of this software and associated documentation files (the "Software"), to deal 7 | # in the Software without restriction, including without limitation the rights 8 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | # copies of the Software, and to permit persons to whom the Software is 10 | # furnished to do so, subject to the following conditions: 11 | 12 | # The above copyright notice and this permission notice shall be included in all 13 | # copies or substantial portions of the Software. 14 | 15 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | # SOFTWARE. 22 | 23 | # File author: Shariq Farooq Bhat 24 | 25 | from .zoedepth_nk_v1 import ZoeDepthNK 26 | 27 | all_versions = { 28 | "v1": ZoeDepthNK, 29 | } 30 | 31 | get_version = lambda v : all_versions[v] -------------------------------------------------------------------------------- /model_lib/ControlNet/annotator/zoe/zoedepth/utils/__init__.py: -------------------------------------------------------------------------------- 1 | # MIT License 2 | 3 | # Copyright (c) 2022 Intelligent Systems Lab Org 4 | 5 | # Permission is hereby granted, free of charge, to any person obtaining a copy 6 | # of this software and associated documentation files (the "Software"), to deal 7 | # in the Software without restriction, including without limitation the rights 8 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | # copies of the Software, and to permit persons to whom the Software is 10 | # furnished to do so, subject to the following conditions: 11 | 12 | # The above copyright notice and this permission notice shall be included in all 13 | # copies or substantial portions of the Software. 14 | 15 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | # SOFTWARE. 22 | 23 | # File author: Shariq Farooq Bhat 24 | 25 | -------------------------------------------------------------------------------- /model_lib/ControlNet/annotator/zoe/zoedepth/utils/arg_utils.py: -------------------------------------------------------------------------------- 1 | 2 | 3 | def infer_type(x): # hacky way to infer type from string args 4 | if not isinstance(x, str): 5 | return x 6 | 7 | try: 8 | x = int(x) 9 | return x 10 | except ValueError: 11 | pass 12 | 13 | try: 14 | x = float(x) 15 | return x 16 | except ValueError: 17 | pass 18 | 19 | return x 20 | 21 | 22 | def parse_unknown(unknown_args): 23 | clean = [] 24 | for a in unknown_args: 25 | if "=" in a: 26 | k, v = a.split("=") 27 | clean.extend([k, v]) 28 | else: 29 | clean.append(a) 30 | 31 | keys = clean[::2] 32 | values = clean[1::2] 33 | return {k.replace("--", ""): infer_type(v) for k, v in zip(keys, values)} 34 | -------------------------------------------------------------------------------- /model_lib/ControlNet/cldm/model.py: -------------------------------------------------------------------------------- 1 | import os 2 | import torch 3 | 4 | from omegaconf import OmegaConf 5 | from model_lib.ControlNet.ldm.util import instantiate_from_config 6 | 7 | 8 | def get_state_dict(d): 9 | return d.get('state_dict', d) 10 | 11 | 12 | def load_state_dict(ckpt_path, location='cpu'): 13 | _, extension = os.path.splitext(ckpt_path) 14 | if extension.lower() == ".safetensors": 15 | import safetensors.torch 16 | state_dict = safetensors.torch.load_file(ckpt_path, device=location) 17 | else: 18 | state_dict = get_state_dict(torch.load(ckpt_path, map_location=torch.device(location))) 19 | state_dict = get_state_dict(state_dict) 20 | print(f'Loaded state_dict from [{ckpt_path}]') 21 | return state_dict 22 | 23 | 24 | def create_model(config_path): 25 | config = OmegaConf.load(config_path) 26 | model = instantiate_from_config(config.model).cpu() 27 | print(f'Loaded model config from [{config_path}]') 28 | return model 29 | -------------------------------------------------------------------------------- /model_lib/ControlNet/ldm/data/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Boese0601/MagicDance/a515a1f4a5fceb9abb3d2cabbc48958ba249e560/model_lib/ControlNet/ldm/data/__init__.py -------------------------------------------------------------------------------- /model_lib/ControlNet/ldm/data/util.py: -------------------------------------------------------------------------------- 1 | import torch 2 | 3 | from model_lib.ControlNet.ldm.modules.midas.api import load_midas_transform 4 | 5 | 6 | class AddMiDaS(object): 7 | def __init__(self, model_type): 8 | super().__init__() 9 | self.transform = load_midas_transform(model_type) 10 | 11 | def pt2np(self, x): 12 | x = ((x + 1.0) * .5).detach().cpu().numpy() 13 | return x 14 | 15 | def np2pt(self, x): 16 | x = torch.from_numpy(x) * 2 - 1. 17 | return x 18 | 19 | def __call__(self, sample): 20 | # sample['jpg'] is tensor hwc in [-1, 1] at this point 21 | x = self.pt2np(sample['jpg']) 22 | x = self.transform({"image": x})["image"] 23 | sample['midas_in'] = x 24 | return sample -------------------------------------------------------------------------------- /model_lib/ControlNet/ldm/models/diffusion/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Boese0601/MagicDance/a515a1f4a5fceb9abb3d2cabbc48958ba249e560/model_lib/ControlNet/ldm/models/diffusion/__init__.py -------------------------------------------------------------------------------- /model_lib/ControlNet/ldm/models/diffusion/dpm_solver/__init__.py: -------------------------------------------------------------------------------- 1 | from .sampler import DPMSolverSampler -------------------------------------------------------------------------------- /model_lib/ControlNet/ldm/models/diffusion/overlap_sampling.py: -------------------------------------------------------------------------------- 1 | import random 2 | pred_all = torch.zeros_like(latents) 3 | counts = torch.zeros(num_frames).cuda() 4 | offset = random.randint(0, num_frames-1) # random offset 5 | for start_idx in range(offset, offset+num_frames-16+1, 12): #?? 6 | indices = torch.arange(start_idx, start_idx + 16) % num_frames 7 | pred_pos = pipeline(latents[:,:,indices], timestep, **cond).sample 8 | pred_neg = pipeline(latents[:,:,indices], timestep, **uncond).sample 9 | pred = pred_neg + guidance_weight * (pred_pos - pred_neg) 10 | pred_all[:,:,indices] += pred 11 | counts[indices] += 1 12 | # print(timestep, counts) 13 | pred = pred_all / counts.reshape(1,1,-1,1,1) 14 | latents = scheduler.step( 15 | pred, 16 | args.unet_prediction, 17 | timestep, 18 | latents 19 | ).prev_sample -------------------------------------------------------------------------------- /model_lib/ControlNet/ldm/models/diffusion/sampling_util.py: -------------------------------------------------------------------------------- 1 | import torch 2 | import numpy as np 3 | 4 | 5 | def append_dims(x, target_dims): 6 | """Appends dimensions to the end of a tensor until it has target_dims dimensions. 7 | From https://github.com/crowsonkb/k-diffusion/blob/master/k_diffusion/utils.py""" 8 | dims_to_append = target_dims - x.ndim 9 | if dims_to_append < 0: 10 | raise ValueError(f'input has {x.ndim} dims but target_dims is {target_dims}, which is less') 11 | return x[(...,) + (None,) * dims_to_append] 12 | 13 | 14 | def norm_thresholding(x0, value): 15 | s = append_dims(x0.pow(2).flatten(1).mean(1).sqrt().clamp(min=value), x0.ndim) 16 | return x0 * (value / s) 17 | 18 | 19 | def spatial_norm_thresholding(x0, value): 20 | # b c h w 21 | s = x0.pow(2).mean(1, keepdim=True).sqrt().clamp(min=value) 22 | return x0 * (value / s) -------------------------------------------------------------------------------- /model_lib/ControlNet/ldm/modules/diffusionmodules/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Boese0601/MagicDance/a515a1f4a5fceb9abb3d2cabbc48958ba249e560/model_lib/ControlNet/ldm/modules/diffusionmodules/__init__.py -------------------------------------------------------------------------------- /model_lib/ControlNet/ldm/modules/distributions/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Boese0601/MagicDance/a515a1f4a5fceb9abb3d2cabbc48958ba249e560/model_lib/ControlNet/ldm/modules/distributions/__init__.py -------------------------------------------------------------------------------- /model_lib/ControlNet/ldm/modules/encoders/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Boese0601/MagicDance/a515a1f4a5fceb9abb3d2cabbc48958ba249e560/model_lib/ControlNet/ldm/modules/encoders/__init__.py -------------------------------------------------------------------------------- /model_lib/ControlNet/ldm/modules/image_degradation/__init__.py: -------------------------------------------------------------------------------- 1 | from ldm.modules.image_degradation.bsrgan import degradation_bsrgan_variant as degradation_fn_bsr 2 | from ldm.modules.image_degradation.bsrgan_light import degradation_bsrgan_variant as degradation_fn_bsr_light 3 | -------------------------------------------------------------------------------- /model_lib/ControlNet/ldm/modules/midas/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Boese0601/MagicDance/a515a1f4a5fceb9abb3d2cabbc48958ba249e560/model_lib/ControlNet/ldm/modules/midas/__init__.py -------------------------------------------------------------------------------- /model_lib/ControlNet/ldm/modules/midas/midas/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Boese0601/MagicDance/a515a1f4a5fceb9abb3d2cabbc48958ba249e560/model_lib/ControlNet/ldm/modules/midas/midas/__init__.py -------------------------------------------------------------------------------- /model_lib/ControlNet/ldm/modules/midas/midas/base_model.py: -------------------------------------------------------------------------------- 1 | import torch 2 | 3 | 4 | class BaseModel(torch.nn.Module): 5 | def load(self, path): 6 | """Load model from file. 7 | 8 | Args: 9 | path (str): file path 10 | """ 11 | parameters = torch.load(path, map_location=torch.device('cpu')) 12 | 13 | if "optimizer" in parameters: 14 | parameters = parameters["model"] 15 | 16 | self.load_state_dict(parameters) 17 | -------------------------------------------------------------------------------- /pretrained_weights/put your model ckpts here.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Boese0601/MagicDance/a515a1f4a5fceb9abb3d2cabbc48958ba249e560/pretrained_weights/put your model ckpts here.txt -------------------------------------------------------------------------------- /scripts/appearance_control_pretraining.sh: -------------------------------------------------------------------------------- 1 | CUDA_VISIBLE_DEVICES=0 torchrun --master_port 10000 train_tiktok.py \ 2 | --model_config model_lib/ControlNet/models/cldm_v15_reference_only.yaml \ 3 | --init_path ./pretrained_weights/control_sd15_ini.ckpt \ 4 | --output_dir ./tiktok_train_log/appearance_control_pretraining \ 5 | --train_batch_size 32 \ 6 | --num_workers 1 \ 7 | --img_bin_limit 15 \ 8 | --use_fp16 \ 9 | --control_mode controlnet_important \ 10 | --control_type body+hand+face \ 11 | --train_dataset tiktok_video_arnold \ 12 | --v4 \ 13 | --with_text \ 14 | --wonoise \ 15 | --finetune_control \ 16 | --local_image_dir ./tiktok_train_log/image_log/appearance_control_pretraining \ 17 | --local_log_dir ./tiktok_train_log/tb_log/appearance_control_pretraining \ 18 | $@ 19 | 20 | -------------------------------------------------------------------------------- /scripts/appearance_disentangle_pose_control.sh: -------------------------------------------------------------------------------- 1 | CUDA_VISIBLE_DEVICES=0 torchrun --master_port 10000 train_tiktok.py \ 2 | --model_config model_lib/ControlNet/models/cldm_v15_reference_only_pose.yaml \ 3 | --init_path ./pretrained_weights/control_sd15_ini.ckpt \ 4 | --output_dir ./tiktok_train_log/magicdance \ 5 | --train_batch_size 8 \ 6 | --num_workers 1 \ 7 | --control_mode controlnet_important \ 8 | --img_bin_limit 29 \ 9 | --use_fp16 \ 10 | --control_type body+hand+face \ 11 | --train_dataset tiktok_video_arnold \ 12 | --with_text \ 13 | --wonoise \ 14 | --finetune_control \ 15 | --local_image_dir ./tiktok_train_log/image_log/magicdance \ 16 | --local_log_dir ./tiktok_train_log/tb_log/magicdance \ 17 | --image_pretrain_dir ./tiktok_train_log/appearance_control_pretraining \ 18 | --pose_pretrain_dir ./pretrained_weights/control_v11p_sd15_openpose.pth \ 19 | $@ 20 | 21 | -------------------------------------------------------------------------------- /scripts/inference_any_image_pose.sh: -------------------------------------------------------------------------------- 1 | imagename="181020" 2 | posepath="001" 3 | 4 | CUDA_VISIBLE_DEVICES=0 torchrun --master_port 18102 test_any_image_pose.py \ 5 | --model_config model_lib/ControlNet/models/cldm_v15_reference_only_pose.yaml \ 6 | --num_train_steps 1 \ 7 | --img_bin_limit all \ 8 | --train_batch_size 1 \ 9 | --use_fp16 \ 10 | --control_mode controlnet_important \ 11 | --control_type body+hand+face \ 12 | --train_dataset tiktok_video_arnold \ 13 | --v4 \ 14 | --with_text \ 15 | --wonoise \ 16 | --local_image_dir ./tiktok_test_log/image_log/$imagename/$posepath/image \ 17 | --local_log_dir ./tiktok_test_log/tb_log/$imagename/$posepath/log \ 18 | --image_pretrain_dir ./pretrained_weights/model_state-110000.th \ 19 | --local_pose_path ./example_data/pose_sequence/$posepath \ 20 | --local_cond_image_path ./example_data/image/out-of-domain/$imagename.png \ 21 | $@ 22 | 23 | -------------------------------------------------------------------------------- /scripts/inference_tiktok_dataset.sh: -------------------------------------------------------------------------------- 1 | CUDA_VISIBLE_DEVICES=1 torchrun --master_port 10000 test_tiktok.py \ 2 | --model_config model_lib/ControlNet/models/cldm_v15_reference_only_pose.yaml \ 3 | --num_train_steps 10 \ 4 | --img_bin_limit all \ 5 | --train_batch_size 1 \ 6 | --use_fp16 \ 7 | --control_mode controlnet_important \ 8 | --control_type body+hand+face \ 9 | --train_dataset tiktok_video_arnold \ 10 | --with_text \ 11 | --wonoise \ 12 | --local_image_dir ./tiktok_test_log/image_log/magicdance \ 13 | --local_log_dir ./tiktok_test_log/tb_log/magicdance \ 14 | --image_pretrain_dir ./pretrained_weights/model_state-110000.th 15 | $@ 16 | 17 | -------------------------------------------------------------------------------- /tool/cleanfid/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Boese0601/MagicDance/a515a1f4a5fceb9abb3d2cabbc48958ba249e560/tool/cleanfid/__init__.py -------------------------------------------------------------------------------- /tool/metrics/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Boese0601/MagicDance/a515a1f4a5fceb9abb3d2cabbc48958ba249e560/tool/metrics/__init__.py -------------------------------------------------------------------------------- /tool/metrics/readme.md: -------------------------------------------------------------------------------- 1 | ### requirments 2 | 3 | sudo apt-get update 4 | sudo apt-get install ffmpeg 5 | pip install ffmpeg-python -------------------------------------------------------------------------------- /tool/test_SD2: -------------------------------------------------------------------------------- 1 | import requests 2 | import torch 3 | from PIL import Image 4 | from io import BytesIO 5 | 6 | from diffusers import StableUnCLIPImg2ImgPipeline 7 | 8 | #Start the StableUnCLIP Image variations pipeline 9 | pipe = StableUnCLIPImg2ImgPipeline.from_pretrained( 10 | "/datadrive_d/wangtan/azure_storage/vigstandard_data/linjli/debug_output/video_sythesis/diffusers/stable-diffusion-2-1-unclip", torch_dtype=torch.float16, variation="fp16" 11 | ) 12 | pipe = pipe.to("cuda") 13 | 14 | #Get image from URL 15 | url = "https://huggingface.co/datasets/hf-internal-testing/diffusers-images/resolve/main/stable_unclip/tarsila_do_amaral.png" 16 | response = requests.get(url) 17 | init_image = Image.open(BytesIO(response.content)).convert("RGB") 18 | 19 | #Pipe to make the variation 20 | images = pipe(init_image, height=256, width=256).images 21 | images[0].save("/home/tan/tarsila_variation.png") -------------------------------------------------------------------------------- /tool/video/gen_vid.py: -------------------------------------------------------------------------------- 1 | import cv2 2 | import numpy as np 3 | import os 4 | from tqdm import tqdm 5 | 6 | video_img_source_path = '' 7 | 8 | 9 | fps = 30 10 | size = (256, 256) 11 | codec = cv2.VideoWriter_fourcc(*"mp4v") 12 | 13 | # Initialize video writer 14 | video_writer = cv2.VideoWriter("{}_vid_output.mp4".format(video_img_source_path), codec, fps, size) 15 | folder_path = video_img_source_path 16 | # Get a list of all files in the folder 17 | files = os.listdir(folder_path) 18 | # Filter the list to only include image filesd 19 | image_files = [file for file in files if file.endswith(".jpg") or file.endswith(".png") or file.endswith(".jpeg")] 20 | num_frm = len(image_files) 21 | 22 | for image_fname_ in image_files: 23 | image_fname = '{}/{}'.format(folder_path,image_fname_) 24 | frame = cv2.imread(image_fname) 25 | # Write frames to video 26 | video_writer.write(frame) 27 | 28 | # Release resources 29 | video_writer.release() 30 | -------------------------------------------------------------------------------- /tool/video/gen_vid_command.py: -------------------------------------------------------------------------------- 1 | import cv2 2 | import numpy as np 3 | import os 4 | import argparse 5 | from tqdm import tqdm 6 | 7 | 8 | if __name__ == '__main__': 9 | parser = argparse.ArgumentParser(description='Get Video') 10 | parser.add_argument('--img_path', default=None, type=str, help='image frame path') 11 | args = parser.parse_args() 12 | 13 | video_img_source_path = args.img_path 14 | fps = 30 15 | size = (256, 256) 16 | codec = cv2.VideoWriter_fourcc(*"mp4v") 17 | 18 | # Initialize video writer 19 | video_writer = cv2.VideoWriter("{}_vid_output.mp4".format(video_img_source_path), codec, fps, size) 20 | folder_path = video_img_source_path 21 | # Get a list of all files in the folder 22 | files = os.listdir(folder_path) 23 | # Filter the list to only include image filesd 24 | image_files = [file for file in files if file.endswith(".jpg") or file.endswith(".png") or file.endswith(".jpeg")] 25 | num_frm = len(image_files) 26 | 27 | for image_fname_ in image_files: 28 | image_fname = '{}/{}'.format(folder_path, image_fname_) 29 | frame = cv2.imread(image_fname) 30 | # Write frames to video 31 | video_writer.write(frame) 32 | 33 | # Release resources 34 | video_writer.release() -------------------------------------------------------------------------------- /tool/video/reencode_vid_folder_forvis.py: -------------------------------------------------------------------------------- 1 | 2 | import os 3 | 4 | 5 | folder_name = '' 6 | save_folder_name = '' 7 | 8 | sub_folder_name_list = os.listdir(folder_name) 9 | sub_folder_name_list = [file for file in sub_folder_name_list if not 'json' in file] 10 | sub_folder_name_list.sort() 11 | 12 | for idx, sub_folder_name in enumerate(sub_folder_name_list): 13 | print(sub_folder_name) 14 | 15 | video_source_path = os.path.join(folder_name, sub_folder_name, 'cond_vid_output.mp4') 16 | video_target_path = os.path.join(folder_name, sub_folder_name, 'cond_vid_output_reencode.mp4') 17 | 18 | assert os.path.exists(video_source_path) 19 | 20 | if os.path.exists(video_target_path): 21 | print('remove the previous file') 22 | os.remove(video_target_path) 23 | os.system(f'ffmpeg -i {video_source_path} -c:v libx264 -c:a aac -strict -2 {video_target_path}') 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /tool/video/runsh/process_video_demo.sh: -------------------------------------------------------------------------------- 1 | export PYTHONUNBUFFERED=TRUE 2 | python tool/video/gen_vid_folder_forvis.py --start_idx 0 --end_idx 200 --gen_idx 1 > tool/video/runsh/cond_log11.txt & 3 | python tool/video/gen_vid_folder_forvis.py --start_idx 200 --end_idx 400 --gen_idx 1 > tool/video/runsh/cond_log12.txt & 4 | python tool/video/gen_vid_folder_forvis.py --start_idx 400 --end_idx 600 --gen_idx 1 > tool/video/runsh/cond_log13.txt & 5 | #python tool/video/gen_vid_folder_forvis.py --start_idx 600 --end_idx 800 > tool/video/runsh/cond_log4.txt & 6 | #python tool/video/gen_vid_folder_forvis.py --start_idx 800 --end_idx 1000 > tool/video/runsh/cond_log5.txt & 7 | #python tool/video/gen_vid_folder_forvis.py --start_idx 1000 --end_idx 1200 > tool/video/runsh/cond_log6.txt & 8 | #python tool/video/gen_vid_folder_forvis.py --start_idx 1200 --end_idx 1400 > tool/video/runsh/cond_log7.txt & 9 | #python tool/video/gen_vid_folder_forvis.py --start_idx 1400 --end_idx 1700 > tool/video/runsh/cond_log8.txt & 10 | 11 | python tool/video/gen_vid_folder_forvis.py --start_idx 0 --end_idx 200 --gen_idx 0 > tool/video/runsh/log11.txt & 12 | python tool/video/gen_vid_folder_forvis.py --start_idx 200 --end_idx 400 --gen_idx 0 > tool/video/runsh/log12.txt & 13 | python tool/video/gen_vid_folder_forvis.py --start_idx 400 --end_idx 600 --gen_idx 0 > tool/video/runsh/log13.txt & -------------------------------------------------------------------------------- /utils/__init__.py: -------------------------------------------------------------------------------- 1 | from .io_utils import mkdirs, pickle_load, pickle_dump, walk_all_files_with_suffix, get_dirs, get_leave_dirs, \ 2 | merge_pkl_dict 3 | 4 | from .time_utils import time_since, Timer 5 | from .txt_utils import log_info, write_str_to_txt, write_namespace_to_txt, read_txt_to_str, read_txt_to_namespace, \ 6 | replace_txt_str 7 | -------------------------------------------------------------------------------- /utils/time_utils.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | 3 | import time 4 | 5 | 6 | class Timer: 7 | def __init__(self): 8 | self.clock = {} 9 | 10 | def start(self, key="default"): 11 | self.clock[key] = time.time() 12 | 13 | def end(self, key="default"): 14 | if key not in self.clock: 15 | raise Exception("{} is not in the clock.".format(key)) 16 | interval = time.time() - self.clock[key] 17 | del self.clock[key] 18 | return interval 19 | 20 | 21 | def time_since(last_time): 22 | time_elapsed = time.time() - last_time 23 | current_time = time.time() 24 | return current_time, time_elapsed 25 | -------------------------------------------------------------------------------- /utils/txt_utils.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | 3 | import json 4 | import logging 5 | import argparse 6 | 7 | 8 | def log_info(s, use_log=True): 9 | if use_log: 10 | logging.info(s) 11 | else: 12 | print(s) 13 | 14 | 15 | def write_str_to_txt(file_path, str, mode='a'): 16 | with open(file_path, mode) as f: 17 | f.write(str) 18 | 19 | 20 | def write_namespace_to_txt(file_path, json_str, indent=4): 21 | with open(file_path, 'a') as f: 22 | f.write(json.dumps(vars(json_str), indent=indent)) 23 | f.write('\n') 24 | 25 | 26 | def read_txt_to_str(file_path): 27 | with open(file_path, 'r') as f: 28 | info_list = f.read().splitlines() 29 | return info_list 30 | 31 | 32 | def read_txt_to_namespace(file_path): 33 | with open(file_path, 'r') as f: 34 | json_str = json.load(f) 35 | args = argparse.Namespace(**json_str) 36 | if type(args.loss_choice) is str: 37 | # 向旧版本cfg兼容 38 | args.loss_choice=[args.loss_choice] 39 | args.loss_lambda=[1] 40 | args.loss_return_dict=False 41 | return args 42 | 43 | 44 | def replace_txt_str(txt_path, old_str, new_str): 45 | file_data = '' 46 | with open(txt_path, 'r') as f: 47 | for idx, line in enumerate(f): 48 | if old_str in line: 49 | line = line.replace(old_str, new_str) 50 | file_data += line 51 | with open(txt_path, 'w') as f: 52 | f.write(file_data) 53 | --------------------------------------------------------------------------------