Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -8,7 +8,7 @@ import zipfile
|
|
8 |
# Cache the model loading
|
9 |
@st.cache_resource
|
10 |
def load_model():
|
11 |
-
#
|
12 |
url = "https://drive.google.com/uc?id=1m9YVs0cBRT3-j98rn7d_0DT7jwB_EXPu"
|
13 |
output = 'model.zip'
|
14 |
gdown.download(url, output, quiet=False)
|
@@ -19,7 +19,7 @@ def load_model():
|
|
19 |
model = tf.keras.models.load_model('best_model')
|
20 |
return model
|
21 |
|
22 |
-
# Cache the JSON
|
23 |
@st.cache_data
|
24 |
def load_json(filename):
|
25 |
with open(filename, 'r') as f:
|
@@ -58,23 +58,20 @@ def predict_rating(reviewerID, itemID, model):
|
|
58 |
prediction = model.predict(prediction_inputs)
|
59 |
return prediction.item()
|
60 |
|
61 |
-
# Load the model
|
62 |
model = load_model()
|
63 |
|
64 |
-
#
|
65 |
st.title('Music Rating Prediction - Amazon Review')
|
66 |
|
67 |
# Example input values
|
68 |
example_reviewerID = "61658" # Example reviewerID
|
69 |
example_itemID = "5000" # Example itemID
|
70 |
|
71 |
-
#
|
72 |
-
|
73 |
-
|
74 |
-
reviewerID = st.text_input('Reviewer ID')
|
75 |
-
itemID = st.text_input('Item ID')
|
76 |
|
77 |
-
#
|
78 |
if st.button('Predict Rating'):
|
79 |
prediction = predict_rating(reviewerID, itemID, model)
|
80 |
st.write(f'Predicted Rating: {prediction:.2f} ⭐')
|
|
|
8 |
# Cache the model loading
|
9 |
@st.cache_resource
|
10 |
def load_model():
|
11 |
+
# Saved model link
|
12 |
url = "https://drive.google.com/uc?id=1m9YVs0cBRT3-j98rn7d_0DT7jwB_EXPu"
|
13 |
output = 'model.zip'
|
14 |
gdown.download(url, output, quiet=False)
|
|
|
19 |
model = tf.keras.models.load_model('best_model')
|
20 |
return model
|
21 |
|
22 |
+
# Cache the JSON
|
23 |
@st.cache_data
|
24 |
def load_json(filename):
|
25 |
with open(filename, 'r') as f:
|
|
|
58 |
prediction = model.predict(prediction_inputs)
|
59 |
return prediction.item()
|
60 |
|
|
|
61 |
model = load_model()
|
62 |
|
63 |
+
# App interface
|
64 |
st.title('Music Rating Prediction - Amazon Review')
|
65 |
|
66 |
# Example input values
|
67 |
example_reviewerID = "61658" # Example reviewerID
|
68 |
example_itemID = "5000" # Example itemID
|
69 |
|
70 |
+
# Inputs
|
71 |
+
reviewerID = st.text_input('Reviewer ID', value=example_reviewerID)
|
72 |
+
itemID = st.text_input('Item ID', value=example_itemID)
|
|
|
|
|
73 |
|
74 |
+
# Button
|
75 |
if st.button('Predict Rating'):
|
76 |
prediction = predict_rating(reviewerID, itemID, model)
|
77 |
st.write(f'Predicted Rating: {prediction:.2f} ⭐')
|