I am trying to deploy a simple model on GCP whit a docker image (i want to deploy the model on a customize container because it will change later)
This is my hello world model :
from fastapi import FastAPI
import joblib
import os
app = FastAPI()
# Chargement du modèle
model = joblib.load('model.joblib')
AIP_HEALTH_ROUTE = os.environ.get('AIP_HEALTH_ROUTE', '/health')
@app.post("/predict")
def predict(input: list):
prediction = model.predict([input])
return {"prediction": prediction.tolist()}
@app.get(AIP_HEALTH_ROUTE, status_code=200)
async def health():
return {'health': 'ok'}
# Utiliser une image de base Python
FROM python:3.8-slim
# Définir le répertoire de travail
WORKDIR /app
# Copier les fichiers nécessaires dans le conteneur
COPY model.joblib model.joblib
COPY main.py main.py
# Installer les dépendances
RUN pip install fastapi uvicorn scikit-learn joblib python-multipart
# Exposer le port pour FastAPI
EXPOSE 80
# Commande pour exécuter l'application
CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "80"]
import numpy as np
from sklearn.linear_model import LinearRegression
import joblib
# Création de données d'exemple
X = np.array([[1, 1], [1, 2], [2, 2], [2, 3]])
y = np.dot(X, np.array([1, 2])) + 3
# Entrainement du modèle
model = LinearRegression().fit(X, y)
# Sauvegarde du modèle
joblib.dump(model, 'model.joblib')
i put the docker image on my artifact registry but when i deployed it on a endpoint in vertex ai, it is not working and i don't have any logs
Could you help me plz
User | Count |
---|---|
2 | |
1 | |
1 | |
1 | |
1 |