Register
Login
Resources
Docs Blog Datasets Glossary Case Studies Tutorials & Webinars
Product
Data Engine LLMs Platform Enterprise
Pricing Explore
Connect to our Discord channel

ad_app.py 1.5 KB

You have to be logged in to leave a comment. Sign In
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
  1. import streamlit as st
  2. import requests as re
  3. import zipfile
  4. import json
  5. from time import sleep
  6. import yaml
  7. import pandas as pd
  8. from src.prepare_data import get_data
  9. # title of web app
  10. SERVICE_URL = "https://ecg-ad.herokuapp.com/predict"
  11. st.markdown('# **Web App for Anomaly Detection in ECG signals**')
  12. bar = st.progress(0)
  13. st.sidebar.header('Upload pickle file')
  14. def save_zip():
  15. list_files = ['ecg_data/pred.pickle']
  16. with zipfile.ZipFile('final.zip', 'w') as zipF:
  17. for file in list_files:
  18. zipF.write(file, compress_type=zipfile.ZIP_DEFLATED)
  19. zipF.close()
  20. with st.sidebar.form(key='my_form'):
  21. uploaded_file = st.file_uploader("Choose a file", accept_multiple_files=True)
  22. if uploaded_file is not None:
  23. array = get_data(dir)
  24. df = pd.read_csv(uploaded_file)
  25. array = df.array
  26. st.write(array)
  27. submit_button = st.form_submit_button(label='Submit')
  28. if submit_button:
  29. res = re.post(SERVICE_URL,array)
  30. json_str = json.dumps(res.json())
  31. resp = json.loads(json_str)
  32. st.write(f"""### The predictions are: {resp[0]}$.""")
  33. import pickle
  34. f=open('ecg_data/pred.pickle','wb')
  35. pickle.dump(resp[0], f)
  36. f.close()
  37. save_zip()
  38. with open("final.zip", "rb") as zip_download:
  39. btn = st.download_button(
  40. label="Download",
  41. data=zip_download,
  42. file_name="final.zip",
  43. mime="application/zip"
  44. )
Tip!

Press p or to see the previous file or, n or to see the next file

Comments

Loading...