diff --git a/docker/Dockerfile.base b/docker/Dockerfile.base index 12f80ced..912a694b 100644 --- a/docker/Dockerfile.base +++ b/docker/Dockerfile.base @@ -28,7 +28,7 @@ RUN apt-get update && apt-get install -y --no-install-recommends \ libvulkan-dev \ python3-numpy WORKDIR /root -RUN git clone https://github.com/iqtlabs/gr-iqtlabs -b 1.0.76 +RUN git clone https://github.com/iqtlabs/gr-iqtlabs -b 1.0.77 COPY --from=iqtlabs/gamutrf-vkfft:latest /root /root/gr-iqtlabs WORKDIR /root/gr-iqtlabs/build COPY --from=sigmf-builder /usr/local /usr/local diff --git a/gamutrf/grscan.py b/gamutrf/grscan.py index 29f1d187..e77be517 100644 --- a/gamutrf/grscan.py +++ b/gamutrf/grscan.py @@ -50,6 +50,8 @@ def __init__( inference_output_dir="", inference_port=8002, inference_text_color="", + iq_inference_model_name="", + iq_inference_model_server="", iqtlabs=None, logaddr="0.0.0.0", # nosec logport=8001, @@ -163,6 +165,7 @@ def __init__( + self.fft_blocks + self.get_db_blocks(nfft, samp_rate, scaling) ) + self.last_db_block = self.fft_blocks[-1] fft_dir = "" self.samples_blocks = [] if write_samples: @@ -277,13 +280,36 @@ def __init__( self.msg_connect((retune_fft, "tune"), (self.sources[0], cmd_port)) self.connect_blocks(self.sources[0], self.sources[1:]) - if self.inference_blocks: - self.connect((retune_fft, 1), (self.inference_blocks[0], 0)) - self.connect_blocks(self.inference_blocks[0], self.inference_blocks[1:]) - self.connect_blocks( - self.inference_blocks[0], - [zeromq.pub_sink(1, 1, inference_zmq_addr, 100, False, 65536, "")], + # TODO: support simultaneous inference types. + # TODO: provide new block that receives JSON-over-PMT and outputs to MQTT/zmq. + iq_inference = iq_inference_model_server and iq_inference_model_name + if self.inference_blocks or iq_inference: + inference_zmq = zeromq.pub_sink( + 1, 1, inference_zmq_addr, 100, False, 65536, "" ) + + if iq_inference: + iq_inference = iqtlabs.iq_inference( + tag="rx_freq", + vlen=nfft, + sample_buffer=tune_step_fft, + min_peak_points=inference_min_db, + model_server=iq_inference_model_server, + model_names=iq_inference_model_name, + confidence=inference_min_confidence, + n_inference=n_inference, + samp_rate=int(samp_rate), + ) + self.connect((self.retune_pre_fft, 0), (iq_inference, 0)) + self.connect((self.last_db_block, 0), (iq_inference, 1)) + self.connect((iq_inference, 0), (inference_zmq, 0)) + self.connect( + (retune_fft, 1), (blocks.null_sink(gr.sizeof_float * nfft)) + ) + else: + self.connect((retune_fft, 1), (self.inference_blocks[0], 0)) + self.connect_blocks(self.inference_blocks[0], self.inference_blocks[1:]) + self.connect_blocks(self.inference_blocks[0], [inference_zmq]) else: self.connect((retune_fft, 1), (blocks.null_sink(gr.sizeof_float * nfft))) @@ -427,3 +453,6 @@ def get_fft_blocks( def start(self): super().start() self.workaround_start_hook(self) + logging.info("raw edge and message edge lists follow") + logging.info(self.edge_list()) + logging.info(self.msg_edge_list()) diff --git a/gamutrf/scan.py b/gamutrf/scan.py index bd45a596..4cee7c9c 100644 --- a/gamutrf/scan.py +++ b/gamutrf/scan.py @@ -260,6 +260,20 @@ def argument_parser(): default="", help="torchserve model server inference API address (e.g. localhost:1234)", ) + parser.add_argument( + "--iq_inference_model_name", + dest="iq_inference_model_name", + type=str, + default="", + help="torchserve model name", + ) + parser.add_argument( + "--iq_inference_model_server", + dest="iq_inference_model_server", + type=str, + default="", + help="torchserve model server inference API address (e.g. localhost:1234)", + ) parser.add_argument( "--inference_model_name", dest="inference_model_name", @@ -453,6 +467,11 @@ def check_options(options): [str(c) for c in [wc.blue, wc.green, wc.red]] ) + image_inference = options.inference_model_server and options.inference_model_name + iq_inference = options.iq_inference_model_server and options.iq_inference_model_name + if image_inference and iq_inference: + return "simultaneous image and I/Q inference not yet supported" + return "" diff --git a/orchestrator.yml b/orchestrator.yml index 4c4e55a2..1df33a10 100644 --- a/orchestrator.yml +++ b/orchestrator.yml @@ -91,6 +91,8 @@ services: # - --external_gps_server_port=8888 - --inference_output_dir=/logs/inference - --inference_model_server=torchserve:8080 + # - --iq_inference_model_server=torchserve:8080 + # - --iq_inference_model_name=mini2_snr - --pretune healthcheck: test: [CMD, "/gamutrf/bin/scanhc.sh", "9000"]