save CIFAR-100 images
    5 ビュー (過去 30 日間)
  
       古いコメントを表示
    
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 件のコメント
回答 (1 件)
  Antonio Cedillo Hernandez
      
 2018 年 5 月 5 日
        
      編集済み: Antonio Cedillo Hernandez
      
 2018 年 5 月 5 日
  
      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 件のコメント
  Toshi Sinha
 2019 年 6 月 3 日
				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
参考
カテゴリ
				Help Center および File Exchange で Deep Learning Toolbox についてさらに検索
			
	Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!