import joblib import json import os # Azure ML will call init() once when the container is started def init(): global model model_path = os.path.join(os.getenv("AZUREML_MODEL_DIR", "."), "model.joblib") model = joblib.load(model_path) # Azure ML will call run() for every request def run(raw_data): try: input_data = json.loads(raw_data) predictions = model.predict(input_data["data"]) return predictions.tolist() except Exception as e: return {"error": str(e)}