Skip to content

Commit

Permalink
Merge pull request #1137 from anarkiwi/iq
Browse files Browse the repository at this point in the history
Initial I/Q inference support (only image, or I/Q is possible current…
  • Loading branch information
anarkiwi authored Feb 1, 2024
2 parents e59e6ce + 2373a2d commit 1d58be6
Show file tree
Hide file tree
Showing 4 changed files with 57 additions and 7 deletions.
2 changes: 1 addition & 1 deletion docker/Dockerfile.base
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
41 changes: 35 additions & 6 deletions gamutrf/grscan.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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)))

Expand Down Expand Up @@ -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())
19 changes: 19 additions & 0 deletions gamutrf/scan.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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 ""


Expand Down
2 changes: 2 additions & 0 deletions orchestrator.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
Expand Down

0 comments on commit 1d58be6

Please sign in to comment.