Exploring Hub:>Activeloop A tale of Uploading Pokemon Data

Pokemon types by Google Images

What is Hub ?

image from Activeloop Hub
image from saggle
image by Activeloop
pip install hub

How I upload my Pokemons to hub:

image by wikipedia

Importing all libraries and preparing Schemas for the dataset:

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:

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….

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