Ejemplo n.º 1
0
	def __init__(self,vidfile,labelfile,modelFile,labelListFile,exportPath,
							perClassFrames=40,frameRate=20,context_size=5,
							banerWidth = 80,scale = 1):
		# input properties
		self.vidreader = VideoReader(vidfile);
		self.labelreader = open(labelfile,'r');
		self.N = self.vidreader.frames;
		self.width,self.height = self.vidreader.width,self.vidreader.height;
		self.context_size=context_size;
		self.perClassFrames = perClassFrames;
		self.labels = load_labels(labelListFile);
		self.n_outs = len(self.labels);
		self.flag_colors = [];
		for index in range(self.n_outs):
			self.flag_colors.extend([tuple(np.array(cm.jet(index/float(self.n_outs))[:3][::-1])*255)])
			
		with open(modelFile,'r') as fp:
			model = fp.readline();
			self.predictor = dnn_instance(model.strip());
		self.input_shape = [self.height,self.width,3]
		self.batch_size = self.predictor.batch_size
		
		#write properites
		self.banerWidth = banerWidth
		self.vidWriter = VideoWriter(exportPath,self.banerWidth+self.width,self.height,fps=frameRate);
		self.colors = np.random.randint(256, size=(len(self.labels), 3))
		self.scale = scale;
		
		#status
		self.frameIdx = 0;
		self.tasks = deque();
		self.isFinished = False;
		self.vidWriter.build();
Ejemplo n.º 2
0
def load_predictors(modelFile):
	predictors = [];
	with open(modelFile,'r') as fp:
		for model in fp:
			predictors.extend([dnn_instance(model.strip())]);
	n_outs = predictors[0].model_config['n_outs'];
	predictorStartIdx = [0]*n_outs;
	for idx in range(n_outs-1):
		predictorStartIdx[idx+1] = predictorStartIdx[idx] + predictors[idx+1].model_config['n_outs'];
	return predictors,predictorStartIdx;
Ejemplo n.º 3
0
    def __init__(self,
                 vidfile,
                 labelfile,
                 modelFile,
                 labelListFile,
                 exportPath,
                 perClassFrames=40,
                 frameRate=20,
                 context_size=5,
                 banerWidth=80,
                 scale=1):
        # input properties
        self.vidreader = VideoReader(vidfile)
        self.labelreader = open(labelfile, 'r')
        self.N = self.vidreader.frames
        self.width, self.height = self.vidreader.width, self.vidreader.height
        self.context_size = context_size
        self.perClassFrames = perClassFrames
        self.labels = load_labels(labelListFile)
        self.n_outs = len(self.labels)
        self.flag_colors = []
        for index in range(self.n_outs):
            self.flag_colors.extend([
                tuple(
                    np.array(cm.jet(index / float(self.n_outs))[:3][::-1]) *
                    255)
            ])

        with open(modelFile, 'r') as fp:
            model = fp.readline()
            self.predictor = dnn_instance(model.strip())
        self.input_shape = [self.height, self.width, 3]
        self.batch_size = self.predictor.batch_size

        #write properites
        self.banerWidth = banerWidth
        self.vidWriter = VideoWriter(exportPath,
                                     self.banerWidth + self.width,
                                     self.height,
                                     fps=frameRate)
        self.colors = np.random.randint(256, size=(len(self.labels), 3))
        self.scale = scale

        #status
        self.frameIdx = 0
        self.tasks = deque()
        self.isFinished = False
        self.vidWriter.build()