hawke84 commited on
Commit
9ab5be6
·
1 Parent(s): ed76b91

Modified UI

Browse files
Files changed (1) hide show
  1. app.py +20 -8
app.py CHANGED
@@ -8,21 +8,33 @@ import json
8
  # Title for Streamlit app
9
  st.title('Isolation Forest Anomaly Detection')
10
 
11
- # Upload log to parse
12
- json_content = None
13
- uploaded_file = st.file_uploader("Upload logfile", type="json")
14
-
15
- if uploaded_file:
16
- # Get the JSON content
17
- log_content = json.loads(uploaded_file.getvalue())['logs']
18
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
19
  # Select dimensions
20
  num_dimensions = st.selectbox('Select number of dimensions:', [1, 2, 3], index=2)
21
 
22
  X = []
23
 
24
  # Iterate over each log entry in the log_content
25
- for log_entry in log_content:
26
  # Extract and convert the necessary attributes
27
  total_today_str = log_entry['distanceTraveled']['totalToday'].rstrip('m')
28
  heart_rate = int(log_entry['healthData']['heartRate']) # Assuming heart rate is always an integer
 
8
  # Title for Streamlit app
9
  st.title('Isolation Forest Anomaly Detection')
10
 
11
+ col1, col2 = st.columns(2)
 
 
 
 
 
 
12
 
13
+ # Content from upload
14
+ json_content = None
15
+ with col1:
16
+ with st.container(border=True):
17
+ uploaded_file = st.file_uploader("Upload JSON", type="json")
18
+ if uploaded_file:
19
+ json_content = json.loads(uploaded_file.getvalue())
20
+
21
+ # Content from local file
22
+ with col2:
23
+ with st.container(border=True):
24
+ st.write('Load embedded JSON')
25
+ if st.button('Load'):
26
+ with open('cattle_log.json', 'r') as file:
27
+ json_content = json.load(file)
28
+
29
+
30
+ if json_content:
31
  # Select dimensions
32
  num_dimensions = st.selectbox('Select number of dimensions:', [1, 2, 3], index=2)
33
 
34
  X = []
35
 
36
  # Iterate over each log entry in the log_content
37
+ for log_entry in json_content['logs']:
38
  # Extract and convert the necessary attributes
39
  total_today_str = log_entry['distanceTraveled']['totalToday'].rstrip('m')
40
  heart_rate = int(log_entry['healthData']['heartRate']) # Assuming heart rate is always an integer