Пример #1
0
def download_datasets(output_path):
    """Helper tool to download datasets

    Args:
        output_path (str): path where to download and unzip the dataset
    """
    from torchvision.datasets.sbd import SBDataset
    from torchvision.datasets.voc import VOCSegmentation

    output_path = Path(output_path)
    output_path.mkdir(parents=True, exist_ok=True)

    print("Download Pascal VOC 2012 - Training")
    VOCSegmentation(output_path.as_posix(), image_set="train", download=True)
    print("Download Pascal VOC 2012 - Validation")
    VOCSegmentation(output_path.as_posix(), image_set="val", download=True)
    print("Download SBD - Training without Pascal VOC validation part")
    sbd_path = output_path / "SBD"
    sbd_path.mkdir(exist_ok=True)
    SBDataset(sbd_path.as_posix(),
              image_set="train_noval",
              mode="segmentation",
              download=True)
    print("Done")
    print(f"Pascal VOC 2012 is at : {(output_path / 'VOCdevkit').as_posix()}")
    print(f"SBD is at : {sbd_path.as_posix()}")
Пример #2
0
import argparse
import os

from torchvision.datasets.sbd import SBDataset
from torchvision.datasets.voc import VOCSegmentation

if __name__ == "__main__":
    parser = argparse.ArgumentParser(
        "Download Pascal VOC 2012 and SBD segmentation datasets"
    )
    parser.add_argument(
        "output_path", type=str, help="Path where to download and unzip the dataset"
    )

    args = parser.parse_args()

    print("Download Pascal VOC 2012 - Training")
    VOCSegmentation(args.output_path, image_set="train", download=True)
    print("Download Pascal VOC 2012 - Validation")
    VOCSegmentation(args.output_path, image_set="val", download=True)
    print("Download SBD - Training without Pascal VOC validation part")
    sbd_path = os.path.join(args.output_path, "SBD")
    os.makedirs(sbd_path, exist_ok=True)
    SBDataset(sbd_path, image_set="train_noval", mode="segmentation", download=True)
    print("Done")
    print(
        "Pascal VOC 2012 is at : {}".format(os.path.join(args.output_path, "VOCdevkit"))
    )
    print("SBD is at : {}".format(sbd_path))
Пример #3
0
import os
import argparse

from torchvision.datasets.voc import VOCSegmentation
from torchvision.datasets.sbd import SBDataset

if __name__ == "__main__":
    parser = argparse.ArgumentParser(
        "Download Pascal VOC 2012 and SBD segmentation datasets")
    parser.add_argument("output_path",
                        type=str,
                        help="Path where to download and unzip the dataset")

    args = parser.parse_args()

    print("Download Pascal VOC 2012 - Training")
    VOCSegmentation(args.output_path, image_set='train', download=True)
    print("Download Pascal VOC 2012 - Validation")
    VOCSegmentation(args.output_path, image_set='val', download=True)
    print("Download SBD - Training without Pascal VOC validation part")
    sbd_path = os.path.join(args.output_path, "SBD")
    os.makedirs(sbd_path, exist_ok=True)
    SBDataset(sbd_path,
              image_set='train_noval',
              mode='segmentation',
              download=True)
    print("Done")
    print("Pascal VOC 2012 is at : {}".format(
        os.path.join(args.output_path, "VOCdevkit")))
    print("SBD is at : {}".format(sbd_path))