ugscnn
ugscnn copied to clipboard
Unzip after download needed
Hi!
I spotted that current gen_mesh.py
only downloads .zip
files and that's it.
It bring us to the errors during experiments/exp1_sphere_mnist/prepare_data.py
:
Command:
python prepare_data.py --bandwidth 60 --mnist_data_folder raw_data --output_file /workdir/ugscnn/mnist_ico4.zip --no_rotate_train --no_rotate_test --mesh_file /workdir/ugscnn/mesh_files/icosphere_4.pkl
Output:
getting mnist data
/opt/conda/envs/s2cnn/lib/python3.10/site-packages/torchvision/datasets/mnist.py:76: UserWarning: train_data has been renamed data
warnings.warn("train_data has been renamed data")
/opt/conda/envs/s2cnn/lib/python3.10/site-packages/torchvision/datasets/mnist.py:66: UserWarning: train_labels has been renamed targets
warnings.warn("train_labels has been renamed targets")
/opt/conda/envs/s2cnn/lib/python3.10/site-packages/torchvision/datasets/mnist.py:81: UserWarning: test_data has been renamed data
warnings.warn("test_data has been renamed data")
/opt/conda/envs/s2cnn/lib/python3.10/site-packages/torchvision/datasets/mnist.py:71: UserWarning: test_labels has been renamed targets
warnings.warn("test_labels has been renamed targets")
projecting train data set
60000/60000
projecting test data set
10000/10000
Traceback (most recent call last):
File "/workdir/ugscnn/experiments/exp1_sphere_mnist/prepare_data.py", line 316, in <module>
main()
File "/workdir/ugscnn/experiments/exp1_sphere_mnist/prepare_data.py", line 283, in main
p = pickle.load(open(args.mesh_file, "rb"))
FileNotFoundError: [Errno 2] No such file or directory: '/workdir/ugscnn/mesh_files/icosphere_4.pkl'
I tried to commit and push the fix into a separate branch, but I don't have rights to accomplish this.
Here is the proper version of gen_mesh.py
, feel free to copy paste:
import sys
import os
import gdown
import zipfile
def main():
try:
sys.path.append("meshcnn")
from mesh import export_spheres
export_spheres(range(8), "mesh_files")
except ImportError:
print("ImportError occurred. Will download precomputed mesh files instead...")
import subprocess
dest = "mesh_files"
if not os.path.exists(dest):
os.makedirs(dest)
fname = 'icosphere_{}.pkl'
url = 'https://drive.google.com/uc?id=17RermILq8jGu1Oz2LgX-k98FnfzAzOW2'
output = "mesh_files.zip"
try:
gdown.download(url, output, quiet=False)
except Exception as e:
print(e)
with zipfile.ZipFile(output, 'r') as zip_ref:
zip_ref.extractall()
if __name__ == '__main__':
main()