test
Browse files- Dockerfile +7 -10
- recommend_normal.py +1 -1
- recommendwithdesc.py +2 -1
Dockerfile
CHANGED
@@ -1,17 +1,14 @@
|
|
1 |
# Use the official Python 3.10.9 image
|
2 |
FROM python:3.10.9
|
3 |
|
4 |
-
#
|
5 |
-
WORKDIR /app
|
6 |
-
|
7 |
-
# Copy everything into container
|
8 |
COPY . .
|
9 |
|
10 |
-
#
|
11 |
-
|
12 |
|
13 |
-
#
|
14 |
-
|
15 |
|
16 |
-
# Start the
|
17 |
-
CMD ["
|
|
|
1 |
# Use the official Python 3.10.9 image
|
2 |
FROM python:3.10.9
|
3 |
|
4 |
+
# Copy the current directory contents into the container at .
|
|
|
|
|
|
|
5 |
COPY . .
|
6 |
|
7 |
+
# Set the working directory to /
|
8 |
+
WORKDIR /
|
9 |
|
10 |
+
# Install requirements.txt
|
11 |
+
RUN pip install --no-cache-dir --upgrade -r /requirements.txt
|
12 |
|
13 |
+
# Start the FastAPI app on port 7860, the default port expected by Spaces
|
14 |
+
CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]
|
recommend_normal.py
CHANGED
@@ -28,7 +28,7 @@ def load_data():
|
|
28 |
|
29 |
# Load movie data
|
30 |
movies_data = load_data()
|
31 |
-
vectorizer_path = hf_hub_download(repo_id=repo_id, filename="
|
32 |
similarity_path = hf_hub_download(repo_id=repo_id, filename="model_similarity.pkl", cache_dir=cache_dir)
|
33 |
def recommend_movies(movie_name):
|
34 |
# Add the movie to the user's history
|
|
|
28 |
|
29 |
# Load movie data
|
30 |
movies_data = load_data()
|
31 |
+
vectorizer_path = hf_hub_download(repo_id=repo_id, filename="model_vectorizer.pkl", cache_dir=cache_dir)
|
32 |
similarity_path = hf_hub_download(repo_id=repo_id, filename="model_similarity.pkl", cache_dir=cache_dir)
|
33 |
def recommend_movies(movie_name):
|
34 |
# Add the movie to the user's history
|
recommendwithdesc.py
CHANGED
@@ -29,13 +29,14 @@ def load_data():
|
|
29 |
movies_data = load_data()
|
30 |
model_vectorizer = hf_hub_download(repo_id=repo_id, filename="model_vectorizer.pkl", cache_dir=cache_dir)
|
31 |
similarity_path = hf_hub_download(repo_id=repo_id, filename="model_similarity.pkl", cache_dir=cache_dir)
|
|
|
32 |
with open(model_vectorizer, 'rb') as vec_file, open(similarity_path, 'rb') as sim_file:
|
33 |
vectorizer = pickle.load(vec_file)
|
34 |
similarity = pickle.load(sim_file)
|
35 |
def recommend_movies_with_desc(query):
|
36 |
# Transform the query into a feature vector using the same vectorizer
|
37 |
feature_vecto = vectorizer.transform(query)
|
38 |
-
with open(
|
39 |
feature_vectors = pickle.load(feature)
|
40 |
|
41 |
# Calculate cosine similarity between the query vector and the feature vectors of the movies
|
|
|
29 |
movies_data = load_data()
|
30 |
model_vectorizer = hf_hub_download(repo_id=repo_id, filename="model_vectorizer.pkl", cache_dir=cache_dir)
|
31 |
similarity_path = hf_hub_download(repo_id=repo_id, filename="model_similarity.pkl", cache_dir=cache_dir)
|
32 |
+
feature_vector = hf_hub_download(repo_id=repo_id, filename="feature_vector.pkl", cache_dir=cache_dir)
|
33 |
with open(model_vectorizer, 'rb') as vec_file, open(similarity_path, 'rb') as sim_file:
|
34 |
vectorizer = pickle.load(vec_file)
|
35 |
similarity = pickle.load(sim_file)
|
36 |
def recommend_movies_with_desc(query):
|
37 |
# Transform the query into a feature vector using the same vectorizer
|
38 |
feature_vecto = vectorizer.transform(query)
|
39 |
+
with open(feature_vector, 'rb') as feature:
|
40 |
feature_vectors = pickle.load(feature)
|
41 |
|
42 |
# Calculate cosine similarity between the query vector and the feature vectors of the movies
|