yearye commited on
Commit
77e5692
ยท
verified ยท
1 Parent(s): 98c771b

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +29 -0
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}")