From ee59a71bc1b78e9ffca5640a598945a1d270d5a1 Mon Sep 17 00:00:00 2001 From: Josh Bailey Date: Fri, 20 Oct 2023 21:00:55 +0000 Subject: [PATCH] image_inference reads from retune_fft (so gets filtered FFT stream). --- docker/Dockerfile.base | 3 +-- docs/README-airt.md | 2 +- gamutrf/grscan.py | 46 ++++++++++++++++++++---------------------- 3 files changed, 24 insertions(+), 27 deletions(-) diff --git a/docker/Dockerfile.base b/docker/Dockerfile.base index 3d8370ef..774fcafa 100644 --- a/docker/Dockerfile.base +++ b/docker/Dockerfile.base @@ -87,8 +87,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.44 -RUN sed -i /SPIRV-Tools/d gr-iqtlabs/lib/CMakeLists.txt +RUN git clone https://github.com/iqtlabs/gr-iqtlabs -b 1.0.45 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/docs/README-airt.md b/docs/README-airt.md index f0a79f5d..7d34d8dd 100644 --- a/docs/README-airt.md +++ b/docs/README-airt.md @@ -85,7 +85,7 @@ install gr-iqtlabs $ git clone https://github.com/google/flatbuffers -b v23.5.26 $ git clone https://github.com/nlohmann/json -b v3.11.2 $ git clone https://github.com/deepsig/libsigmf -b v1.0.2 -$ git clone https://github.com/iqtlabs/gr-iqtlabs -b 1.0.44 +$ git clone https://github.com/iqtlabs/gr-iqtlabs -b 1.0.45 $ mkdir -p flatbuffers/build && cd flatbuffers/build && cmake -DCMAKE_INSTALL_PREFIX=~/.conda/envs/$CONDA_DEFAULT_ENV .. && make -j $(nproc) && make install && cd ../.. $ mkdir -p json/build && cd json/build && cmake -DCMAKE_INSTALL_PREFIX=~/.conda/envs/$CONDA_DEFAULT_ENV .. && make -j $(nproc) && make install && cd ../.. $ mkdir -p libsigmf/build && cd libsigmf/build && cmake -DUSE_SYSTEM_JSON=ON -DUSE_SYSTEM_FLATBUFFERS=ON -DCMAKE_INSTALL_PREFIX=~/.conda/envs/$CONDA_DEFAULT_ENV -DCMAKE_CXX_FLAGS="-I $HOME/.conda/envs/$CONDA_DEFAULT_ENV/include" .. && make -j $(nproc) && make install && cd ../.. diff --git a/gamutrf/grscan.py b/gamutrf/grscan.py index 050c7941..189af8f5 100644 --- a/gamutrf/grscan.py +++ b/gamutrf/grscan.py @@ -151,7 +151,6 @@ def __init__( pretune, ) self.fft_blocks = fft_blocks + self.get_db_blocks(nfft, samp_rate, scaling) - self.fft_to_inference_block = self.fft_blocks[-1] retune_fft = self.iqtlabs.retune_fft( "rx_freq", @@ -179,7 +178,7 @@ def __init__( logging.info("serving FFT on %s", zmq_addr) self.fft_blocks.append((zeromq.pub_sink(1, 1, zmq_addr, 100, False, 65536, ""))) - self.inference_blocks = [] + self.inference_blocks = [blocks.null_sink(gr.sizeof_float * nfft)] if inference_output_dir: x = 640 y = 640 @@ -190,26 +189,24 @@ def __init__( image_dir = Path(inference_output_dir, "images") Path(inference_output_dir).mkdir(parents=True, exist_ok=True) image_dir.mkdir(parents=True, exist_ok=True) - self.image_inference_block = self.iqtlabs.image_inference( - tag="rx_freq", - vlen=nfft, - x=x, - y=y, - image_dir=str(image_dir), - convert_alpha=255, - norm_alpha=0, - norm_beta=1, - norm_type=32, # cv::NORM_MINMAX = 32 - colormap=16, # cv::COLORMAP_VIRIDIS = 16, cv::COLORMAP_TURBO = 20, - interpolation=1, # cv::INTER_LINEAR = 1, - flip=0, - min_peak_points=inference_min_db, - model_server=inference_model_server, - model_name=inference_model_name, - ) self.inference_blocks = [ - blocks.stream_to_vector(gr.sizeof_float * nfft, 1), - self.image_inference_block, + self.iqtlabs.image_inference( + tag="rx_freq", + vlen=nfft, + x=x, + y=y, + image_dir=str(image_dir), + convert_alpha=255, + norm_alpha=0, + norm_beta=1, + norm_type=32, # cv::NORM_MINMAX = 32 + colormap=16, # cv::COLORMAP_VIRIDIS = 16, cv::COLORMAP_TURBO = 20, + interpolation=1, # cv::INTER_LINEAR = 1, + flip=0, + min_peak_points=inference_min_db, + model_server=inference_model_server, + model_name=inference_model_name, + ), yolo_bbox( str(Path(inference_output_dir, "predictions")), inference_min_confidence, @@ -223,17 +220,18 @@ def __init__( else: self.msg_connect((retune_fft, "tune"), (self.sources[0], cmd_port)) self.connect_blocks(self.sources[0], self.sources[1:]) - self.connect_blocks(self.fft_to_inference_block, self.inference_blocks) + self.connect((retune_fft, 1), (self.inference_blocks[0], 0)) + self.connect_blocks(self.inference_blocks[0], self.inference_blocks[1:]) for pipeline_blocks in ( self.fft_blocks, self.samples_blocks, ): self.connect_blocks(self.sources[-1], pipeline_blocks) - def connect_blocks(self, source, other_blocks): + def connect_blocks(self, source, other_blocks, last_block_port=0): last_block = source for block in other_blocks: - self.connect((last_block, 0), (block, 0)) + self.connect((last_block, last_block_port), (block, 0)) last_block = block def get_db_blocks(self, nfft, samp_rate, scaling):