save CIFAR-100 images
11 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
dear all, I'm working with CIFAR-100 images for training CNN, available here: https://www.cs.toronto.edu/~kriz/cifar-10-matlab.tar.gz
as im extracting the file, would see different mat files (each contain one called 'labels' another 'data'). any body know what is labels and data? how can i do the same for my own data? I meant save my images as mat file with data and labels? thanks
0 commentaires
Réponses (1)
Antonio Cedillo Hernandez
le 5 Mai 2018
Modifié(e) : Antonio Cedillo Hernandez
le 5 Mai 2018
Hi Abo! I apologize if my answer is too late, but as there is 21 views of this question in last 30 days, so I will post my answer to your question. There are three MAT files called meta.dat, test.mat and train.mat. All of them are matrices with data in order to guide the correct extracting process of the images. Here is my code to extract the images from the dataset:
if true
clc;
clear all;
load('meta.mat');
%Create folders
for i=1:length(fine_label_names)
mkdir('CIFAR-100\TEST\',fine_label_names{i});
mkdir('CIFAR-100\TRAIN\',fine_label_names{i});
end
%%Training images
load('train.mat');
im=zeros(32,32,3);
for cpt=1:50000
R=data(cpt,1:1024);
G=data(cpt,1025:2048);
B=data(cpt,2049:3072);
k=1;
for x=1:32
for i=1:32
im(x,i,1)=R(k);
im(x,i,2)=G(k);
im(x,i,3)=B(k);
k=k+1;
end
end
im=uint8(im);
pathdest = strcat('CIFAR-100\TRAIN\',fine_label_names{fine_labels(cpt)+1},'\',filenames{cpt});
imwrite(im,pathdest,'png');
end
%%Test images
load('test.mat');
im=zeros(32,32,3);
for cpt=1:10000
R=data(cpt,1:1024);
G=data(cpt,1025:2048);
B=data(cpt,2049:3072);
k=1;
for x=1:32
for i=1:32
im(x,i,1)=R(k);
im(x,i,2)=G(k);
im(x,i,3)=B(k);
k=k+1;
end
end
im=uint8(im);
pathdest = strcat('CIFAR-100\TEST\',fine_label_names{fine_labels(cpt)+1},'\',filenames{cpt});
imwrite(im,pathdest,'png');
end
end
4 commentaires
Toshi Sinha
le 3 Juin 2019
Download 7-zip and extract the ".tar.gz" files using it. They will be extracted to a folder now you can see all .mat files
Voir également
Catégories
En savoir plus sur Image Data Workflows dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!