Exemple #1
0
import my_utils.loadDataset as dl  # create dataloader for selected dataset
import my_utils.loadModel as lm  # facilitate loading and manipulating models
import my_utils.trainModel as tm  # Facilitate training of the model
import my_utils.initialize_pruning as ip  # Initialize and provide basic parmeter require for pruning
import my_utils.facilitate_pruning as fp  # Compute Pruning Value and many things

# In[2]: Set the data loader to load the data for selected dataset
dl.setFolderLocation(datasets='/home/pragnesh/Dataset/',
                     selectedDataset='IntelIC/',
                     train='train',
                     test='test')
# set the imge properties
dl.setImageSize(224)
dl.setBatchSize = 16
dataLoaders = dl.dataLoader()

# In[3]:load the saved model if have any and if dont load a standard model
loadModel = True
if loadModel:
    load_path = "/home/pragnesh/Dataset/Intel_Image_Classifacation_v2/Model/VGG_IntelIC_v1-vgg16"
    device1 = torch.device("cuda:0" if torch.cuda.is_available() else "cpu")
    newModel = torch.load(load_path, map_location=torch.device(device1))
else:
    #if dont have any saved trained model download pretrained model for tranfer learning
    newmodel = lm.load_model(model_name='vgg16',
                             number_of_class=6,
                             pretrainval=False,
                             freeze_feature=False,
                             device_l=device1)
# In[1]:

import my_utils.loadDataset as dl
import my_utils.loadModel as lm
import my_utils.trainModel as tm
import torch

# In[2]:

dl.setFolderLocation(datasets='/home/pragnesh/Dataset/',
                     selectedDataset='IntelIC/',
                     train='train',
                     test='test')
dl.setImageSize(224)
dl.setBatchSize = 2
dataLoader = dl.dataLoader()

# In[3]:

device1 = torch.device("cuda:0" if torch.cuda.is_available() else "cpu")
print(device1)
newmodel = lm.loadModel(modelname='vgg16',
                        numberOfClass=6,
                        pretrainval=False,
                        freezeFeature=False,
                        device=device1)

# In[ ]:

print(newmodel.features[0]._parameters)