-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Add Imagewoof Dataset #1590
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
Open
nouman-10
wants to merge
3
commits into
tensorflow:master
Choose a base branch
from
nouman-10:add_imagewoof
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Add Imagewoof Dataset #1590
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,105 @@ | ||
# coding=utf-8 | ||
# Copyright 2020 The TensorFlow Datasets Authors. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
# Lint as: python3 | ||
"""Imagewoof Dataset""" | ||
# gfile cannot be imported directly `from tensorflow.io import gfile` | ||
import os | ||
import tensorflow.compat.v2 as tf | ||
import tensorflow_datasets.public_api as tfds | ||
|
||
|
||
_IMAGEWOOF_URL = "https://s3.amazonaws.com/fast-ai-imageclas/imagewoof2.tgz" | ||
|
||
_CITATION = """ | ||
@misc{imagewoof, | ||
author = "Jeremy Howard", | ||
title = "Imagewoof", | ||
url = "https://github.com/fastai/imagenette/" | ||
} | ||
""" | ||
|
||
_DESCRIPTION = """\ | ||
Imagewoof is a subset of 10 classes from Imagenet that aren't so easy to | ||
classify, since they're all dog breeds. The breeds are: Australian terrier, | ||
Border terrier, Samoyed, Beagle, Shih-Tzu, English foxhound, Rhodesian | ||
ridgeback, Dingo, Golden retriever, Old English sheepdog. | ||
""" | ||
|
||
lbl_dict = { | ||
'n02093754': 'Australian terrier', | ||
'n02089973': 'Border terrier', | ||
'n02099601': 'Samoyed', | ||
'n02087394': 'Beagle', | ||
'n02105641': 'Shih-Tzu', | ||
'n02096294': 'English foxhound', | ||
'n02088364': 'Rhodesian ridgeback', | ||
'n02115641': 'Dingo', | ||
'n02111889': 'Golden retriever', | ||
'n02086240': 'Old English sheepdog' | ||
} | ||
|
||
|
||
class Imagewoof(tfds.core.GeneratorBasedBuilder): | ||
"""Imagewoof Dataset""" | ||
VERSION = tfds.core.Version('0.1.0') | ||
|
||
def _info(self): | ||
return tfds.core.DatasetInfo( | ||
builder=self, | ||
description=_DESCRIPTION, | ||
features=tfds.features.FeaturesDict({ | ||
"image": tfds.features.Image(), | ||
"label": tfds.features.ClassLabel( | ||
names=['Australian terrier', 'Border terrier', 'Samoyed', | ||
'Beagle', 'Shih-Tzu', 'English foxhound', | ||
'Rhodesian ridgeback', 'Dingo', 'Golden retriever', | ||
'Old English sheepdog']), | ||
}), | ||
supervised_keys=("image", "label"), | ||
homepage="https://github.com/fastai/imagenette", | ||
citation=_CITATION | ||
) | ||
|
||
def _split_generators(self, dl_manager): | ||
"""Generate Splits""" | ||
extracted_path = dl_manager.download_and_extract(_IMAGEWOOF_URL) | ||
extracted_path = os.path.join(extracted_path, 'imagewoof2') | ||
# Specify the splits | ||
return [ | ||
tfds.core.SplitGenerator( | ||
name=tfds.Split.TRAIN, | ||
gen_kwargs={ | ||
"images_dir_path": os.path.join(extracted_path, "train"), | ||
}), | ||
tfds.core.SplitGenerator( | ||
name=tfds.Split.VALIDATION, | ||
gen_kwargs={ | ||
"images_dir_path": os.path.join(extracted_path, "val"), | ||
}), | ||
] | ||
|
||
def _generate_examples(self, images_dir_path): | ||
"""Generate examples given the image directory path""" | ||
count = 0 | ||
for image_folder in tf.io.gfile.listdir(images_dir_path): | ||
for image_file in tf.io.gfile.listdir(os.path.join(images_dir_path, | ||
image_folder)): | ||
yield count, { | ||
'image': '{}/{}/{}'.format(images_dir_path, image_folder, | ||
image_file), | ||
'label': lbl_dict[image_folder] | ||
} | ||
count += 1 | ||
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. I don't know why its not showing you error for adding extra one line space after ending of code. |
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,34 @@ | ||
# coding=utf-8 | ||
# Copyright 2020 The TensorFlow Datasets Authors. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
# Lint as: python3 | ||
|
||
"""Tests for Imagewoof.""" | ||
|
||
from tensorflow_datasets import testing | ||
from tensorflow_datasets.image import imagewoof | ||
|
||
|
||
|
||
class ImagewangFullSizeTest(testing.DatasetBuilderTestCase): | ||
DATASET_CLASS = imagewoof.Imagewoof | ||
SPLITS = { | ||
"train": 4, | ||
"validation": 4, | ||
} | ||
|
||
|
||
if __name__ == "__main__": | ||
testing.test_main() |
Binary file added
BIN
+104 KB
.../fake_examples/imagewoof/imagewoof/train/n02086240/ILSVRC2012_val_00010805.JPEG
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+159 KB
.../fake_examples/imagewoof/imagewoof/train/n02086240/ILSVRC2012_val_00011754.JPEG
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+159 KB
.../fake_examples/imagewoof/imagewoof/train/n02093754/ILSVRC2012_val_00013727.JPEG
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+153 KB
.../fake_examples/imagewoof/imagewoof/train/n02093754/ILSVRC2012_val_00014225.JPEG
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+112 KB
...ta/fake_examples/imagewoof/imagewoof/val/n02086240/ILSVRC2012_val_00002701.JPEG
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+81.9 KB
...ta/fake_examples/imagewoof/imagewoof/val/n02086240/ILSVRC2012_val_00003841.JPEG
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+46.5 KB
...ng/test_data/fake_examples/imagewoof/imagewoof/val/n02093754/n02086240_110.JPEG
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+69.1 KB
...ng/test_data/fake_examples/imagewoof/imagewoof/val/n02093754/n02086240_112.JPEG
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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 @@ | ||
https://s3.amazonaws.com/fast-ai-imageclas/imagewoof2.tgz 1343482285 d6f2ffc7b95663f7701b94cea32db1683b9a50dd389382c7cca024e840af0379 |
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.