ecs-vlc / fmix Goto Github PK
View Code? Open in Web Editor NEWOfficial implementation of 'FMix: Enhancing Mixed Sample Data Augmentation'
Home Page: https://arxiv.org/abs/2002.12047
License: MIT License
Official implementation of 'FMix: Enhancing Mixed Sample Data Augmentation'
Home Page: https://arxiv.org/abs/2002.12047
License: MIT License
Hi,
Thank you so much for giving us new data augmentation technique. I am bit confused, when I explore your models folder.
My main question is, are you training your ImageNet models with Pre-trained weights? It seems, you don't use pre-trained but you are building your own models and training without using "imagenet" weights.. Please, correct me If I am wrong here..
Secondly, the context of the first question is in the second question about baseline accuracies. Are you getting the baseline accuracies without "Imagenet" weights?
Any guideline to use FMix in keras?
Thank you!
Hi, thank you very much, your work is very interesting; I have a question regarding the datset, I'm working with the code that you uploaded in Colab, if I want to train with my own data, how do I modify the line of code?
I modify la line of torchvision, I chance CIFAR10 to ImageFolder and I structure the folders according to ImageNet but I'm still having problems.
testset = torchvision.datasets.ImageFolder(root="/root/test/all/", transform=transforms.Compose([transforms.ToTensor()]), target_transform=None).
I thank you very much for your time and attention
cheers
Hi
Could you provide a sample command line to run your code on a dataset such as CIFAR-10 or -100?
can you provide the checkpoint of pyramidnet trained in the cifar10?thank you!
Hi there! Thanks for sharing your work! The paper is very impressive!
I ran the cifar_experiment.sh with cifar data, resnet model, and fmix. However, I'm a little confused about two things:
1- Training accuracy is much lower than validation accuracy. Is this an artifact of using the masks and therefore making the learning phase much harder? Am I missing something? I confess that I'm not 100% sure I understand all the moving parts.
2- When it runs, it says running_mixup_acc etc. I had selected fmix so it's confusing to see mixup here. Can you help me understand this?
Thank you in advance!
I understood the concepts here , but I am unable to figure out how I should use this github repo wth my pytorch dataset even after going throught h colab implementations.
I am using this classification dataset.
class FlowerDataset(Dataset):
def __init__(self, id , classes , image , img_height , img_width, mean , std , is_valid):
self.id = id
self.classes = classes
self.image = image
self.is_valid = is_valid
if self.is_valid == 1:
self.aug = albumentations.Compose([
albumentations.Resize(img_height , img_width, always_apply = True) ,
albumentations.Normalize(mean , std , always_apply = True)
])
else:
self.aug = albumentations.Compose([
albumentations.Resize(img_height , img_width, always_apply = True) ,
albumentations.Normalize(mean , std , always_apply = True),
albumentations.ShiftScaleRotate(shift_limit = 0.0625,
scale_limit = 0.1 ,
rotate_limit = 5,
p = 0.9)
])
def __len__(self):
return len(self.id)
def __getitem__(self, index):
id = self.id[index]
img = np.array(Image.open(io.BytesIO(self.image[index])))
img = cv2.resize(img, dsize=(128, 128), interpolation=cv2.INTER_CUBIC)
img = self.aug(image = img)['image']
img = np.transpose(img , (2,0,1)).astype(np.float32)
return torch.tensor(img, dtype = torch.float),int(self.classes[index])
Pleas help
detectron2 support?
I just use the def in fmix.py to generate blended images independently using a batch-size images. But the end result is always a mix of vertical blocks, just like the cutmix. I didn't use pytorch or tf, just the fmix.py and pass in batch data alone. I don't know what the problem is, if you can help me to answer this question, I would be very grateful.
I have used the following training loop for my plant image dataset
def train_loop_fn(data_loader, model, optimizer, device, scheduler=None):
running_loss = 0.0
running_corrects = 0
model.train()
alpha, decay_power = 1.0, 3.0
for batch_index,dataset in enumerate(data_loader):
image = dataset["image"]
label = dataset["label"]
image = image.to(device, dtype=torch.float)
label = label.to(device, dtype=torch.float)
image, perm, lambda_value = sample_and_apply(image, alpha, decay_power, (224, 224))
optimizer.zero_grad()
outputs = model(image)
loss = loss_fn(outputs, label) * lambda_value + loss_fn(outputs, label[perm]) * (1 - lambda_value)
loss.backward()
xm.optimizer_step(optimizer)
running_loss += loss.item()
scheduler.step()
train_loss = running_loss / float(len(train_dataset))
xm.master_print('training Loss: {:.4f} '.format(train_loss))
and my dataset class look like this
import cv2
import torch
from torchvision import transforms
import albumentations
from PIL import Image
class leaf_classification(Dataset):
def __init__(self, ids, image_id, label, mean , std , is_valid):
self.ids = ids
self.image_id = image_id
self.label = label
self.is_valid = is_valid
if self.is_valid == 1: # transforms for validation images
self.aug = albumentations.Compose([
albumentations.Normalize(mean , std , always_apply = True)
])
else: # transfoms for training images
self.aug = albumentations.Compose([
albumentations.Normalize(mean , std , always_apply = True),
albumentations.ShiftScaleRotate(shift_limit = 0.0625,
scale_limit = 0.1 ,
rotate_limit = 5,
p = 0.9)
])
def __len__(self):
return len(self.ids)
def __getitem__(self, index):
# converting jpg format of images to numpy array
img = np.array(Image.open('../input/cassava-leaf-disease-classification/train_images/' + self.image_id[index]))
img = cv2.resize(img, dsize=(224, 224), interpolation=cv2.INTER_CUBIC)
img = self.aug(image = img)['image']
img = np.transpose(img , (2,0,1)).astype(np.float32) # 2,0,1 because pytorch excepts image channel first then dimension of image
return {
'image' : torch.tensor(img, dtype = torch.float) ,
'label' : torch.tensor(self.label[index], dtype = torch.float)
}
And its generating the error
while training it generating this error
please help me in resolving this error . Here's the link to my notebook
what's the cifar10 pyramidnet batch_size?
the batch_size of pyramidnet is '' can u provide the number of batch_size?
thank you!
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.