### Setup AniLines Environment Source: https://github.com/vivocameraresearch/magic-tryon/blob/main/inference/customize/AniLines/README.md Clone the repository, create a conda environment, and install dependencies. Ensure you have Python 3.12 or compatible. ```bash git clone https://github.com/zhenglinpan/AniLines-Anime-Line-Extractor.git cd AniLines-Anime-Line-Extractor conda create -n anilines python=3.12 -y conda activate anilines pip install -r requirements.txt ``` -------------------------------- ### Install Detectron2 from Source (Git Clone) Source: https://github.com/vivocameraresearch/magic-tryon/blob/main/inference/customize/detectron2/INSTALL.md Install Detectron2 by cloning the repository and installing it in editable mode. This is useful for development or when needing the latest features. ```bash git clone https://github.com/facebookresearch/detectron2.git python -m pip install -e detectron2 ``` -------------------------------- ### Install PanopticAPI Source: https://github.com/vivocameraresearch/magic-tryon/blob/main/inference/customize/gen_mask/preprocess/humanparsing/mhp_extension/detectron2/docs/tutorials/builtin_datasets.md Install the panopticapi library from its GitHub repository. This is required for setting up datasets for PanopticFPN. ```bash pip install git+https://github.com/cocodataset/panopticapi.git ``` -------------------------------- ### Install Detectron2 from Source (GitHub) Source: https://github.com/vivocameraresearch/magic-tryon/blob/main/inference/customize/gen_mask/preprocess/humanparsing/mhp_extension/detectron2/INSTALL.md Installs Detectron2 directly from its GitHub repository. Use '--user' if you lack sufficient permissions. ```bash python -m pip install 'git+https://github.com/facebookresearch/detectron2.git' ``` -------------------------------- ### Install TensorMask Project Source: https://github.com/vivocameraresearch/magic-tryon/blob/main/inference/customize/detectron2/projects/TensorMask/README.md Install the TensorMask project within Detectron2. Ensure Detectron2 is installed and the dataset is set up before compiling the TensorMask-specific op. ```bash pip install -e /path/to/detectron2/projects/TensorMask ``` -------------------------------- ### Install Detectron2 from Source (Pip) Source: https://github.com/vivocameraresearch/magic-tryon/blob/main/inference/customize/detectron2/INSTALL.md Install Detectron2 directly from its GitHub repository using pip. Use the --user flag if you lack system-wide permissions. ```bash python -m pip install 'git+https://github.com/facebookresearch/detectron2.git' # (add --user if you don't have permission) ``` -------------------------------- ### Install Detectron2 (CPU, PyTorch 1.8) Source: https://github.com/vivocameraresearch/magic-tryon/blob/main/inference/customize/detectron2/INSTALL.md Install a pre-built Detectron2 wheel for CPU-only environments with PyTorch 1.8. This is for Linux systems only. ```bash python -m pip install detectron2 -f https://dl.fbaipublicfiles.com/detectron2/wheels/cpu/torch1.8/index.html ``` -------------------------------- ### Install Detectron2 (CPU, PyTorch 1.10) Source: https://github.com/vivocameraresearch/magic-tryon/blob/main/inference/customize/detectron2/INSTALL.md Install a pre-built Detectron2 wheel for CPU-only environments with PyTorch 1.10. This is for Linux systems only. ```bash python -m pip install detectron2 -f https://dl.fbaipublicfiles.com/detectron2/wheels/cpu/torch1.10/index.html ``` -------------------------------- ### Install LVIS API Source: https://github.com/vivocameraresearch/magic-tryon/blob/main/inference/customize/gen_mask/preprocess/humanparsing/mhp_extension/detectron2/docs/tutorials/builtin_datasets.md Install the lvis-api library from its GitHub repository. This is needed for working with LVIS datasets in Detectron2. ```bash pip install git+https://github.com/lvis-dataset/lvis-api.git ``` -------------------------------- ### Install Detectron2 (CPU, PyTorch 1.9) Source: https://github.com/vivocameraresearch/magic-tryon/blob/main/inference/customize/detectron2/INSTALL.md Install a pre-built Detectron2 wheel for CPU-only environments with PyTorch 1.9. This is for Linux systems only. ```bash python -m pip install detectron2 -f https://dl.fbaipublicfiles.com/detectron2/wheels/cpu/torch1.9/index.html ``` -------------------------------- ### Training Schedule Example Source: https://github.com/vivocameraresearch/magic-tryon/blob/main/inference/customize/detectron2/docs/notes/benchmarks.md This example demonstrates a multi-stage training schedule. Adjust the learning rate, epochs, layers to fine-tune, and augmentation as needed for your specific task. ```python model.train(dataset_train, dataset_val, learning_rate=config.LEARNING_RATE, epochs=40, layers='3+', augmentation=augmentation) ``` -------------------------------- ### Install Cityscapes Scripts Source: https://github.com/vivocameraresearch/magic-tryon/blob/main/inference/customize/detectron2/datasets/README.md Install the necessary scripts for processing the Cityscapes dataset. ```bash pip install git+https://github.com/mcordts/cityscapesScripts.git ``` -------------------------------- ### Install Detectron2 from Local Clone (macOS) Source: https://github.com/vivocameraresearch/magic-tryon/blob/main/inference/customize/gen_mask/preprocess/humanparsing/mhp_extension/detectron2/INSTALL.md Specific installation command for macOS users when installing from a local clone. ```bash # CC=clang CXX=clang++ python -m pip install -e . ``` -------------------------------- ### Install Detectron2 (CUDA 10.1, PyTorch 1.8) Source: https://github.com/vivocameraresearch/magic-tryon/blob/main/inference/customize/detectron2/INSTALL.md Install a pre-built Detectron2 wheel compatible with CUDA 10.1 and PyTorch 1.8. This is for Linux systems only. ```bash python -m pip install detectron2 -f https://dl.fbaipublicfiles.com/detectron2/wheels/cu101/torch1.8/index.html ``` -------------------------------- ### Install and Prepare Panoptic FPN Annotations Source: https://github.com/vivocameraresearch/magic-tryon/blob/main/inference/customize/detectron2/datasets/README.md Install the panopticapi library and run a script to extract semantic annotations from COCO panoptic annotations for PanopticFPN. ```bash pip install git+https://github.com/cocodataset/panopticapi.git ``` ```python python datasets/prepare_panoptic_fpn.py ``` -------------------------------- ### Command Line Config Overwrite Example Source: https://github.com/vivocameraresearch/magic-tryon/blob/main/inference/customize/detectron2/docs/tutorials/configs.md Illustrates how to overwrite configuration values using command-line arguments with demo.py. ```bash ./demo.py --config-file config.yaml [--other-options] \ --opts MODEL.WEIGHTS /path/to/weights INPUT.MIN_SIZE_TEST 1000 ``` -------------------------------- ### Trainer Log Output Example Source: https://github.com/vivocameraresearch/magic-tryon/blob/main/inference/customize/detectron2/projects/DensePose/doc/BOOTSTRAPPING_PIPELINE.md Example log output from the DensePose trainer showing the proportion of data from different sources in a batch. ```text [... densepose.engine.trainer]: batch/ 1.8, batch/base_coco_2017_train 6.4, batch/densepose_coco_2014_train 3.85 ``` -------------------------------- ### Install DensePose as a Python Package Source: https://github.com/vivocameraresearch/magic-tryon/blob/main/inference/customize/detectron2/projects/DensePose/doc/GETTING_STARTED.md Install DensePose from its GitHub repository using pip. This command installs the package and makes it importable as 'densepose'. ```bash pip install git+https://github.com/facebookresearch/detectron2@main#subdirectory=projects/DensePose ``` -------------------------------- ### Install Detectron2 (CUDA 10.2, PyTorch 1.10) Source: https://github.com/vivocameraresearch/magic-tryon/blob/main/inference/customize/detectron2/INSTALL.md Install a pre-built Detectron2 wheel compatible with CUDA 10.2 and PyTorch 1.10. This is for Linux systems only. ```bash python -m pip install detectron2 -f https://dl.fbaipublicfiles.com/detectron2/wheels/cu102/torch1.10/index.html ``` -------------------------------- ### Install Detectron2 (CUDA 10.2, PyTorch 1.8) Source: https://github.com/vivocameraresearch/magic-tryon/blob/main/inference/customize/detectron2/INSTALL.md Install a pre-built Detectron2 wheel compatible with CUDA 10.2 and PyTorch 1.8. This is for Linux systems only. ```bash python -m pip install detectron2 -f https://dl.fbaipublicfiles.com/detectron2/wheels/cu102/torch1.8/index.html ``` -------------------------------- ### Manually Install Flash Attention Source: https://github.com/vivocameraresearch/magic-tryon/blob/main/README.md If encountering errors during Flash Attention installation, manually download the appropriate wheel file based on your Python, CUDA, and Torch versions, then install using pip. ```shell pip install flash_attn-2.7.3+cu12torch2.2cxx11abiFALSE-cp312-cp312-linux_x86_64.whl ``` -------------------------------- ### Install Detectron2 (CUDA 11.1, PyTorch 1.8) Source: https://github.com/vivocameraresearch/magic-tryon/blob/main/inference/customize/detectron2/INSTALL.md Install a pre-built Detectron2 wheel compatible with CUDA 11.1 and PyTorch 1.8. This is for Linux systems only. ```bash python -m pip install detectron2 -f https://dl.fbaipublicfiles.com/detectron2/wheels/cu111/torch1.8/index.html ``` -------------------------------- ### Install Detectron2 (CUDA 11.1, PyTorch 1.9) Source: https://github.com/vivocameraresearch/magic-tryon/blob/main/inference/customize/detectron2/INSTALL.md Install a pre-built Detectron2 wheel compatible with CUDA 11.1 and PyTorch 1.9. This is for Linux systems only. ```bash python -m pip install detectron2 -f https://dl.fbaipublicfiles.com/detectron2/wheels/cu111/torch1.9/index.html ``` -------------------------------- ### Install Detectron2 (CUDA 11.1, PyTorch 1.10) Source: https://github.com/vivocameraresearch/magic-tryon/blob/main/inference/customize/detectron2/INSTALL.md Install a pre-built Detectron2 wheel compatible with CUDA 11.1 and PyTorch 1.10. This is for Linux systems only. ```bash python -m pip install detectron2 -f https://dl.fbaipublicfiles.com/detectron2/wheels/cu111/torch1.10/index.html ``` -------------------------------- ### Train TridentNet with ResNet-50 Source: https://github.com/vivocameraresearch/magic-tryon/blob/main/inference/customize/detectron2/projects/TridentNet/README.md Example command to launch end-to-end TridentNet training using ResNet-50 backbone on 8 GPUs. Ensure the config file path is correct. ```bash python /path/to/detectron2/projects/TridentNet/train_net.py --config-file configs/tridentnet_fast_R_50_C4_1x.yaml --num-gpus 8 ``` -------------------------------- ### Install Pre-Built Detectron2 (Linux CUDA 10.1) Source: https://github.com/vivocameraresearch/magic-tryon/blob/main/inference/customize/gen_mask/preprocess/humanparsing/mhp_extension/detectron2/INSTALL.md Installs a pre-built Detectron2 wheel for Linux systems with CUDA 10.1. Replace 'cu101' with other CUDA versions or 'cpu' as needed. ```bash # for CUDA 10.1: python -m pip install detectron2 -f https://dl.fbaipublicfiles.com/detectron2/wheels/cu101/index.html ``` -------------------------------- ### Install Detectron2 (CUDA 10.2, PyTorch 1.9) Source: https://github.com/vivocameraresearch/magic-tryon/blob/main/inference/customize/detectron2/INSTALL.md Install a pre-built Detectron2 wheel compatible with CUDA 10.2 and PyTorch 1.9. This is for Linux systems only. ```bash python -m pip install detectron2 -f https://dl.fbaipublicfiles.com/detectron2/wheels/cu102/torch1.9/index.html ``` -------------------------------- ### Compile and Run Caffe2 Mask R-CNN Example Source: https://github.com/vivocameraresearch/magic-tryon/blob/main/inference/customize/gen_mask/preprocess/humanparsing/mhp_extension/detectron2/docs/tutorials/deployment.md Compiles and runs a C++ example for CPU/GPU inference using a converted Caffe2 Mask R-CNN model. Ensure all dependencies and build configurations are met. ```bash sudo apt update && sudo apt install libgflags-dev libgoogle-glog-dev libopencv-dev pip install mkl-include wget https://github.com/protocolbuffers/protobuf/releases/download/v3.6.1/protobuf-cpp-3.6.1.tar.gz tar xf protobuf-cpp-3.6.1.tar.gz export CPATH=$(readlink -f ./protobuf-3.6.1/src/):$HOME/.local/include export CMAKE_PREFIX_PATH=$HOME/.local/lib/python3.6/site-packages/torch/ mkdir build && cd build cmake -DTORCH_CUDA_ARCH_LIST=$TORCH_CUDA_ARCH_LIST .. && make # To run: ./caffe2_mask_rcnn --predict_net=./model.pb --init_net=./model_init.pb --input=input.jpg ``` -------------------------------- ### Install Detectron2 (CUDA 11.3, PyTorch 1.10) Source: https://github.com/vivocameraresearch/magic-tryon/blob/main/inference/customize/detectron2/INSTALL.md Install a pre-built Detectron2 wheel compatible with CUDA 11.3 and PyTorch 1.10. This is for Linux systems only. ```bash python -m pip install detectron2 -f https://dl.fbaipublicfiles.com/detectron2/wheels/cu113/torch1.10/index.html ``` -------------------------------- ### Build and Launch Detectron2 Deployment Docker Container Source: https://github.com/vivocameraresearch/magic-tryon/blob/main/inference/customize/detectron2/docker/README.md Builds a Docker image for deploying Detectron2 with C++ examples and launches an interactive container with GPU support. ```bash # Build: docker build -t detectron2-deploy:v0 -f deploy.Dockerfile . # Launch: docker run --gpus all -it detectron2-deploy:v0 ``` -------------------------------- ### Launch TensorMask BiPyramid Training Source: https://github.com/vivocameraresearch/magic-tryon/blob/main/inference/customize/gen_mask/preprocess/humanparsing/mhp_extension/detectron2/projects/TensorMask/README.md Example command to launch TensorMask BiPyramid training with a ResNet-50 backbone and a 1x schedule on 8 GPUs. Ensure the config file path is correct. ```bash python /path/to/detectron2/projects/TensorMask/train_net.py --config-file configs/tensormask_R_50_FPN_1x.yaml --num-gpus 8 ``` -------------------------------- ### Install and Prepare Cocofied LVIS Annotations Source: https://github.com/vivocameraresearch/magic-tryon/blob/main/inference/customize/detectron2/datasets/README.md Install the lvis-api and run a script to prepare 'cocofied' LVIS annotations for evaluating models trained on COCO. ```bash pip install git+https://github.com/lvis-dataset/lvis-api.git ``` ```python python datasets/prepare_cocofied_lvis.py ``` -------------------------------- ### Show Bounding Box and V Coordinate Visualization Source: https://github.com/vivocameraresearch/magic-tryon/blob/main/inference/customize/gen_mask/preprocess/humanparsing/mhp_extension/detectron2/projects/DensePose/doc/TOOL_APPLY_NET.md Example command to visualize bounding boxes and the estimated V coordinates for body parts. Specify 'bbox,dp_v' for the visualizations. ```bash python apply_net.py show configs/densepose_rcnn_R_50_FPN_s1x.yaml DensePose_ResNet50_FPN_s1x-e2e.pkl image.jpg bbox,dp_v -v ``` -------------------------------- ### Show Bounding Box and U Coordinate Visualization Source: https://github.com/vivocameraresearch/magic-tryon/blob/main/inference/customize/gen_mask/preprocess/humanparsing/mhp_extension/detectron2/projects/DensePose/doc/TOOL_APPLY_NET.md Example command to visualize bounding boxes and the estimated U coordinates for body parts. Use 'bbox,dp_u' for the visualizations argument. ```bash python apply_net.py show configs/densepose_rcnn_R_50_FPN_s1x.yaml DensePose_ResNet50_FPN_s1x-e2e.pkl image.jpg bbox,dp_u -v ``` -------------------------------- ### Visualize Bounding Box and Segmentation Source: https://github.com/vivocameraresearch/magic-tryon/blob/main/inference/customize/gen_mask/preprocess/humanparsing/mhp_extension/detectron2/projects/DensePose/doc/TOOL_QUERY_DB.md Example of visualizing bounding boxes and segmentation masks for a specific image. The -v flag enables verbose output. ```bash python query_db.py show densepose_coco_2014_train image_id:int=322 bbox,dp_segm -v ``` -------------------------------- ### Start AniLines Gradio UI Source: https://github.com/vivocameraresearch/magic-tryon/blob/main/inference/customize/AniLines/README.md Launch the Gradio web interface for AniLines locally. This allows for interactive processing of images, videos, and batch files. ```bash python app.py ``` -------------------------------- ### Visualize Bounding Box and Point Labels Source: https://github.com/vivocameraresearch/magic-tryon/blob/main/inference/customize/gen_mask/preprocess/humanparsing/mhp_extension/detectron2/projects/DensePose/doc/TOOL_QUERY_DB.md Example of visualizing bounding boxes and points colored by their containing part for a specific image. The -v flag enables verbose output. ```bash python query_db.py show densepose_coco_2014_train image_id:int=322 bbox,dp_i -v ``` -------------------------------- ### Show Bounding Box and Contour Visualization Source: https://github.com/vivocameraresearch/magic-tryon/blob/main/inference/customize/gen_mask/preprocess/humanparsing/mhp_extension/detectron2/projects/DensePose/doc/TOOL_APPLY_NET.md Example command to visualize bounding boxes and contour plots with color-coded U and V coordinates. Use 'dp_contour,bbox' for the visualizations. ```bash python apply_net.py show configs/densepose_rcnn_R_50_FPN_s1x.yaml DensePose_ResNet50_FPN_s1x-e2e.pkl image.jpg dp_contour,bbox -v ``` -------------------------------- ### Visualize Bounding Box and U Coordinate Points Source: https://github.com/vivocameraresearch/magic-tryon/blob/main/inference/customize/gen_mask/preprocess/humanparsing/mhp_extension/detectron2/projects/DensePose/doc/TOOL_QUERY_DB.md Example of visualizing bounding boxes and points colored by their U coordinate for a specific image. The -v flag enables verbose output. ```bash python query_db.py show densepose_coco_2014_train image_id:int=322 bbox,dp_u -v ``` -------------------------------- ### Visualize Bounding Box and V Coordinate Points Source: https://github.com/vivocameraresearch/magic-tryon/blob/main/inference/customize/gen_mask/preprocess/humanparsing/mhp_extension/detectron2/projects/DensePose/doc/TOOL_QUERY_DB.md Example of visualizing bounding boxes and points colored by their V coordinate for a specific image. The -v flag enables verbose output. ```bash python query_db.py show densepose_coco_2014_train image_id:int=322 bbox,dp_v -v ``` -------------------------------- ### DensePose Bootstrapping Configuration Source: https://github.com/vivocameraresearch/magic-tryon/blob/main/inference/customize/detectron2/projects/DensePose/doc/BOOTSTRAPPING_PIPELINE.md Example YAML configuration for bootstrapping DensePose datasets. Specifies dataset details, image loading, inference parameters, data sampling, and filtering criteria. ```yaml BOOTSTRAP_DATASETS: - DATASET: "chimpnsee" RATIO: 1.0 IMAGE_LOADER: TYPE: "video_keyframe" SELECT: STRATEGY: "random_k" NUM_IMAGES: 4 TRANSFORM: TYPE: "resize" MIN_SIZE: 800 MAX_SIZE: 1333 BATCH_SIZE: 8 NUM_WORKERS: 1 INFERENCE: INPUT_BATCH_SIZE: 1 OUTPUT_BATCH_SIZE: 1 DATA_SAMPLER: # supported types: # densepose_uniform # densepose_UV_confidence # densepose_fine_segm_confidence # densepose_coarse_segm_confidence TYPE: "densepose_uniform" COUNT_PER_CLASS: 8 FILTER: TYPE: "detection_score" MIN_VALUE: 0.8 BOOTSTRAP_MODEL: WEIGHTS: https://dl.fbaipublicfiles.com/densepose/evolution/densepose_R_50_FPN_DL_WC1M_3x_Atop10P_CA/217578784/model_final_9fe1cc.pkl ``` -------------------------------- ### Basic CfgNode Usage Source: https://github.com/vivocameraresearch/magic-tryon/blob/main/inference/customize/detectron2/docs/tutorials/configs.md Demonstrates obtaining default configurations, adding custom settings, merging from files and lists, and saving/printing configurations. ```python from detectron2.config import get_cfg cfg = get_cfg() # obtain detectron2's default config cfg.xxx = yyy # add new configs for your own custom components cfg.merge_from_file("my_cfg.yaml") # load values from a file cfg.merge_from_list(["MODEL.WEIGHTS", "weights.pth"]) # can also load values from a list of str print(cfg.dump()) # print formatted configs with open("output.yaml", "w") as f: f.write(cfg.dump()) # save config to file ``` -------------------------------- ### Install pycocotools Source: https://github.com/vivocameraresearch/magic-tryon/blob/main/inference/customize/gen_mask/preprocess/humanparsing/mhp_extension/detectron2/INSTALL.md Installs the pycocotools package, which is required for COCO dataset operations and visualizations. ```bash pip install cython; pip install -U 'git+https://github.com/cocodataset/cocoapi.git#subdirectory=PythonAPI' ``` -------------------------------- ### Show Bounding Box and Segmentation Source: https://github.com/vivocameraresearch/magic-tryon/blob/main/inference/customize/gen_mask/preprocess/humanparsing/mhp_extension/detectron2/projects/DensePose/doc/TOOL_APPLY_NET.md Example command to visualize bounding boxes and segmentation masks for detected persons. Requires a configuration file, model file, input image, and 'bbox,dp_segm' as visualizations. ```bash python apply_net.py show configs/densepose_rcnn_R_50_FPN_s1x.yaml DensePose_ResNet50_FPN_s1x-e2e.pkl image.jpg bbox,dp_segm -v ``` -------------------------------- ### Install New Dependencies in Dockerfile Source: https://github.com/vivocameraresearch/magic-tryon/blob/main/inference/customize/detectron2/docker/README.md Adds a RUN command to the Dockerfile to install new system dependencies using apt-get. This makes persistent changes to the image. ```dockerfile RUN sudo apt-get update && sudo apt-get install -y vim ``` -------------------------------- ### Install Project Requirements Source: https://github.com/vivocameraresearch/magic-tryon/blob/main/README.md Create a conda environment and install project dependencies using the provided requirements file or environment.yaml. Ensure Python, CUDA, and Torch versions are compatible. ```shell conda create -n magictryon python==3.12.9 conda activate magictryon pip install -r requirements.txt ``` ```shell conda env create -f environment.yaml ``` -------------------------------- ### Example of BGR Input Format Source: https://github.com/vivocameraresearch/magic-tryon/blob/main/inference/customize/detectron2/docs/tutorials/extend.md This snippet shows how to specify the input format as BGR when configuring Detectron2. ```python input_format="BGR", ) ``` -------------------------------- ### Video Try-On Inference Source: https://github.com/vivocameraresearch/magic-tryon/blob/main/README.md Execute the video try-on demo using the specified Python scripts. Assign the CUDA device and adjust inference parameters in the script as needed. ```powershell CUDA_VISIBLE_DEVICES=0 python inference/video_tryon/predict_video_tryon_up.py ``` ```powershell CUDA_VISIBLE_DEVICES=1 python inference/video_tryon/predict_video_tryon_low.py ``` -------------------------------- ### Compile TensorMask Op Source: https://github.com/vivocameraresearch/magic-tryon/blob/main/inference/customize/gen_mask/preprocess/humanparsing/mhp_extension/detectron2/projects/TensorMask/README.md Compile the TensorMask-specific op 'swap_align2nat' after installing Detectron2 and setting up the dataset. This is a prerequisite for using TensorMask. ```bash cd /path/to/detectron2/projects/TensorMask python setup.py build develop ``` -------------------------------- ### Build All Wheels and Generate Index Source: https://github.com/vivocameraresearch/magic-tryon/blob/main/inference/customize/detectron2/dev/packaging/README.md Execute these scripts to build wheels for all supported CUDA and Python combinations and then generate an index file for them. ```bash ./dev/packaging/build_all_wheels.sh ./dev/packaging/gen_wheel_index.sh /path/to/wheels ``` -------------------------------- ### Print First 10 Entries Source: https://github.com/vivocameraresearch/magic-tryon/blob/main/inference/customize/gen_mask/preprocess/humanparsing/mhp_extension/detectron2/projects/DensePose/doc/TOOL_QUERY_DB.md Example of printing at most 10 entries from the densepose_coco_2014_train dataset. The -v flag enables verbose output. ```bash python query_db.py print densepose_coco_2014_train \* --max-entries 10 -v ``` -------------------------------- ### Basic CfgNode Usage in Detectron2 Source: https://github.com/vivocameraresearch/magic-tryon/blob/main/inference/customize/gen_mask/preprocess/humanparsing/mhp_extension/detectron2/docs/tutorials/configs.md Demonstrates obtaining default configurations, adding custom settings, merging from files and lists, and printing the formatted configuration. Use this for initializing and modifying Detectron2's configuration settings. ```python from detectron2.config import get_cfg cfg = get_cfg() # obtain detectron2's default config cfg.xxx = yyy # add new configs for your own custom components cfg.merge_from_file("my_cfg.yaml") # load values from a file cfg.merge_from_list(["MODEL.WEIGHTS", "weights.pth"]) # can also load values from a list of str print(cfg.dump()) # print formatted configs ``` -------------------------------- ### Train Panoptic-DeepLab Model Source: https://github.com/vivocameraresearch/magic-tryon/blob/main/inference/customize/detectron2/projects/Panoptic-DeepLab/README.md Use this command to train a Panoptic-DeepLab model on a dataset like Cityscapes. Ensure Detectron2 is installed and data is prepared. ```bash cd /path/to/detectron2/projects/Panoptic-DeepLab python train_net.py --config-file configs/Cityscapes-PanopticSegmentation/panoptic_deeplab_R_52_os16_mg124_poly_90k_bs32_crop_512_1024_dsconv.yaml --num-gpus 8 ``` -------------------------------- ### Build and Run Detectron2 Docker Container (docker ≥ 19.03) Source: https://github.com/vivocameraresearch/magic-tryon/blob/main/inference/customize/gen_mask/preprocess/humanparsing/mhp_extension/detectron2/docker/README.md Builds the Detectron2 Docker image and runs it with GPU support. Grants access to the host X server for displaying images. ```bash cd docker/ # Build: docker build --build-arg USER_ID=$UID -t detectron2:v0 . # Run: docker run --gpus all -it \ --shm-size=8gb --env="DISPLAY" --volume="/tmp/.X11-unix:/tmp/.X11-unix:rw" \ --name=detectron2 detectron2:v0 # Grant docker access to host X server to show images xhost +local:`docker inspect --format='{{ .Config.Hostname }}' detectron2` ``` -------------------------------- ### Print Entries by File Name Source: https://github.com/vivocameraresearch/magic-tryon/blob/main/inference/customize/gen_mask/preprocess/humanparsing/mhp_extension/detectron2/projects/DensePose/doc/TOOL_QUERY_DB.md Example of printing all entries where the file_name matches a specific value. The -v flag enables verbose output. ```bash python query_db.py print densepose_coco_2014_train file_name=COCO_train2014_000000000036.jpg -v ``` -------------------------------- ### Run Inference Demo with Pre-trained Models Source: https://github.com/vivocameraresearch/magic-tryon/blob/main/inference/customize/detectron2/GETTING_STARTED.md Use the demo.py script to run inference on images using pre-trained models from the model zoo. Specify input files, configuration, and model weights. Common options include running on webcam, video, or CPU, and saving outputs. ```bash cd demo/ python demo.py --config-file ../configs/COCO-InstanceSegmentation/mask_rcnn_R_50_FPN_3x.yaml \ --input input1.jpg input2.jpg \ [--other-options] \ --opts MODEL.WEIGHTS detectron2://COCO-InstanceSegmentation/mask_rcnn_R_50_FPN_3x/137849600/model_final_f10217.pkl ```