Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix HPatches download error by using kaggle download mirror #115

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 8 additions & 7 deletions gluefactory/datasets/hpatches.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

import argparse
import logging
import tarfile
import zipfile

import matplotlib.pyplot as plt
import numpy as np
Expand Down Expand Up @@ -54,7 +54,7 @@ class HPatches(BaseDataset, torch.utils.data.Dataset):
"v_astronautis",
"v_talent",
)
url = "http://icvl.ee.ic.ac.uk/vbalnt/hpatches/hpatches-sequences-release.tar.gz"
url = "https://www.kaggle.com/api/v1/datasets/download/javidtheimmortal/hpatches-sequence-release"

def _init(self, conf):
assert conf.batch_size == 1
Expand All @@ -79,11 +79,12 @@ def _init(self, conf):
def download(self):
data_dir = self.root.parent
data_dir.mkdir(exist_ok=True, parents=True)
tar_path = data_dir / self.url.rsplit("/", 1)[-1]
torch.hub.download_url_to_file(self.url, tar_path)
with tarfile.open(tar_path) as tar:
tar.extractall(data_dir)
tar_path.unlink()
zip_path = data_dir / self.url.rsplit("/", 1)[-1]
torch.hub.download_url_to_file(self.url, zip_path)
# Open the ZIP file
with zipfile.ZipFile(zip_path, 'r') as zip_ref:
# Extract all contents to a directory
zip_ref.extractall(data_dir)

def get_dataset(self, split):
assert split in ["val", "test"]
Expand Down
Loading