MCPcopy Index your code
hub / github.com/AICVHub/Copy-Paste-for-Semantic-Segmentation

github.com/AICVHub/Copy-Paste-for-Semantic-Segmentation @main

Chat with this repo
repository ↗ · DeepWiki ↗ · + Follow
11 symbols 37 edges 2 files 0 documented · 0%
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

typora-root-url: images

Copy-Paste-for-Semantic-Segmentation

Unofficial implementation of Copy-Paste method: Simple Copy-Paste is a Strong Data Augmentation Method for Instance Segmentation.

This repo is implementation for semantic segmentation. You can use also in instance segmentation.

We do it at VOC-like dataset. If your dataset is coco-like, you need extract mask from coco first.

More details see blog.

methods used in this repo:

  1. Random Horizontal Flip
  2. Large Scale Jittering
  3. Copy-Paste

Steps:

  1. choice source image and main image;
  2. get annotations from source image;
  3. rescale source image and it annotations;
  4. paste source image and annotations to main image and annotations;
  5. merge main annotations and source annotations;

Usage:

If use coco-like dataset, you need run get_coco_mask.py first:

usage: get_coco_mask.py [-h] [--input_dir INPUT_DIR] [--split SPLIT]

optional arguments:
  -h, --help            show this help message and exit
  --input_dir INPUT_DIR
                        coco dataset directory
  --split SPLIT         train2017 or val2017

And then, run copy_paste.py:

usage: copy_paste.py [-h] [--input_dir INPUT_DIR] [--output_dir OUTPUT_DIR]
                     [--lsj LSJ]

optional arguments:
  -h, --help            show this help message and exit
  --input_dir INPUT_DIR
                        input annotated directory
  --output_dir OUTPUT_DIR
                        output dataset directory
  --lsj LSJ             if use Large Scale Jittering

If your dataset is voc-like, just run copy_paste.py.

Examples:

example of get_coco_mask.py:

python copy_paste.py --input_dir ../dataset/coco2017 --split train2017

example of copy_paste.py:

python copy_paste.py --input_dir ../dataset/VOCdevkit2012/VOC2012 --output_dir ../dataset/VOCdevkit2012/VOC2012_copy_paste --lsj True

Results:

main image + source image:

image

main anno + source anno:

image

visualization:

vis

Core symbols most depended-on inside this repo

random_flip_horizontal
called by 2
copy_paste.py
img_add
called by 2
copy_paste.py
Large_Scale_Jittering
called by 2
copy_paste.py
save_colored_mask
called by 1
get_coco_mask.py
main
called by 1
get_coco_mask.py
get_args
called by 1
get_coco_mask.py
save_colored_mask
called by 1
copy_paste.py
rescale_src
called by 1
copy_paste.py

Shape

Function 11

Languages

Python100%

Modules by API surface

copy_paste.py8 symbols
get_coco_mask.py3 symbols

For agents

$ claude mcp add Copy-Paste-for-Semantic-Segmentation \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact