Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -79,12 +79,10 @@ def get_similar_and_recommend(input_text):
|
|
79 |
]
|
80 |
dot_products[given_video_index] = -float("inf")
|
81 |
|
82 |
-
|
83 |
-
return [df.iloc[idx].to_dict() for idx in
|
84 |
|
85 |
-
top_10_recommended_videos_features = recommend_next_10_videos(
|
86 |
-
most_similar_index, all_video_embeddings
|
87 |
-
)
|
88 |
|
89 |
# Exclude unwanted features for recommended videos
|
90 |
for recommended_video in top_10_recommended_videos_features:
|
@@ -92,7 +90,7 @@ def get_similar_and_recommend(input_text):
|
|
92 |
if key in recommended_video:
|
93 |
del recommended_video[key]
|
94 |
|
95 |
-
# Create the output JSON with all features except
|
96 |
output = {
|
97 |
"most_similar_video": most_similar_video_features,
|
98 |
"top_10_recommended_videos": top_10_recommended_videos_features,
|
@@ -100,13 +98,13 @@ def get_similar_and_recommend(input_text):
|
|
100 |
|
101 |
return output
|
102 |
|
103 |
-
# Update the Gradio interface to output
|
104 |
interface = gr.Interface(
|
105 |
fn=get_similar_and_recommend,
|
106 |
inputs=gr.components.Textbox(label="Enter Text to Find Most Similar Video"),
|
107 |
outputs=gr.JSON(),
|
108 |
title="Video Recommendation System with GNN-based Recommendations",
|
109 |
-
description="Enter text to find the most similar video and get
|
110 |
)
|
111 |
|
112 |
interface.launch()
|
|
|
79 |
]
|
80 |
dot_products[given_video_index] = -float("inf")
|
81 |
|
82 |
+
top 10_indices = np.argsort(dot_products)[::-1][:10]
|
83 |
+
return [df.iloc[idx].to_dict() for idx in top 10_indices]
|
84 |
|
85 |
+
top_10_recommended_videos_features = recommend_next_10_videos(most_similar_index, all_video_embeddings)
|
|
|
|
|
86 |
|
87 |
# Exclude unwanted features for recommended videos
|
88 |
for recommended_video in top_10_recommended_videos_features:
|
|
|
90 |
if key in recommended_video:
|
91 |
del recommended_video[key]
|
92 |
|
93 |
+
# Create the output JSON with all features except unwanted ones
|
94 |
output = {
|
95 |
"most_similar_video": most_similar_video_features,
|
96 |
"top_10_recommended_videos": top_10_recommended_videos_features,
|
|
|
98 |
|
99 |
return output
|
100 |
|
101 |
+
# Update the Gradio interface to output JSON without unwanted features
|
102 |
interface = gr.Interface(
|
103 |
fn=get_similar_and_recommend,
|
104 |
inputs=gr.components.Textbox(label="Enter Text to Find Most Similar Video"),
|
105 |
outputs=gr.JSON(),
|
106 |
title="Video Recommendation System with GNN-based Recommendations",
|
107 |
+
description="Enter text to find the most similar video and get top 10 recommended videos with all features except embeddings-related fields in a JSON object.",
|
108 |
)
|
109 |
|
110 |
interface.launch()
|