-
Notifications
You must be signed in to change notification settings - Fork 7.1k
Adds EuroSAT to the list of supported datasets #5114
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
Merged
Merged
Changes from all commits
Commits
Show all changes
23 commits
Select commit
Hold shift + click to select a range
f5c291b
feat: Added EuroSAT dataset
frgfm 1619c6a
test: Added unittest
frgfm cca559a
docs: Improved comments
frgfm ad3adcb
docs: Updated the documentation
frgfm 84e5396
Merge branch 'main' into eurosat
pmeier f7f35b8
docs: Removed unnecessary comments
frgfm 58a2423
fix: Fixed class implementation
frgfm 4de1d31
test: Fixed unittest
frgfm 6993c36
fix: Fixed magic method len
frgfm fe051cd
test: Fixed unittest
frgfm 69d5b78
refactor: Refactored EuroSAT
frgfm bbfc86b
Merge branch 'main' into eurosat
frgfm cbf79e1
refactor: Applied modifications
frgfm c823d1e
Apply suggestions from code review
pmeier 5b03950
Merge branch 'main' into eurosat
pmeier d90fce0
Merge branch 'main' into eurosat
frgfm e6f59fd
refactor: Applied request changes
frgfm f366970
refactor: Made var explicit
frgfm 077c9c1
Merge branch 'main' into eurosat
frgfm 109c47a
Merge branch 'main' into eurosat
pmeier ae05094
fix: Fixed attribute initialization order
frgfm cbcd204
Merge branch 'main' into eurosat
frgfm fad24b8
refactor: Removed name mapping
frgfm File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
import os | ||
from typing import Any | ||
|
||
from .folder import ImageFolder | ||
from .utils import download_and_extract_archive | ||
|
||
|
||
class EuroSAT(ImageFolder): | ||
"""RGB version of the `EuroSAT <https://github.com/phelber/eurosat>`_ Dataset. | ||
|
||
Args: | ||
root (string): Root directory of dataset where ``root/eurosat`` exists. | ||
download (bool, optional): If True, downloads the dataset from the internet and | ||
puts it in root directory. If dataset is already downloaded, it is not | ||
downloaded again. Default is False. | ||
transform (callable, optional): A function/transform that takes in an PIL image | ||
and returns a transformed version. E.g, ``transforms.RandomCrop`` | ||
target_transform (callable, optional): A function/transform that takes in the | ||
target and transforms it. | ||
""" | ||
|
||
url = "https://madm.dfki.de/files/sentinel/EuroSAT.zip" | ||
md5 = "c8fa014336c82ac7804f0398fcb19387" | ||
|
||
def __init__( | ||
self, | ||
root: str, | ||
download: bool = False, | ||
**kwargs: Any, | ||
) -> None: | ||
self.root = os.path.expanduser(root) | ||
self._base_folder = os.path.join(self.root, "eurosat") | ||
self._data_folder = os.path.join(self._base_folder, "2750") | ||
|
||
if download: | ||
self.download() | ||
|
||
if not self._check_exists(): | ||
raise RuntimeError("Dataset not found. You can use download=True to download it") | ||
|
||
super().__init__(self._data_folder, **kwargs) | ||
self.root = os.path.expanduser(root) | ||
|
||
def __len__(self) -> int: | ||
return len(self.samples) | ||
|
||
def _check_exists(self) -> bool: | ||
return os.path.exists(self._data_folder) | ||
|
||
def download(self) -> None: | ||
|
||
if self._check_exists(): | ||
return | ||
|
||
os.makedirs(self._base_folder, exist_ok=True) | ||
download_and_extract_archive(self.url, download_root=self._base_folder, md5=self.md5) |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.