Skip to content

Commit

Permalink
Update hpatches.py
Browse files Browse the repository at this point in the history
  • Loading branch information
Parskatt authored Dec 4, 2024
1 parent 1f56839 commit 7881ee1
Showing 1 changed file with 8 additions and 7 deletions.
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

0 comments on commit 7881ee1

Please sign in to comment.