imagenet-multiGPU.torch
imagenet-multiGPU.torch copied to clipboard
how to save my image data into torch format (.t7)
this is my image data
@Smerity @bobbens @pedropgusmao @soumith @ppwwyyxx
@Smerity @bobbens @pedropgusmao @soumith @ppwwyyxx
how prepare my dataset in torch file format (.t7)?? @Smerity @bobbens @pedropgusmao @soumith @ppwwyyxx
Dear zq1314;
I wrote a lua code before for this kind of work. You can edit it how you need.
require 'image'
torch.setdefaulttensortype('torch.FloatTensor')
dirname = '.'
dirs = io.popen('ls ' .. dirname)
counter = 0
for dir in dirs:lines() do
files = io.popen('ls ' .. dir)
for file in files:lines() do
if(string.sub(file,-3)=="jpg") then
counter = counter + 1
end
end
end
classcnt = 0
local allpics = torch.Tensor(counter,3,231,231)
local allclass = torch.Tensor(counter)
dirname = '.'
dirs = io.popen('ls ' .. dirname)
counter = 0
for dir in dirs:lines() do
files = io.popen('ls ' .. dir)
if(not string.find(dir,"%.")) then
print(dir)
classcnt = classcnt + 1 end
for file in files:lines() do
if(string.sub(file,-3)=="jpg") then
counter=counter+1
local img = image.load(dir.."/"..file,3)
allpics[counter]= img
allclass[counter] = classcnt
end
end
end
torch.save("data.t7",allpics)
torch.save("classes.t7",allclass)