-
Notifications
You must be signed in to change notification settings - Fork 7.1k
LSUN download Data #2748
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
LSUN download Data #2748
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -7,7 +7,7 @@ | |||||||||||||||||
from collections.abc import Iterable | ||||||||||||||||||
import pickle | ||||||||||||||||||
from typing import Any, Callable, cast, List, Optional, Tuple, Union | ||||||||||||||||||
from .utils import verify_str_arg, iterable_to_str | ||||||||||||||||||
from .utils import verify_str_arg, iterable_to_str, download_url, extract_archive | ||||||||||||||||||
|
||||||||||||||||||
|
||||||||||||||||||
class LSUNClass(VisionDataset): | ||||||||||||||||||
|
@@ -82,6 +82,7 @@ def __init__( | |||||||||||||||||
# for each class, create an LSUNClassDataset | ||||||||||||||||||
self.dbs = [] | ||||||||||||||||||
for c in self.classes: | ||||||||||||||||||
self._download(c) | ||||||||||||||||||
self.dbs.append(LSUNClass( | ||||||||||||||||||
root=root + '/' + c + '_lmdb', | ||||||||||||||||||
transform=transform)) | ||||||||||||||||||
|
@@ -93,6 +94,16 @@ def __init__( | |||||||||||||||||
self.indices.append(count) | ||||||||||||||||||
|
||||||||||||||||||
self.length = count | ||||||||||||||||||
|
||||||||||||||||||
def _download(self, c): | ||||||||||||||||||
url = 'http://dl.yf.io/lsun/scenes/{}'.format(c + '_lmdb.zip') | ||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Before the download you could check if the vision/torchvision/datasets/utils.py Lines 38 to 43 in 588f7ae
If that is the case you don't need to download anything. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @pmeier Do I have to find md5 hash, if yes how? otherwise I can just directly check if the file exists or not There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Although not terribly common, download errors happen. Without a checksum, you have no idea if the file maybe is corrupt. Thus it we prefer to have a MD5 checksum for most files. In your case that would mean for the
You can download and extract all archives with the download logic you already have. Afterwards you can use a variety of tools. Depending on your setup you might have vision/torchvision/datasets/utils.py Line 26 in de90862
|
||||||||||||||||||
file_name = c + '_lmdb.zip' | ||||||||||||||||||
file_path = os.path.join(self.root, file_name) | ||||||||||||||||||
if not(os.path.isfile(os.path.join(self.root, file_name))): | ||||||||||||||||||
download_url(url, self.root, file_name) | ||||||||||||||||||
print("Extracting File") | ||||||||||||||||||
extract_archive(file_path, self.root, True) | ||||||||||||||||||
print("Done!!!") | ||||||||||||||||||
Comment on lines
+102
to
+106
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You can make this simpler by using vision/torchvision/datasets/utils.py Lines 242 to 249 in 588f7ae
|
||||||||||||||||||
|
||||||||||||||||||
def _verify_classes(self, classes: Union[str, List[str]]) -> List[str]: | ||||||||||||||||||
categories = ['bedroom', 'bridge', 'church_outdoor', 'classroom', | ||||||||||||||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The download should be optional. Other datasets have a
download=True
flag in the constructor that indicates whether the download should happen or not.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay I will make the changes.
Thanks for your support and guidance.