Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -8,6 +8,9 @@ from torch_geometric.nn import GATConv
|
|
| 8 |
from sentence_transformers import SentenceTransformer
|
| 9 |
from sklearn.metrics.pairwise import cosine_similarity
|
| 10 |
|
|
|
|
|
|
|
|
|
|
| 11 |
class ModeratelySimplifiedGATConvModel(torch.nn.Module):
|
| 12 |
def __init__(self, in_channels, hidden_channels, out_channels):
|
| 13 |
super().__init__()
|
|
@@ -126,13 +129,14 @@ if user_input:
|
|
| 126 |
|
| 127 |
|
| 128 |
|
| 129 |
-
@
|
| 130 |
def recommend():
|
| 131 |
input_text = request.json['input_text']
|
| 132 |
|
| 133 |
recommendations = get_similar_and_recommend(input_text)
|
| 134 |
return jsonify(recommendations)
|
| 135 |
|
|
|
|
| 136 |
# Create a simple Streamlit interface with instructions
|
| 137 |
st.title("Video Recommendation API")
|
| 138 |
st.write("Use POST requests to `/recommend` with JSON data {'input_text': '<your text>'}")
|
|
|
|
| 8 |
from sentence_transformers import SentenceTransformer
|
| 9 |
from sklearn.metrics.pairwise import cosine_similarity
|
| 10 |
|
| 11 |
+
flask_app = Flask(__name__)
|
| 12 |
+
|
| 13 |
+
|
| 14 |
class ModeratelySimplifiedGATConvModel(torch.nn.Module):
|
| 15 |
def __init__(self, in_channels, hidden_channels, out_channels):
|
| 16 |
super().__init__()
|
|
|
|
| 129 |
|
| 130 |
|
| 131 |
|
| 132 |
+
@flask_app.route('/recommend', methods=['POST'])
|
| 133 |
def recommend():
|
| 134 |
input_text = request.json['input_text']
|
| 135 |
|
| 136 |
recommendations = get_similar_and_recommend(input_text)
|
| 137 |
return jsonify(recommendations)
|
| 138 |
|
| 139 |
+
|
| 140 |
# Create a simple Streamlit interface with instructions
|
| 141 |
st.title("Video Recommendation API")
|
| 142 |
st.write("Use POST requests to `/recommend` with JSON data {'input_text': '<your text>'}")
|