Skip to main content

Map dataset generator for learning map representations and generation

Project description

MapDatasetGenerator

Generate and load dataset of road network maps.

Installation from pip

pip install mapdatasetgenerator

Creating patches

# Run this script to generate data in /output directory.
import logging
import sys

root = logging.getLogger()
root.setLevel(logging.INFO)

handler = logging.StreamHandler(sys.stdout)
handler.setLevel(logging.INFO)
formatter = logging.Formatter('%(asctime)s - %(name)s - %(levelname)s - %(message)s')
handler.setFormatter(formatter)
root.addHandler(handler)

from mapdataset import ImageGroupReader, single_layer_converter, MapsDataset, MapReader


sfMap = MapReader('./data/input/sf_layered.txt', "SF_Layered")
mapsDataset = MapsDataset(
    patch_size=(32, 32), 
    stride=10, 
    sample_group_size=1280, 
    converter=single_layer_converter,
    outputDir="./data/output"
    ) 
    
mapsDataset.generate_patches(sfMap) #This will generate dill files which contain the saved sample lists.

Reading patches

# Script to read dill data objects as numpy arrays.
from PIL import Image
import os
import sys
import logging

root = logging.getLogger()
root.setLevel(logging.INFO)

handler = logging.StreamHandler(sys.stdout)
handler.setLevel(logging.INFO)
formatter = logging.Formatter('%(asctime)s - %(name)s - %(levelname)s - %(message)s')
handler.setFormatter(formatter)
root.addHandler(handler)


from mapdataset import ImageGroupReader, single_layer_converter, MapsDataset, MapReader, ImageUtils

dillFolder = "./data/output/SF_Layered/32x32/group-1280-stride-10"

mapsDataset = MapsDataset(
    patch_size=(32, 32), 
    stride=10, 
    sample_group_size=1280, 
    converter=single_layer_converter,
    outputDir="./data/output"
    ) 

mapsDataset.loadPatches("./data/output/SF_Layered/32x32/group-1280-stride-10")
patchNo = randint(0, len(mapsDataset))
logging.info(f"reading patch {patchNo}")
patch = mapsDataset[patchNo]


im = ImageUtils.TorchNpPatchToPILImgGray(patch)
path = os.path.join(dillFolder, f"{patchNo}.png")
im.save(path)

Using for training

  1. Create patches if you already do not have them
  2. Create a MapsDataset object and load patches. Now you can use the dataset object as a regular Pytorch dataset or use it with a Dataloader.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

MapDatasetGenerator-0.0.2.tar.gz (7.8 kB view details)

Uploaded Source

Built Distribution

mapdatasetgenerator-0.0.2-py3-none-any.whl (9.7 kB view details)

Uploaded Python 3

File details

Details for the file MapDatasetGenerator-0.0.2.tar.gz.

File metadata

  • Download URL: MapDatasetGenerator-0.0.2.tar.gz
  • Upload date:
  • Size: 7.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.2.1 CPython/3.7.9 Windows/10

File hashes

Hashes for MapDatasetGenerator-0.0.2.tar.gz
Algorithm Hash digest
SHA256 68b6a3c8ee028d4731443fcb541b14f8d7c9b558e228603dbe2fd5dc6f7d171f
MD5 db5c5c5ca47ed8154820343655b94068
BLAKE2b-256 0b9ef8f1ca7e8c5a44a7f40f398755c9c5a97870db7c1db1d23189a69514792f

See more details on using hashes here.

File details

Details for the file mapdatasetgenerator-0.0.2-py3-none-any.whl.

File metadata

File hashes

Hashes for mapdatasetgenerator-0.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 fb34852b487d4b5afd91beaf307aceb44ff91609cfbc37437a8408b56c1326c8
MD5 9dc9871dd393fd5d437833f70948a074
BLAKE2b-256 40c898dbb86e5efea170140254aad554d33b492e882e499c5109c4b3726323db

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page