File size: 1,057 Bytes
fea8200
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
import streamlit as st
import pandas as pd
import joblib
from predict_module import extract_features_from_video_id, predict_view_count, visualize_result, predict_views

# joblib์—์„œ load๋ฅผ ๊ฐ€์ ธ์˜ต๋‹ˆ๋‹ค
from joblib import load

# ๋ชจ๋ธ ๋กœ๋“œ (ํŒŒ์ผ ๊ฒฝ๋กœ๋Š” Hugging Face Spaces ๊ธฐ์ค€ ์ƒ๋Œ€๊ฒฝ๋กœ๋กœ)
model = load("view_predictor.joblib")

# YouTube API ํ‚ค ์„ค์ •
api_key = "AIzaSyAgkZQp9EqA6N49J7TCh6Q40mWyVIGBit8"

st.title("๐ŸŽฌ YouTube ์กฐํšŒ์ˆ˜ ์˜ˆ์ธก๊ธฐ")

# ์‚ฌ์šฉ์ž ์ž…๋ ฅ
video_id = st.text_input("YouTube ์˜์ƒ ID๋ฅผ ์ž…๋ ฅํ•˜์„ธ์š”:")

if st.button("์˜ˆ์ธก ์‹œ์ž‘"):
    try:
        # ์ „์ฒด ์ •๋ณด
        info = predict_views(video_id, api_key)

        # ํŠน์ง• ์ถ”์ถœ
        features = extract_features_from_video_id(video_id, api_key)

        # ์˜ˆ์ธก
        predicted = predict_view_count(model, features)

        # ์‹œ๊ฐํ™” ์ถœ๋ ฅ
        html = visualize_result(video_id, features, predicted, info)
        st.components.v1.html(html, height=1000)

    except Exception as e:
        st.error(f"โŒ ์˜ค๋ฅ˜ ๋ฐœ์ƒ: {e}")