Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion gr-spectrumdetect/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ RUN apt-get update && apt-get install -y \
python3 \
python3-dev \
python3-numpy \
python3-apt \
pip \
gcc \
g++ \
Expand Down Expand Up @@ -57,7 +58,7 @@ RUN pip install torchaudio -U

RUN pip install pybombs

RUN pybombs config makewidth 56
RUN pybombs config makewidth 4

RUN pybombs recipes add gr-recipes https://github.com/gnuradio/gr-recipes.git

Expand Down
34 changes: 18 additions & 16 deletions gr-spectrumdetect/README.md
Original file line number Diff line number Diff line change
@@ -1,16 +1,14 @@
## GR-Spectrumdetect Overview
## gr-spectrumdetect Overview
---
gr-spectrumdetect is an open-source example of using a trained model from TorchSig Wideband with GNU Radio for RF energy detection.

`detect.pt` can be downloaded with the bash `trained_model_download.sh` script in `gr-spectrumdetect/examples/`.
- If `trained_model_download.sh` does not work, try using `trained_model_download_github.sh` (Downloads the model from [TorchSig's Github v0.6.0 Release Notes](https://github.com/TorchDSP/torchsig/releases/tag/v0.6.0))

`detect.pt` is a YOLOv8x model trained for detection with the following settings:
- single_cls=True
- 1024x1024 spectrograms
- gray scale black hot images
- Wideband with level 2 impairments with no signal overlap
- `torchsig/datasets/conf.py` -> `WidebandImpairedTrainConfig` -> `overlap_prob = 0.0`
- Wideband with level 2 impairments

### Notes
- The first class of `wideband_yolo.yaml` has been modified to say `signal` because this training method is detection only.
Expand All @@ -27,18 +25,22 @@ yolo detect train data=wideband_yolo.yaml model=yolov8x pretrained=yolov8x.pt de

## Installation with Docker
---
Clone the `torchsig` repository and install using the following commands:
The following command downloads a couple files needed to run the GNU Radio block:
```
git clone https://github.com/TorchDSP/torchsig.git
cd torchsig
pip install .
cd gr-spectrumdetect
bash build_docker.sh
bash run_docker.sh
cd /build/gr-spectrumdetect/examples/
source /opt/gnuradio/v3.10/setup_env.sh
bash trained_model_download.sh
gnuradio-companion example.grc &
$ cd torchsig/gr-spectrumdetect/examples
$ bash trained_model_download.sh
```
Now move back to the `gr-spectrumdetect` directory, then install and run the docker container:
```
$ cd ..
$ bash build_docker.sh
$ bash run_docker.sh
```
Now running inside the docker:
```
# source /opt/gnuradio/v3.10/setup_env.sh
# cd /build/gr-spectrumdetect/examples/
# gnuradio-companion example.grc &
```

## Installation without Docker
Expand Down Expand Up @@ -69,4 +71,4 @@ bash train.sh

## License
---
gr-spectrumdetect is released under the MIT License. The MIT license is a popular open-source software license enabling free use, redistribution, and modifications, even for commercial purposes, provided the license is included in all copies or substantial portions of the software. TorchSig has no connection to MIT, other than through the use of this license.
gr-spectrumdetect is released under the MIT License. The MIT license is a popular open-source software license enabling free use, redistribution, and modifications, even for commercial purposes, provided the license is included in all copies or substantial portions of the software. TorchSig has no connection to MIT, other than through the use of this license.
25 changes: 17 additions & 8 deletions gr-spectrumdetect/examples/example.grc
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ blocks:
id: variable
parameters:
comment: ''
value: '25000000'
value: '50000000'
states:
bus_sink: false
bus_source: false
Expand Down Expand Up @@ -128,19 +128,28 @@ blocks:
parameters:
affinity: ''
alias: ''
augment: 'False'
center_frequency: centerFrequency
comment: ''
debug_sigMF: 'False'
iou: '0.1'
max_det: '300'
detect_json: 'False'
gpu_device: '0'
gpu_half: 'True'
maxoutbuf: '0'
minoutbuf: '0'
n_fft: nfft
sample_rate: sampleRate
save: 'False'
trained_model: trainedModel
trained_narrowband_model: xcit.ckpt
trained_wideband_model: 11s.pt
vector_size: vectorSize
wb_detect_only: 'True'
write_labeled_wb_images: 'False'
write_nb_iq_file: 'False'
write_wb_images: 'False'
write_wb_iq_file: 'False'
yolo_agnostic_nms: 'False'
yolo_augment: 'False'
yolo_conf: '0.25'
yolo_iou: '0.7'
yolo_max_det: '300'
states:
bus_sink: false
bus_source: false
Expand Down Expand Up @@ -169,7 +178,7 @@ blocks:
parameters:
affinity: ''
alias: ''
ant0: '"TX/RX"'
ant0: '"RX2"'
ant1: '"RX2"'
ant10: '"RX2"'
ant11: '"RX2"'
Expand Down
2 changes: 1 addition & 1 deletion gr-spectrumdetect/examples/train.sh
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
#!/bin/bash
yolo detect train data=wideband_detector_yolo.yaml model=yolov11s pretrained=yolov11s.pt device=0 epochs=1 batch=32 save=True save_period=1 single_cls=True imgsz=1024 name=11s_freeze1 cos_lr=False cache=False workers=16 freeze=1 lr0=0.0001 optimizer=SGD
yolo detect train data=wideband_yolo.yaml model=yolov8x pretrained=yolov8x.pt device=0 epochs=1 batch=32 save=True save_period=1 single_cls=True imgsz=1024 name=8x_freeze1 cos_lr=False cache=False workers=16 freeze=1 lr0=0.0033329 optimizer=SGD
22 changes: 22 additions & 0 deletions gr-spectrumdetect/examples/trained_model_download.sh
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,25 @@ if [ $? -eq 0 ]; then
else
echo "Download failed."
fi

destination_path=11s.pt
download_url=https://bucket.ltsnet.net/torchsig/models/11s.pt

curl -L -o "$destination_path" "$download_url"

if [ $? -eq 0 ]; then
echo "Download completed successfully."
else
echo "Download failed."
fi

destination_path=xcit.ckpt
download_url=https://bucket.ltsnet.net/torchsig/models/xcit.ckpt

curl -L -o "$destination_path" "$download_url"

if [ $? -eq 0 ]; then
echo "Download completed successfully."
else
echo "Download failed."
fi
13 changes: 0 additions & 13 deletions gr-spectrumdetect/examples/trained_model_download_github.sh

This file was deleted.

79 changes: 62 additions & 17 deletions gr-spectrumdetect/grc/spectrumDetect_specDetect.block.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ category: '[spectrumDetect]'

templates:
imports: from gnuradio import spectrumDetect
make: spectrumDetect.specDetect(${center_frequency},${sample_rate},${vector_size}, ${n_fft}, ${trained_model}, ${augment}, ${iou}, ${save}, ${max_det}, ${debug_sigMF})
make: spectrumDetect.specDetect(${center_frequency},${sample_rate},${vector_size}, ${n_fft},${trained_wideband_model}, ${trained_narrowband_model}, ${yolo_augment}, ${yolo_iou}, ${yolo_conf}, ${yolo_agnostic_nms}, ${yolo_max_det}, ${write_labeled_wb_images}, ${write_wb_images}, ${write_wb_iq_file}, ${write_nb_iq_file}, ${gpu_device}, ${gpu_half}, ${detect_json}, ${wb_detect_only})

parameters:
- id: center_frequency
Expand All @@ -16,7 +16,7 @@ parameters:
- id: sample_rate
label: sampleRate
dtype: float
default: 20000000.0
default: 50000000.0

- id: vector_size
label: vectorSize
Expand All @@ -28,35 +28,80 @@ parameters:
dtype: int
default: 1024

- id: trained_model
label: trainedModel
- id: trained_wideband_model
label: trainedWidebandModel
dtype: string
default: 'detect.pt'
default: '11s.pt'

- id: augment
label: yoloAugment
- id: trained_narrowband_model
label: trainedNarrowbandModel
dtype: string
default: 'xcit.ckpt'

- id: yolo_augment
label: augment
dtype: bool
default: False

- id: iou
label: yoloIOU
- id: yolo_iou
label: iou
dtype: float
default: 0.7

- id: yolo_conf
label: conf
dtype: float
default: 0.1
default: 0.25

- id: save
label: yoloSave
- id: yolo_agnostic_nms
label: agnosticNms
dtype: bool
default: False
default: False

- id: max_det
label: yoloMAX_DET
- id: yolo_max_det
label: maxDet
dtype: int
default: 300

- id: write_labeled_wb_images
label: writeLabeledWBImages
dtype: bool
default: False

- id: write_wb_images
label: writeWBImages
dtype: bool
default: False

- id: write_wb_iq_file
label: writeWBIQFile
dtype: bool
default: False

- id: debug_sigMF
label: debugOut_sigMF
- id: write_nb_iq_file
label: writeNBIQFile
dtype: bool
default: False

- id: gpu_device
label: gpuDevice
dtype: string
default: '0'

- id: gpu_half
label: gpuHalf
dtype: bool
default: False

- id: detect_json
label: detectJson
dtype: bool
default: False

- id: wb_detect_only
label: wbDetectOnly
dtype: bool
default: True

inputs:
- label: vector
Expand Down
Loading