Skip to content

Commit

Permalink
Working MegaFlow2D with new separated data
Browse files Browse the repository at this point in the history
  • Loading branch information
WenzhuoXu committed Sep 21, 2023
1 parent c3bcba1 commit c3b9984
Show file tree
Hide file tree
Showing 7 changed files with 23 additions and 4 deletions.
Binary file modified megaflow/__pycache__/__init__.cpython-310.pyc
Binary file not shown.
Binary file added megaflow/common/__pycache__/__init__.cpython-310.pyc
Binary file not shown.
Binary file not shown.
22 changes: 20 additions & 2 deletions megaflow/dataset/MegaFlow2D.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import multiprocessing as mp
from threading import Thread
import h5py
from zipfile import ZipFile

import torch
from torch import Tensor
Expand Down Expand Up @@ -33,7 +34,9 @@ def __init__(self, root, download, transform, pre_transform, split_scheme='mixed
self.transforms = transform
self.pre_transform = pre_transform
if download:
self.download()
self.download()
# give a warning that the package does not check the integrity of the downloaded data
Warning('The package does not check the integrity of the downloaded data. The downloading operation is always executed if the flag download is True. Please disable the download flag if you have already downloaded the data')
self.data_list = self.get_data_list
# self.processed_las_data_dir = os.path.join(self.root, 'processed', 'las')
# self.processed_has_data_dir = os.path.join(self.root, 'processed', 'has')
Expand Down Expand Up @@ -104,12 +107,27 @@ def len(self):
return 0
else:
return len(self.data_list)

def _extract_zip(self, path, folder):
zips = ["data.zip.00{}".format(i) for i in range(1, 6)]

with open(os.path.join(path, "data.zip"), "ab") as f:
for zipName in zips:
with open(os.path.join(path, zipName), "rb") as z:
f.write(z.read())

z.close()
os.remove(os.path.join(path, zipName))

with ZipFile(os.path.join(path, "data.zip"), "r") as zipObj:
zipObj.extractall(folder)
os.remove(os.path.join(path, "data.zip"))

def download(self):
for i in range(1, 6):
url = 'https://huggingface.co/datasets/cmudrc/MegaFlow2D/resolve/main/data.zip.00{}'.format(i)
path = download_url(url, self.root)
extract_zip(path, self.root)
self._extract_zip(self.root, self.root)

def process(self):
# Read mesh solution into graph structure
Expand Down
Binary file modified megaflow/dataset/__pycache__/MegaFlow2D.cpython-310.pyc
Binary file not shown.
Binary file not shown.
5 changes: 3 additions & 2 deletions test.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from megaflow.dataset.MegaFlow2D import MegaFlow2D

# Create a dataset object
dataset = MegaFlow2D(root='D:/Work/data', download=True)
if __name__ == '__main__':
# Create a dataset object
dataset = MegaFlow2D(root='D:/Work/data', download=True, transform='normalize', pre_transform=None)

0 comments on commit c3b9984

Please sign in to comment.