def stream(streamer): session, inputs, logits = construct_model( "../models/deeplab_v3_plus_53_19e_0095", (513, 513), 5) parser = Parser() cap = cv2.VideoCapture("rtsp://127.0.0.1:5000") framerate = 12.0 out = cv2.VideoWriter( 'appsrc ! videoconvert ! ' 'x264enc noise-reduction=10000 speed-preset=ultrafast tune=zerolatency ! ' 'rtph264pay config-interval=1 pt=96 !' 'tcpserversink host=127.0.0.1 port=5000 sync=false', 0, framerate, (1920, 1080)) counter = 0 while cap.isOpened(): frame = streamer.get_frame() pred = inference(frame, session, logits, inputs) result = parser.parse(pred, frame) # result = cv2.imencode('.jpg', result)[1].tobytes() out.write(result) cap.release() out.release()
def gen(streamer): session, inputs, logits = construct_model( "../models/deeplab_v3_plus_53_19e_0095", (513, 513), 5) parser = Parser() while True: frame = streamer.get_frame() pred = inference(frame, session, logits, inputs) result = parser.parse(pred, frame) result = cv2.imencode('.jpg', result)[1].tobytes() yield (b'--frame\r\n' b'Content-Type: image/jpeg\r\n\r\n' + result + b'\r\n\r\n')
dest='global_model', action='store_true', help='Train the model with Global Average Pooling') parser.add_argument('--glimpse-clouds', dest='glimpse_clouds', action='store_true', help='Train the model with Glimpse Clouds') parser.add_argument( '--pose-predictions', dest='pose_predictions', action='store_true', help='Regress the pose from the penultimate features maps') # Args args, _ = parser.parse_known_args() # Transform to dict options = vars(args) options['global_model'] = True # options['glimpse_clouds'] = True # options['pose_predictions'] = True # mini-syn test # options['root'] = '/home/hochul/Desktop/mini_syn_data' # AIR+SYN options['root'] = '/media/hochul/my_book/data/' options['workers'] = 0 if platform == "darwin" else 12 # Infer inference.inference(options)