Skip to content

Commit

Permalink
Merge pull request #931 from anarkiwi/filt
Browse files Browse the repository at this point in the history
image_inference reads from retune_fft (so gets filtered FFT stream).
  • Loading branch information
anarkiwi authored Oct 23, 2023
2 parents f526ce9 + ee59a71 commit e7861bb
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 27 deletions.
3 changes: 1 addition & 2 deletions docker/Dockerfile.base
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion docs/README-airt.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 ../..
Expand Down
46 changes: 22 additions & 24 deletions gamutrf/grscan.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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
Expand All @@ -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,
Expand All @@ -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):
Expand Down

0 comments on commit e7861bb

Please sign in to comment.