diff --git a/NN_server/server.py b/NN_server/server.py index 043f3ff..331e1d0 100644 --- a/NN_server/server.py +++ b/NN_server/server.py @@ -137,19 +137,29 @@ def receive_data(): print() try: + result = 0 - if (int(freq) == 2400 and (prediction_list[0] in ['drone', 'drone_noise'] or (prediction_list[0] == 'wifi' and float(probability) >= 0.95))) or (int(freq) == 1200 and (prediction_list[0] in ['drone'] and float(probability) >= 0.95)): - result += 0 - if int(freq) in [915]: - result = 0 - if int(freq) in []: + freq_int = int(freq) + prediction = prediction_list[0] + prob = float(probability) + + if freq_int == 2400: + if prediction in ["drone", "drone_noise"]: + result += 0 + elif prediction == "wifi" and prob >= 0.95: + result += 0 + + elif freq_int == 1200: + if prediction == "drone" and prob >= 0.95: + result += 8 + + elif freq_int == 915: result = 0 - data_to_send={ - 'freq': str(freq), - 'amplitude': result - #'triggered': False if result < 7 else True, - #'light_len': result - } + + data_to_send = { + "freq": str(freq), + "amplitude": result, + } response = requests.post("http://{0}:{1}/process_data".format(gen_server_ip, gen_server_port), json=data_to_send) if response.status_code == 200: print("Данные успешно отправлены!")