-
Notifications
You must be signed in to change notification settings - Fork 24
/
testDatasetFullSplit.lua
66 lines (52 loc) · 1.92 KB
/
testDatasetFullSplit.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
require 'chex'
local ffi = require 'ffi'
require 'gfx.js'
dataset = chex.dataset{split=0,
paths={'../../toyset'},
sampleSize={3,255,226},
}
print('Class names', dataset.classes)
print('Total images in dataset: ' .. dataset:size())
print('Training size: ' .. dataset:sizeTrain())
print('Testing size: ' .. dataset:sizeTest())
print()
for k,v in ipairs(dataset.classes) do
print('Images for class: ' .. v .. ' : ' .. dataset:size(k) .. ' == ' .. dataset:size(v))
print('Training size: ' .. dataset:sizeTrain(k))
print('Testing size: ' .. dataset:sizeTest(k))
print('First image path: ' .. ffi.string(dataset.imagePath[dataset.classList[k][1]]:data()))
print('Last image path: ' .. ffi.string(dataset.imagePath[dataset.classList[k][#dataset.classList[k]]]:data()))
print()
end
print('Getting test samples')
local count = 0
for inputs, labels in dataset:test(16) do
print(#inputs)
print(#labels)
gfx.image(inputs)
count = count + 1
print(count)
end
-- now sample from this dataset and print out sizes, also visualize
print('Getting 128 training samples')
local inputs, labels = dataset:sample(128)
print('Size of 128 training samples')
print(#inputs)
print('Size of 128 training labels')
print(#labels)
print('Getting 1 training sample')
local inputs, labels = dataset:sample()
print('Size of 1 training sample')
print(#inputs)
print('1 training label: ' .. labels)
gfx.image(inputs)
print('Getting 2 training samples')
local inputs, labels = dataset:sample(2)
print('Size of 2 training samples')
print(#inputs)
print('Size of 1 training labels')
print(#labels)
gfx.image(inputs)
-- dataset = chex.dataset{paths={'/home/fatbox/data/imagenet12/cropped_quality100/train'}, sampleSize={3,200,200}}
-- dataset = chex.dataset{paths={'/home/fatbox/data/imagenet-fall11/images'}, sampleSize={3,200,200}}
-- dataset = chex.dataset({'asdsd'}, {3,200,200})