forked from activeloopai/deeplake
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
157 additions
and
54 deletions.
There are no files selected for viewing
This file contains 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,41 @@ | ||
import hub | ||
import torch | ||
|
||
if __name__ == "__main__": | ||
ds = hub.Dataset("eurosat/eurosat-rgb") | ||
|
||
# 26000 samples in dataset, accessing values | ||
print(ds["image"][10].numpy()) | ||
print(ds["label", 15].numpy()) # alternate way to access, by specifying both key and sample number at once | ||
print(ds["filename", 20:22].numpy()) # accessing multiple elements at once | ||
|
||
# Splitting into train and test sets | ||
train_ds = ds[:13000] | ||
test_ds = ds[13000:] | ||
|
||
# Using hub with tensorflow | ||
train_tf_ds = train_ds.to_tensorflow().batch(2) | ||
|
||
for batch in train_tf_ds: | ||
print(batch["label"], batch["filename"], batch["image"]) | ||
break | ||
|
||
test_tf_ds = test_ds.to_tensorflow().batch(2) | ||
|
||
for batch in test_tf_ds: | ||
print(batch["label"], batch["filename"], batch["image"]) | ||
break | ||
|
||
# Using hub with pytorch | ||
train_pt_ds = train_ds.to_pytorch() | ||
train_loader = torch.utils.data.DataLoader(train_pt_ds, batch_size=2) | ||
|
||
for batch in train_loader: | ||
print(batch["label"], batch["image"]) # pytorch tensors don't support text labels such as filename | ||
break | ||
|
||
test_pt_ds = test_ds.to_pytorch() | ||
test_loader = torch.utils.data.DataLoader(test_pt_ds, batch_size=2) | ||
for batch in test_loader: | ||
print(batch["label"], batch["image"]) # pytorch tensors don't support text labels such as filename | ||
break |
This file contains 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 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 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 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 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 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 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
Oops, something went wrong.