import sys, os sys.path.append(os.path.abspath('..\\..\\ezmodel')) from ezmodel.ezmodel import ezmodel from ezmodel.ezdata import ezdata from ezmodel.eztrainer import eztrainer # [EZDATA] parameters = { "name": "Skin to predict", "path": "C:\\Users\\daian\\Desktop\\DATA\\Skin\\skin_to_predict.npz", "resize": (128, 128) } data_to_predict = ezdata(parameters) # [EZNETWORK] ez_trainer = eztrainer(network="imagenet.mobilenet") # [EZMODEL] ez_model = ezmodel() ez_model.assign(data_to_predict, ez_trainer) ez_model.predict(data_to_predict)
# ---------------------------- [EZ Data] ----------------------------------- # Table Classification from a csv file: # - One subdirectory by Class parameters = { "name": "Iris", "type": "classification", "format": "table", "from": "file", "path": "C:\\Users\\daian\\Desktop\\DATA\\Iris\\iris.csv", "table_delimiter": ",", "table_target_column": ["species"], "table_target_column_type": "string" } ez_data = ezdata(parameters) ez_data.gen_test(size=0.2) ez_data.preprocess(X="standard", y="categorical") #on crée les scaler dans ez_data aussi # ---------------------------- [EZ Data Save] ------------------------------- ez_data.save("iris_dataset") # ---------------------------- [EZ Data Load] ------------------------------- ez_data2 = ezdata(load="iris_dataset") print(ez_data2.params["name"])
from ezmodel.eztrainer import eztrainer # ---------------------------- [EZ Data] ----------------------------------- # Load from a npz file containing data # NPZ file should contains 3 keys: # X key containing data # y key containing label # synsets key in case of classification model with synset generated parameters = { "name" : "Skin", "path" : "C:\\Users\\daian\\Desktop\\DATA\\Skin\\skin.npz", "X.key" : "images", "y.key" : "labels" } ez_data = ezdata(parameters) ez_data.gen_test(0.2) #ez_data.preprocess(X="mobilenet",y="categorical") ez_data.preprocess(X="vgg19",y="categorical") # -------------------------- [EZ Trainer] ------------------------------------ from keras.layers import Dense,Dropout ez_trainer = eztrainer() ez_trainer.gen_trainval(ez_data,size=0.2) # -- Keras network --
import sys, os sys.path.append(os.path.abspath('..\\..\\ezmodel')) from ezmodel.ezmodel import ezmodel from ezmodel.ezdata import ezdata from ezmodel.eztrainer import eztrainer ezd = ezdata() ezd.X = ezd.image_from_url( url= "https://www.almanac.com/sites/default/files/styles/primary_image_in_article/public/image_nodes/strawberries-1.jpg", img_size=(128, 128)) ezd.y = None import pickle from urllib.request import urlopen ezd.synsets = pickle.load( urlopen( 'https://gist.githubusercontent.com/yrevar/6135f1bd8dcf2e0cc683/raw/d133d61a09d7e5a3b36b8c111a8dd5c4b5d560ee/imagenet1000_clsid_to_human.pkl' )) ezt = eztrainer() ezt.network = ezt.PretrainedNetwork("mobilenet", ezd.X.shape[1:]) ezt.network.summary() ezd.preprocess(X="mobilenet", y=None) import numpy as np p = ezt.network.predict(ezd.X) top = 5 ind_five = (-p).argsort()[-3:][::-1][0][0:top]