Exploring Hub:>Activeloop A tale of Uploading Pokemon Data

Image for post
Image for post
Pokemon types by Google Images

What is Hub ?

Image for post
Image for post
image from Activeloop Hub
Image for post
Image for post
image from saggle
Image for post
Image for post
image by Activeloop
pip install hub

How I upload my Pokemons to hub:

Before two sections are for the basic knowledge ,from here begins the tale.I know about the activeloop and hub in the hacktoberfest while searching for the repositories to contribute.When found I think about how to use it and contribute to this awesome community,after some days I joined the activeloop/hub slack community workspace which is a good place to start your contribution in machine learning.

Image for post
Image for post
image by wikipedia

Importing all libraries and preparing Schemas for the dataset:

Now I imported the required libraries for the reading and formatting data.The libraries are numpy,opencv,hub.

import numpy as np
import os
from cv2 import imread
from hub import schema,Dataset
from hub.schema import ClassLabel,Image
all_labels =    [‘bug’,’dark’,’dragon’,’electric’,’fairy’,’fighting’,’fire’,’flying’,’ghost’,’grass’,’ground’,’ice’,’normal’,’poison’,’psychic’,’rock’,’steel’,’water’]
classlabel = ClassLabel(names=[‘bug’,’dark’,’dragon’,’electric’,’fairy’,’fighting’,’fire’,’flying’,’ghost’,’grass’,’ground’,’ice’,’normal’,’poison’,’psychic’,’rock’,’steel’,’water’])
schema = {

“labels”: classlabel,
“image”:Image(
dtype=”uint8",
shape=((120,120,None)),max_shape=(120,120,4))
}

Loading Images to dictionary and upload to the hub:

I wrote this following code to load the images to the memory,take a look:

store = []
store_label = []
store_name = []
root = ‘/home/debo/uploadhub/pokemon-images-dataset-by-type’for i in sorted(os.listdir(root)):
for j in sorted(os.listdir(root+’/’+i)):
image = imread(root+’/’+i+’/’+j)
store.append(np.asarray(image))
store_label.append(i)
store_name.append(j)
classlabel = ClassLabel(names=[‘bug’,’dark’,’dragon’,’electric’,’fairy’,’fighting’,’fire’,’flying’,’ghost’,’grass’,’ground’,’ice’,’normal’,’poison’,’psychic’,’rock’,’steel’,’water’])schema = {

“labels”: classlabel,
“image”:Image(
dtype=”uint8",
shape=((120,120,None)),max_shape=(120,120,4))
}
ds = Dataset(
“darkdebo/pokemon_data”,
mode=”w+”,
schema=schema,
shape=(809,),
cache=2**26,
)
for i in range(len(store_label)):
#print(store_name[i])
ds[‘image’,i] = store[i]
#print(ds[‘image’,i])
ds[‘labels’,i] = classlabel.str2int(store_label[i])
print(“uploading…”)
print(“uploaded succesfully”)ds.commit()

Some Words….

Now the dataset you can check https://app.activeloop.ai/dataset/darkdebo/pokemon_data.

Image for post
Image for post
image by Author

cs student pre final year,Open source contributor,AI && ML,DS & ALGO

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store