def test_singleton_preprocessor_service_realdata(self): args = set_preprocessor_service_parser().parse_args( ['--yaml_path', self.singleton_img_pre_yaml]) c_args = _set_client_parser().parse_args( ['--port_in', str(args.port_out), '--port_out', str(args.port_in)]) all_zips = zipfile.ZipFile(os.path.join(self.dirname, 'imgs/test.zip')) all_bytes = [all_zips.open(v).read() for v in all_zips.namelist()] with PreprocessorService(args), ZmqClient(c_args) as client: for req in RequestGenerator.index(all_bytes): msg = gnes_pb2.Message() msg.request.index.CopyFrom(req.index) client.send_message(msg) r = client.recv_message() self.assertEqual( r.envelope.routes[0].service, 'PreprocessorService:BaseSingletonPreprocessor') for d in r.request.index.docs: self.assertEqual(len(d.chunks), 1) self.assertEqual(len(blob2array(d.chunks[0].blob).shape), 3) self.assertEqual(blob2array(d.chunks[0].blob).shape[-1], 3) self.assertEqual( blob2array(d.chunks[0].blob).shape[0], 224) self.assertEqual( blob2array(d.chunks[0].blob).shape[1], 224) print(blob2array(d.chunks[0].blob).dtype)
def test_preprocessor_service_realdata(self): args = set_preprocessor_service_parser().parse_args([]) c_args = _set_client_parser().parse_args( ['--port_in', str(args.port_out), '--port_out', str(args.port_in)]) with open(os.path.join(self.dirname, '26-doc-chinese.txt'), 'r', encoding='utf8') as fp: msg = gnes_pb2.Message() all_text = '' for v in fp: if v.strip(): d = msg.request.train.docs.add() d.raw_text = v all_text += v with PreprocessorService(args), ZmqClient(c_args) as client: client.send_message(msg) r = client.recv_message() print(r) msg1 = gnes_pb2.Message() msg1.request.index.docs.extend(msg.request.train.docs) client.send_message(msg1) r = client.recv_message() print(r) msg2 = gnes_pb2.Message() msg2.request.search.query.raw_text = all_text client.send_message(msg2) r = client.recv_message() print(r)
def test_preprocessor_service_echo(self): args = set_preprocessor_service_parser().parse_args([]) c_args = _set_client_parser().parse_args([ '--port_in', str(args.port_out), '--port_out', str(args.port_in) ]) with PreprocessorService(args), ZmqClient(c_args) as client: msg = gnes_pb2.Message() msg.request.index.docs.extend([gnes_pb2.Document() for _ in range(5)]) client.send_message(msg) r = client.recv_message() print(r) msg.request.train.docs.extend([gnes_pb2.Document() for _ in range(5)]) client.send_message(msg) r = client.recv_message() print(r)
def test_video_cut_by_num(self): args = set_preprocessor_service_parser().parse_args( ['--yaml_path', self.yml_path_3]) c_args = _set_client_parser().parse_args( ['--port_in', str(args.port_out), '--port_out', str(args.port_in)]) with PreprocessorService(args), ZmqClient(c_args) as client: for req in RequestGenerator.index(self.video_bytes): msg = gnes_pb2.Message() msg.request.index.CopyFrom(req.index) client.send_message(msg) r = client.recv_message() for d in r.request.index.docs: self.assertEqual(len(d.chunks), 6)
def test_video_preprocessor_service_realdata(self): args = set_preprocessor_service_parser().parse_args( ['--yaml_path', self.yml_path]) c_args = _set_client_parser().parse_args( ['--port_in', str(args.port_out), '--port_out', str(args.port_in)]) with PreprocessorService(args), ZmqClient(c_args) as client: for req in RequestGenerator.index(self.video_bytes): msg = gnes_pb2.Message() msg.request.index.CopyFrom(req.index) client.send_message(msg) r = client.recv_message() for d in r.request.index.docs: self.assertGreater(len(d.chunks), 0) for _ in range(len(d.chunks)): shape = blob2array(d.chunks[_].blob).shape self.assertEqual(shape, (168, 192, 3))
def test_slidingwindow_preprocessor_service_empty(self): args = set_preprocessor_service_parser().parse_args( ['--yaml_path', self.slidingwindow_img_pre_yaml]) with PreprocessorService(args): pass
def test_preprocessor_service_empty(self): args = set_preprocessor_service_parser().parse_args([]) with PreprocessorService(args): pass
def test_segmentation_preprocessor_service_empty(self): args = set_preprocessor_service_parser().parse_args( ['--yaml_path', self.segmentation_img_pre_yaml]) with PreprocessorService(args): pass
def test_video_preprocessor_service_empty(self): args = set_preprocessor_service_parser().parse_args( ['--yaml_path', self.yml_path]) with PreprocessorService(args): pass
def test_preprocessor_service_empty(self): args = set_preprocessor_service_parser().parse_args( ['--yaml_path', 'BasePreprocessor']) with PreprocessorService(args): pass