Spaces:
Sleeping
Sleeping
Create app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import streamlit as st
|
| 2 |
+
import pandas as pd
|
| 3 |
+
import joblib
|
| 4 |
+
from predict_module import extract_features_from_video_id, predict_view_count, visualize_result, predict_views
|
| 5 |
+
|
| 6 |
+
api_key = "AIzaSyAgkZQp9EqA6N49J7TCh6Q40mWyVIGBit8"
|
| 7 |
+
model = joblib.load("model/view_predictor.joblib")
|
| 8 |
+
|
| 9 |
+
st.title("๐ฌ YouTube ์กฐํ์ ์์ธก๊ธฐ")
|
| 10 |
+
|
| 11 |
+
video_id = st.text_input("YouTube ์์ ID๋ฅผ ์
๋ ฅํ์ธ์:")
|
| 12 |
+
|
| 13 |
+
if st.button("์์ธก ์์"):
|
| 14 |
+
try:
|
| 15 |
+
# โถ info = ์์ ์ ์ฒด ์ ๋ณด ํฌํจ
|
| 16 |
+
info = predict_views(video_id, api_key)
|
| 17 |
+
|
| 18 |
+
# โท features๋ง ์ถ์ถ
|
| 19 |
+
features = extract_features_from_video_id(video_id, api_key)
|
| 20 |
+
|
| 21 |
+
# โธ ์์ธก
|
| 22 |
+
predicted = predict_view_count(model, features)
|
| 23 |
+
|
| 24 |
+
# โน ์๊ฐํํ ๋ info๋ ๋๊น
|
| 25 |
+
html = visualize_result(video_id, features, predicted, info)
|
| 26 |
+
st.components.v1.html(html, height=1000)
|
| 27 |
+
|
| 28 |
+
except Exception as e:
|
| 29 |
+
st.error(f"โ ์ค๋ฅ ๋ฐ์: {e}")
|