JUNGU commited on
Commit
bd820cc
ยท
1 Parent(s): 1de3bac

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +44 -0
app.py ADDED
@@ -0,0 +1,44 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ import pandas as pd
3
+ import matplotlib.pyplot as plt
4
+
5
+ # ํŒŒ์ผ ์—…๋กœ๋“œ
6
+ uploaded_file = st.file_uploader("Choose a CSV file", type="csv")
7
+
8
+ # ๋ฐ์ดํ„ฐ ํƒ€์ž„ ํ”„๋ ˆ์ž„ ์„ ํƒ
9
+ time_frame_options = ["1๋ถ„", "5๋ถ„", "10๋ถ„", "30๋ถ„", "60๋ถ„"]
10
+ time_frame = st.selectbox("๋ฐ์ดํ„ฐ ํƒ€์ž„ ํ”„๋ ˆ์ž„ ์„ ํƒ:", time_frame_options)
11
+ time_frame_map = {"1๋ถ„": 1, "5๋ถ„": 5, "10๋ถ„": 10, "30๋ถ„": 30, "60๋ถ„": 60}
12
+ time_frame_minutes = time_frame_map[time_frame]
13
+
14
+ if uploaded_file:
15
+ # CSV ํŒŒ์ผ ์ฝ๊ธฐ
16
+ df = pd.read_csv(uploaded_file)
17
+
18
+ # timestamp๋ฅผ datetime ํ˜•ํƒœ๋กœ ๋ณ€ํ™˜
19
+ df['timestamp'] = pd.to_datetime(df['timestamp'], unit='ms')
20
+
21
+ # ์„ ํƒ๋œ ํƒ€์ž„ ํ”„๋ ˆ์ž„์œผ๋กœ ๋ฆฌ์ƒ˜ํ”Œ๋ง
22
+ df_resampled = df.resample(f'{time_frame_minutes}T', on='timestamp').mean()
23
+
24
+ # RGB ๊ทธ๋ž˜ํ”„
25
+ plt.figure(figsize=(15, 5))
26
+ plt.plot(df_resampled['R'], label='R')
27
+ plt.plot(df_resampled['G'], label='G')
28
+ plt.plot(df_resampled['B'], label='B')
29
+ plt.title('RGB Color Variation')
30
+ plt.xlabel('Time')
31
+ plt.ylabel('Value')
32
+ plt.legend()
33
+ st.pyplot()
34
+
35
+ # HSV ๊ทธ๋ž˜ํ”„
36
+ plt.figure(figsize=(15, 5))
37
+ plt.plot(df_resampled['H'], label='H')
38
+ plt.plot(df_resampled['S'], label='S')
39
+ plt.plot(df_resampled['V'], label='V')
40
+ plt.title('HSV Color Variation')
41
+ plt.xlabel('Time')
42
+ plt.ylabel('Value')
43
+ plt.legend()
44
+ st.pyplot()