Skip to content

InsightFace: how to train 112*96

左庆 edited this page Sep 16, 2018 · 1 revision

(1)修改insightface\src\image_iter.py: def net_sample(sef) line124 return之前加一句img=img[:,8:104,:]

修改前

header, img = recordio.unpack(s)

return header.label, img, None, None

修改后

header, img = recordio.unpack(s)

img = img[:,8:104,:]#added by zuoqing

return header.label, img, None, None

(2)修改insightface\src\image_iter.py: def next(self) line215 self.postprocess_data(datum)之前加一句datum=datum[:,8:104,:]

修改前

#print(datum.shape)

batch_data[i][:] = self.postprocess_data(datum)

修改后

#print(datum.shape)

datum = datum[:,8:104,:]# added by zuoqing

batch_data[i][:] = self.postprocess_data(datum)

(3)修改datasets\faces_emore\property:112,112,改成了112,96 (同理,你用其他数据训练也得改)

(4)修改insightface\src\eval\verification.py: def load_bin(path,image_size) line193 tranpose之前加一句img=img[:,8:104,:]

修改前

img = mx.image.imdecode(_bin)

img = nd.transpose(img, axes=(2, 0, 1))

修改后

img = mx.image.imdecode(_bin)

img = img[:,8:104,:]#added by zuoqing

img = nd.transpose(img, axes=(2, 0, 1))

(5)修改insightface\src\symbols\symbol_utils.py里面get_fc1把kernel改成(7,6)

改完之后显存会少使用一些,可以使用更大的batch_size

Clone this wiki locally