{"id":13586679,"url":"https://github.com/randaller/cnn-rtlsdr","last_synced_at":"2025-04-07T18:34:48.428Z","repository":{"id":27619326,"uuid":"114627844","full_name":"randaller/cnn-rtlsdr","owner":"randaller","description":"Deep learning signal classification using rtl-sdr dongle","archived":false,"fork":false,"pushed_at":"2022-12-08T00:43:58.000Z","size":29214,"stargazers_count":282,"open_issues_count":27,"forks_count":75,"subscribers_count":26,"default_branch":"master","last_synced_at":"2024-01-24T03:42:59.441Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/randaller.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-12-18T10:30:32.000Z","updated_at":"2024-01-22T12:11:15.000Z","dependencies_parsed_at":"2022-07-13T18:20:55.795Z","dependency_job_id":null,"html_url":"https://github.com/randaller/cnn-rtlsdr","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/randaller%2Fcnn-rtlsdr","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/randaller%2Fcnn-rtlsdr/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/randaller%2Fcnn-rtlsdr/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/randaller%2Fcnn-rtlsdr/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/randaller","download_url":"https://codeload.github.com/randaller/cnn-rtlsdr/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247707785,"owners_count":20982851,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-08-01T15:05:44.200Z","updated_at":"2025-04-07T18:34:48.422Z","avatar_url":"https://github.com/randaller.png","language":"Python","readme":"# CNN-rtlsdr\nDeep learning signal classification using rtl-sdr dongle.\n\nCurrent pre-trained model is able to classify 4 kinds of signals: WFM, TV Secam carrier, DMR signal and \"Others\".\n\n### TEST WITH PRETRAINED MODEL\n\nUnpack software archive into some folder, e.g. C:\\rtlsdr\n\nGo to https://www.anaconda.com/download/ and choose Python 3.6 version, 64-Bit Graphical Installer\nor download directly: https://repo.continuum.io/archive/Anaconda3-5.0.1-Windows-x86_64.exe\n\nIf you do not have modern NVIDIA graphics card, to install CPU version, just remove the following line in requirements.txt:\n```\ntensorflow-gpu==1.4.0\n```\n\nRun anaconda prompt, change dir to C:\\rtlsdr, then run:\n```\nconda install pip\npip install -r requirements.txt\n```\n\nOnly for CUDA version of Tensorflow, if you have installed CPU version, skip these steps:\n- Download and install CUDA 8 Toolkit: https://developer.nvidia.com/cuda-80-ga2-download-archive\n- Download CUDNN for Toolkit 8. https://developer.nvidia.com/cudnn\n- Extract file [bin\\cudnn64_6.dll] from zip into C:\\Windows folder.\n\nLast step is to copy 2 files from x64!!! osmocom rtl-sdr drivers: https://osmocom.org/attachments/download/2242/RelWithDebInfo.zip\n\nCopy these [rtl-sdr-release/x64/]: rtlsdr.dll \u0026 libusb-1.0.dll into C:\\Windows folder.\n\nReboot your system.\n\nNow open your anaconda prompt again, change folder to C:\\rtlsdr and run:\n```\npython predict_scan.py\n```\nto scan entire band and predict signal types , or the full version scan:\n```\npython predict_scan.py --start 85000000 --stop 108000000 --step 50000 --gain 20 --ppm 56 --threshold 0.9955\n```\n\nWatch CNN-rtlsdr in action on YouTube:\n\n[![cnn-rtlsdr in action](https://img.youtube.com/vi/OrSL9dgzlcA/0.jpg)](https://www.youtube.com/watch?v=OrSL9dgzlcA)\n\nSome help also available:\n```\npython predict_scan.py --help\n```\n\n### LINUX INSTALLATION\n\nLinux installation issues discussed here: https://github.com/randaller/cnn-rtlsdr/issues/1\n\n### TRAIN YOUR OWN DATA\n\nTo train your own model, edit the settings in file [prepare_data.py] to set own frequencies of local stations and ppm error.\n```\nsdr.err_ppm = 56     # change it to yours\n\ncollect_samples(104000000, \"wfm\")\ncollect_samples(942200000, \"gsm\")\n```\n\nThen to obtain some samples run:\n```\npython prepare_data.py\n```\n\nDelete unnecessary folders under [/testing_data] and [/training_data] as they are responsible for classificator.\nE.g., if you want to train only WFM and OTHER classes, delete everything, except of:\n- /training_data/wfm/\n- /training_data/other/\n- /testing_data/wfm/\n- /testing_data/other/\n\nCleanup previous model checkpoint before starting a new train (otherwise it will continue training old model).\n```\ncleanup.cmd\n```\n\nFinally, we may now run training (of course, we are still inside anaconda prompt):\n```\npython train.py\n```\n\nBest decision is to stop the training [ctrl+c], when validation loss becomes 0.1 - 0.01 or below. Lowest values shows better performance.\nReally, you may terminate training even after a few (20-30) epochs with values about 0.4 - 0.3 and evaluate the model.\n\nAlso, it is better to obtain different samples of signals at different frequencies, gain levels. Edit [prepare_data.py] and run it again.\nThen train the classifier again to see the difference. Feel free to sample your own signal classes to train a bigger model.\n\n### SOME TECH FOR GEEKS\n\nFirst version of this project was built using adaptation of image classification network, as the RF signal is representating also in 2D .\nI fed network with raw IQ samples, formed in a square as image, and even this gave me the model, doing it's job! This CNN graph was:\n```\nConv2D (32*3*3) -\u003e Conv2D (32*3*3) -\u003e Conv2D (64*3*3) -\u003e Dense (128) -\u003e Dense (output)\n```\n\nInspired of success, I began to try different preprocessing methods before feeding the network with complex. Neural networks generally has\nno idea, which input they serves, so I have tried to form into image shape the following:\n\nFFT data\n```\niq_samples = np.fft.fft(iq_samples)\n```\n\nAM demodulation data\n```\niq_samples = np.sqrt(np.real(iq_samples) ** 2 + np.imag(iq_samples) ** 2)\n```\n\nFM demodulation data\n```\niq_samples = np.unwrap(np.angle(iq_samples))\niq_samples = np.diff(iq_samples)\n```\n\nand all of those gave me some results. FFT version converged very fast, in a 3-5 epochs, while AM demod version showed worst performance. Finally,\nI've started googling to get more info and found the paper https://arxiv.org/pdf/1602.04105.pdf with all the CNN math great explanation. Then\nI have adapted network to match paper one, and graph now becomes:\n```\nConv2D (64*1*3) -\u003e Conv2D (16*2*3) -\u003e Dense (128) -\u003e Dense (output)\n```\n\nFeeding it with 1/4 sec raw IQ samples, sampled at 2.4 MSPS, and then decimated to a constant value of 48, left 12500 Hz bandwidth for classification.\n\n### KERAS VERSION\n\nThis is an optimized version of network, that reaches 99% accuracy while training.\n\n```\npython prepare_data.py\npython train_keras.py\n```\n\n![Keras network screenshot](https://github.com/randaller/cnn-rtlsdr/blob/master/screenshot_keras.png)\n","funding_links":[],"categories":["Python","Other SDR Software"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frandaller%2Fcnn-rtlsdr","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frandaller%2Fcnn-rtlsdr","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frandaller%2Fcnn-rtlsdr/lists"}