Create app.py
Browse files
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()
|