Quickstart
A jump-start guide to using Hub.

Installing Hub

Hub can be installed through pip.
1
$ pip3 install hub
Copied!

Fetching Your First Hub Dataset

Let's load MNIST, the hello world dataset of machine learning.
First, instantiate a Dataset by pointing it to the dataset's locations. Datasets hosted on Activeloop Platform are typically identified by the namespace of the organization followed by the dataset name: activeloop/mnist-train.
1
import hub
2
3
dataset_path = 'hub://activeloop/mnist-train'
4
ds = hub.load(dataset_path) # Returns a Hub Dataset but does not download data locally
Copied!

Reading Samples From a Hub Dataset

Data is not immediately read into memory because Hub operates lazily. You can fetch data by calling the.numpy()method, which reads data into a numpy array.
1
# Indexing
2
W = ds.images[0].numpy() # Fetch an image and return a numpy array
3
4
# Slicing
5
Y = ds.images[0:100].numpy() # Fetch 100 images and return a numpy array
6
# The method above produces an exception if
7
# the images are not all the same size
8
9
Z = ds.labels[0:100].numpy(aslist=True) # Fetch 100 labels and store
10
# them as a list of numpy arrays
Copied!
Congratulations, you've got Hub working on your local machine
🤓
Last modified 2d ago