Context: I am training a Yolov8 model and have successfully registered it in MlFlow.
The model that is used for object detection supports input in the following formats:
- a string form of NumPy array (obtained after opening the image with OpenCV)
cv2.imread('path')
- directly the image path
I am using it in a similar fashion when I load the model from the MLFlow registry and do predictions.
from ultralytics import YOLO
class YOLOWrapper(mlflow.pyfunc.PythonModel):
def load_context(self, context):
from ultralytics import YOLO
self.model = YOLO(context.artifacts["yolo_model"])
def predict(self, context, model_input):
results = self.model(model_input)
return results
def main():
loaded_model = mlflow.pyfunc.load_model(
model_uri=f"models:/{registered_model_name}/latest"
)
results = loaded_model.predict(model_input = 'path to an image')
However, when I want to serve this model after registering it, I am not able to directly pass in the image in similar formats
I need help finding References in which image classification or object detection models are served usin mlflow.
I tried this but it did not work for me, so any other related suggestions would be helpful.