pip install git+https://github.hmckmc.co.kr/airlab/segpack
(github ID, password 입력 필요)
# training
>>> from segpack import train
>>> train("train_data_name", "val_data_name", "pretrained_network_name", "config_name")
# inference directory structure
root
└── inference
└── image_file1.jpeg
└── image_file2.jpeg
└── ...
# generate png (segmentation map)
>>> from segpack.convert import generate_pseudolabels
>>> generate_pseudolabels("path/to/root", "pretrained_network_name", "segmap", "path/to/output/dir", "segmentation_resize")
# generate labelme readable json
>>> from segpack.convert import generate_pseudolabels
>>> generate_pseudolabels("path/to/root", "pretrained_network_name", "labelme", "path/to/output/dir", "segmentation_resize")
# convert to torchscript model (for faster inference)
>>> from segpack.deploy import generate_jit
>>> generate_jit("bodysealer_test", 2049, 2449, "output/jit")
# run torchscript model (copy codes of Deployer for actual deployment)
>>> from segpack.deploy import Deployer
>>> deployer = Deployer("output/jit/network_jit.pt", (2049,2449), (2048,2448), [0.485, 0.456, 0.406], [0.229, 0.224, 0.225])
>>> result = deployer.inference("samples/img_seg_pairs/image/1.jpg")
# convert format (png -> labelme)
>>> from segpack.convert import convert_format
>>> convert_format("samples/img_seg_pairs", "path/to/output/dir", "segmap", "labelme")
# convert format (labelme -> png)
>>> from segpack.convert import convert_format
>>> convert_format("samples/labelme", "path/to/output/dir", "labelme", "segmap", {"__ignore__": -1, "_background_": 0, "1": 1, "2": 2, "3": 3})