From 5d72c8633a61647126edbe91faff17eb1505a3e8 Mon Sep 17 00:00:00 2001 From: Benjamin Cretois Date: Mon, 2 Oct 2023 13:26:58 +0200 Subject: [PATCH] [ADD] send message when analysis is done --- .gitignore | 4 +- CONFIG.yaml | 6 +- .../__pycache__/custom_model.cpython-38.pyc | Bin 1374 -> 1501 bytes .../simple_tokenizer.cpython-38.pyc | Bin 5777 -> 5832 bytes cloud_Dockerfile | 3 +- cloud_analysis/main.py | 64 +++++++++++++++--- cloud_analysis/test.sh | 5 ++ logs/logfile.log | 0 8 files changed, 69 insertions(+), 13 deletions(-) create mode 100755 cloud_analysis/test.sh delete mode 100644 logs/logfile.log diff --git a/.gitignore b/.gitignore index 1c783b5..0496a53 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,5 @@ audioclip/assets/* **/*/__pycache__/* -singing_in_noise/Figures_MS/* \ No newline at end of file +singing_in_noise/Figures_MS/* +cloud_analysis/gmail_logs.env +logs/logfile.log \ No newline at end of file diff --git a/CONFIG.yaml b/CONFIG.yaml index 4a743ca..ec8d001 100644 --- a/CONFIG.yaml +++ b/CONFIG.yaml @@ -3,6 +3,6 @@ ###################################### # List of paths to initialise the model -path_tokenizer_file: "./assets/bpe_simple_vocab_16e6.txt.gz" -path_audioclip: './assets/AudioCLIP-Full-Training.pt' -path_snowmobile_model: "./assets/snowmobile_model.pth" \ No newline at end of file +path_tokenizer_file: "/app/audioclip/assets/bpe_simple_vocab_16e6.txt.gz" +path_audioclip: '/app/audioclip/assets/AudioCLIP-Full-Training.pt' +path_snowmobile_model: "/app/audioclip/assets/snowmobile_model.pth" \ No newline at end of file diff --git a/audioclip/model/__pycache__/custom_model.cpython-38.pyc b/audioclip/model/__pycache__/custom_model.cpython-38.pyc index b2c7809455cdd8f7858a32488f81e48d70cef4d7..adcc90fa72aad4dfc5d105294b5d82da44122f24 100644 GIT binary patch delta 720 zcmYjOPixdb6rahT-DEb|-PT1bC{(JJrLwDF5ky2#T7i{8agpfg!$J1}qFpLxIcd++@uKN@S#T$dnu{(b*K#|A>b zlyUml(zqvY_GY$rYd{gj-1cnwn%tfck6^?aw04L;c07mKyDoDWq4oEg*L;rF(G&C( zy+E6YTGW1vsLg7-twY^wQ@oA3WOlH++Qouw6r67*0cCLD_WJi94>lfd_V$Abm%-XR zFgtohOi4pmR34NU@XE_vr`mZG;i>jX`+%p&H>OIOQ}nrZgfOB=*3bunq`-0rqL@*y znFjgT4+;p@+j!`4!(VU1@pcZ@hf_az9AZ{&8x5 zl2FF`VUgv@#IKBAx({lYZF#e5s+iz5UMg>D@32#T({?%vPLPlXSr!c=23-SMsQ6DDo zIsm#{t{dBtVpV~|6_xJ#e#IqZoXgfvNT?Q|Vp5lyDwWlwuyC_(*`R#g1!3k1gk#X8 zC9F#C#WAQ2!KL!AaWxi(S|X^u2_s2aEbvemTy7c~(&x3dqR}{yqj>Zvp#^6Z@F^B2 dU08SIgyoOBSmtHQZ(#>Jnx#3q(gix93!yIeX{6XTStQpZ%~5r%DzoNheagTJI&(X)n=Q7P@zLCer*~fA`VG_AJXb z9+M`WjBZYg*fU?DWq!h~n6j74<6Ov$Cu%es%SoXxpbR)4WC-H?g8f)Sta)a&n?9<^ zp{tQ0gcWF-Q|k=`re*IpD_B_h(qSr9?5N0`*q!DIdQ??bsjFjIH6QKcZh&1G$;ki% z@Pq=ZEA#~0Wj)JBT<61LoE*nCf}T39_Wz)=Hq6ygqQsgxbN2d_u41bWF&ckI7|1N+ z{Lk+z{}Sn{ATD+kL3>zySgQGfqPMtiZn#(Bn%Q;NcMg{O>FBVa-95;~ER&Vw67Sz& WrGE!EiHc1iD6PYX2qMe3BI`H7h=9KU diff --git a/audioclip/utils/__pycache__/simple_tokenizer.cpython-38.pyc b/audioclip/utils/__pycache__/simple_tokenizer.cpython-38.pyc index 268676f42f2519fe757a0e71f318b8ac55f3acae..a33c9a8227fea9a6275a820ac70469495349b6a6 100644 GIT binary patch delta 1952 zcmZuyO>7%Q6rNe{Zq{o%aei8w3L;U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KW?__ugkl6 zzW6dpS>vo;SL1#v5;u+Ab`bM{}XQ$DrFwHui^ zePVG{q;AU#AQ>bRlL33$S0Ng(K-oU zMNsyJ7q&$L7f3=RWsA*JL>w-Xq@UotoUIPC3E8Y(o|rQ<>NUD!&rOUWyHhjUT{1gFDAYGX6~HH5=TkemN2RANEX7)NrT9;2rv8C5G2XSu->@>+P9U5sA$f)VJlk zJ=fU{B5xm&mrlsbMfx9PPCRb{)=}#l9MmI*g~iLlEd#YYj3KCe7=I-ICTLz*!8pAz zgimSvsCp4y&@A-8Fs>Uw#jaUdf=6+_Tsl5K0Zz>4vyh_<;6egqoQZ*iPeqtZ)Jp?b+Z+dq=kVmbU5Vqs$})xJ!DN zEJKH$8PqvB0je-uMVP~pI0z2w?RIL8qouV@SVS2N5m50|aitykX&i?M=)S!|!aRso z>`N*htkC%|KtL_5tE=m*?6|Qm{8Sr0b+5EDy3?GQX3X26sGCSk&LcSZUvpR`hiF=? NWZ^jHR2 0.1 and confidence > 0.99: + count += 1 + + # create the detections dataset detections.append({ u"start": start, u"end": end, u"tags": ["snowmobile"], + u"confidence": confidence, + u"harmonic_ratio": harmonic_ratio, #u"analysisId": analysis_id, # Add any other information you want to record here - u"confidence": confidence, - u"harmonic_ratio": harmonic_ratio }) - print(detections) - print(f"{audio_id} completed with {len(detections)} detections") + return count @app.route('/process-audio', methods=['POST']) @@ -91,12 +136,15 @@ def process_audio_endpoint(): audio_id = request.json['audio_id'] audio_rec = request.json['audio_rec'] - on_process_audio(audio_id, audio_rec, audio_file_path) + detection_count = on_process_audio(audio_id, audio_rec, audio_file_path) + + #if detection_count > 0: + send_email("Snowmobile Detection Alert", f"{detection_count} snowmobile detections were made in the audio file!") return jsonify({"message": "Audio processing completed!"}) if __name__ == "__main__": - + app.debug = True app.run(host='0.0.0.0', port=8080) diff --git a/cloud_analysis/test.sh b/cloud_analysis/test.sh new file mode 100755 index 0000000..fa5345e --- /dev/null +++ b/cloud_analysis/test.sh @@ -0,0 +1,5 @@ +#!/bin/bash + +curl -X POST -H "Content-Type: application/json" \ + -d '{"audio_file_path": "/app/example/example_audio.mp3", "audio_id": "test-id", "audio_rec": {"location": {"latitude": 0, "longitude": 0}}}' \ + http://localhost:8080/process-audio \ No newline at end of file diff --git a/logs/logfile.log b/logs/logfile.log deleted file mode 100644 index e69de29..0000000