khurramjaved96 / incremental-learning Goto Github PK
View Code? Open in Web Editor NEWPytorch implementation of ACCV18 paper "Revisiting Distillation and Incremental Classifier Learning."
Pytorch implementation of ACCV18 paper "Revisiting Distillation and Incremental Classifier Learning."
I was wondering since it says its an ongoing implementation, is it complete yet ?or still working in progress?
Hi, I added custom dataset like below:
def pil_loader(path):
# open path as file to avoid ResourceWarning (https://github.com/python-pillow/Pillow/issues/835)
with open(path, 'rb') as f:
img = Image.open(f)
img = img.resize((32,32))
img = img.convert('RGB')
return img
class GEO(Dataset):
'''
:param train_path: /media/gaoya/disk/Applications/pytorch/Incremental Learning/train_dataset
:param test_path /media/gaoya/disk/Applications/pytorch/Incremental Learning/test_dataset
'''
def __init__(self,train_path, test_path):
super().__init__(classes=5, name="GEO", labels_per_class_train=500, labels_per_class_test=100)
imgs = numpy.array([])
self.train_transform = transforms.Compose([
transforms.Resize(32),
transforms.RandomHorizontalFlip(),
transforms.ToTensor(),
transforms.Normalize((0.4914, 0.4822, 0.4465), (0.2023, 0.1994, 0.2010)),
])
self.test_transform = transforms.Compose([
transforms.Resize(32),
transforms.ToTensor(),
transforms.Normalize((0.4914, 0.4822, 0.4465), (0.2023, 0.1994, 0.2010)),
])
self.train_data = datasets.ImageFolder(root=train_path,
transform=self.train_transform,
loader=pil_loader)
imgs = numpy.array([self.train_transform(pil_loader(path[0])).numpy().transpose(2,1,0) for path in self.train_data.imgs])
# img_temp = imgs[0]
# for k in range(1, len(imgs)):
# img_temp = numpy.stack((img_temp, imgs[k]))
self.train_imgs = imgs
self.train_targets = self.train_data.targets
self.test_data = datasets.ImageFolder(root=test_path,
transform=self.test_transform,
loader=pil_loader)
self.test_imgs = numpy.array([self.test_transform(pil_loader(path[0])).numpy().transpose(2,1,0) for path in self.test_data.imgs])
self.test_targets = self.test_data.targets
and I also have changed the code about dataset_loader( like data is dataset.train_imgs, labels is dataset.train_targets)
When I reran the file, I got error:
Traceback (most recent call last):
File "run_experiment.py", line 224, in <module>
my_trainer.increment_classes(class_group)
File "H:\MachineLearning\incremental-learning-autoencoders\trainer\trainer.py", line 78, in increment_classes
pop_val = self.all_classes.pop()
IndexError: pop from empty list
Can you tell me what's wrong with the code? My custom datasets have 5 classes (traing set is ((8476, 32, 32, 3), testing set is (1021, 32, 32, 3))
First, thanks so much for your work. In your code, we have to specify the argument "labels_per_class_test", but I have a imbalanced dataset, which means that the number of labels for each class is different, so what should I do?
Hello, can you explain the function of the parameters in the runExperiment.py file in the readme, i want to read your code, it is difficult to read for me
hi @khurramjaved96
There should be a small change in your code. In the trainer.py file, in the distillation loss section, the previous model giving features after passing through the softmax while the current model giving features by passing through log softmax. How we can compute the KL divergence between these two using the F.kl function?
Please check this.
Thanks
when I try to run python run_experiment.py it gives me this error AttributeError: 'CIFAR100' object has no attribute 'train_data'.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.