(lsun_dir, category, dset, tag, overwrite=False)
Download LSUN data and unpack

    Arguments:
        lsun_dir (str): LSUN data directory
        category (str): LSUN category
        dset (str): dataset, "train", "val", or "test"
        tag (str): version tag, use "latest" for most recent
        overwrite (bool): whether to overwrite existing data
Download LSUN data and unpack
Download LSUN data and unpack
def download_lsun(lsun_dir, category, dset, tag, overwrite=False):
    """
    Download LSUN data and unpack

    Arguments:
        lsun_dir (str): LSUN data directory
        category (str): LSUN category
        dset (str): dataset, "train", "val", or "test"
        tag (str): version tag, use "latest" for most recent
        overwrite (bool): whether to overwrite existing data
    """
    dfile = 'test_lmdb' if dset == 'test' else '{0}_{1}_lmdb'.format(category, dset)
    dfile = os.path.join(lsun_dir, dfile)
    if not os.path.exists(dfile) or overwrite:
        dfile += '.zip'
        if os.path.exists(dfile):
            os.remove(dfile)
        url = LSUN_URL + 'download.cgi?tag={0}&category={1}&set={2}'.format(tag, category, dset)
        print('Data download might take a long time.')
        print('Downloading {0} {1} set...'.format(category, dset))
        subprocess.call(['curl', url, '-o', dfile])
        print('Extracting {0} {1} set...'.format(category, dset))
        zf = zipfile.ZipFile(dfile, 'r')
        zf.extractall(lsun_dir)
        zf.close()
        print('Deleting {}...'.format(dfile))
        os.remove(dfile)
    else:
        pass  # data already downloaded
    print("LSUN {0} {1} dataset downloaded and unpacked.".format(category, dset))
def download_lsun ( lsun_dir , category , dset , tag , overwrite = False ) : dfile = 'test_lmdb' if dset == 'test' else '{0}_{1}_lmdb' . format ( category , dset ) dfile = os . path . join ( lsun_dir , dfile ) if not os . path . exists ( dfile ) or overwrite : dfile += '.zip' if os . path . exists ( dfile ) : os . remove ( dfile ) url = LSUN_URL + 'download.cgi?tag={0}&category={1}&set={2}' . format ( tag , category , dset ) print ( 'Data download might take a long time.' ) print ( 'Downloading {0} {1} set...' . format ( category , dset ) ) subprocess . call ( [ 'curl' , url , '-o' , dfile ] ) print ( 'Extracting {0} {1} set...' . format ( category , dset ) ) zf = zipfile . ZipFile ( dfile , 'r' ) zf . extractall ( lsun_dir ) zf . close ( ) print ( 'Deleting {}...' . format ( dfile ) ) os . remove ( dfile ) else : pass # data already downloaded print ( "LSUN {0} {1} dataset downloaded and unpacked." . format ( category , dset ) )