mfc7n=mfc7/np.max(mfc7) cum_feats += mfc7 # add n to make normalised local_cum_feats += mfc7 # mean pooled 4096 vector mean_feats = cum_feats/cumFrames local_feats = local_cum_feats/local_cum_frames # graph=np.zeros(shape=(900,1024),dtype=np.uint8) # for p in range(4): # for pp in range(1024): # graph[225*(p+1)-(200*mfc7n[(p*1024)+pp]):225*(p+1),pp]=255 # # cv2.imshow('FC7',graph) if RNN_IN == 2: description_fw = my_rnn.get_description(fc7,rnn_cp) top_prediction_fw = description_fw['score'] candidate_fw = description_fw['sent'] #RNN EVAL if RNN_IN > 0: description = my_rnn.get_description(mean_feats,rnn_cp) top_prediction = description['score'] candidate = description['sent'] if change == 1: top_prediction_lp = top_prediction_lc candidate_lp = candidate_lc sent_str='(%d) .:. (%f) %s\n' % (last_seq_length,top_prediction_lp, candidate_lp) out_str=time_str+sent_str time_str='%02d:%02d:%02d ' % (int(((frameNum/25)/60)/60),int(((frameNum/25)/60)%60),int((frameNum/25)%60))
prediction = utils.get_prediction(frame, cnn_net) # Find and store indices of Top n results ind = np.argpartition(prediction[0], -TOP_N)[-TOP_N:] ind = ind[np.argsort(prediction[0][ind])] # Maximum Score if prediction[0][ind[TOP_N-1]] > max_score[1]: max_score[2] = frameNum max_score[1] = prediction[0][ind[TOP_N-1]] max_score[0] = ind[TOP_N-1] fc7 = cnn_net.blobs['fc7'].data # = numpy ndarray of the fc7 layer description = my_rnn.get_description(fc7,rnn_cp) top_prediction = description['score'] candidate = description['sent'] # Display classifications and sentences predictions if cumFrames > 0: cv2.putText(display,'FRAMEWISE', (30,3*displayH/4+20), cv2.FONT_HERSHEY_SIMPLEX, .6, (200,200,200)) # For top n, print result onto video for i in range(0,TOP_N): cv2.putText(display,str(TOP_N-i)+' : '+'%.4f' % prediction[0][ind[i]]+' '+str(ind[i])+' '+classes[ind[i]][1], (30,3*displayH/4+20+22*(TOP_N-i)), cv2.FONT_HERSHEY_SIMPLEX, .6, (0,255,0)) # Display Sentence if RNN_IN > 1: cv2.putText(display,'FWS: (%f) %s' % (top_prediction, candidate), (30,3*displayH/4+20+22*(TOP_N+1)), cv2.FONT_HERSHEY_SIMPLEX, .6, (200,200,200)) cv2.putText(display,'GT: (1) %s' % (ground_truth), (30,3*displayH/4+50+22*(TOP_N+1)), cv2.FONT_HERSHEY_SIMPLEX, .6, (20,220,20))