def predict(self, event=None):
try:
first = int(self.predict_first.text())
last = int(self.predict_last.text())
num_proc = int(self.num_proc.text())
except ValueError:
sys.stderr.write('Integers only\n')
return
if last < 0:
last = self.parent.num_frames
if self.get_and_convert(first).shape[0] != self.parent.converted.shape[1]:
sys.stderr.write('Wrong length for converted image (expected %d, got %d). You may need to update converter.\n' %
(self.parent.converted.shape[1], self.get_and_convert(first).shape[0]))
return
predictions = multiprocessing.Array(ctypes.c_char, self.parent.num_frames)
jobs = []
for i in range(num_proc):
p = multiprocessing.Process(target=self.predict_worker, args=(i, num_proc, np.arange(first, last, dtype='i4'), predictions))
jobs.append(p)
p.start()
for j in jobs:
j.join()
sys.stderr.write('\r%d/%d\n' % (last, last))
self.predictions = np.frombuffer(predictions.get_obj(), dtype='S1')
self.gen_predict_summary()
评论列表
文章目录