Skip to content

Implement model inference

Depends #2

The plan is to print the predicted polygons on an image from Arkindex to stdout.

Step 1: Model embedding

  • Download model weights in models/, store though git-lfs
  • Create a new method on the worker in worker.py, that loads this model and prepare a Predictor (DefaultPredictor from detectron2?)
  • Call this method in the configure method to setup the predictor

Step 2: Image downloading and processing

  • In process_element, call open_image
  • Pass to predictor and retrieve the predictions

Step 3: Post-processing

  • If it's not hard, you can save the predictions as PNG image in os.path.join(self.work_dir,"{element.id}.png"). This way, we could see it on Arkindex.
  • Convert the predictions to a list of dict with the following structure
[
    {
        "type": ...,         # Channel/Class name of the object
        "polygon": ...,      # Anything that can identify the object, bounding box positions, full list of coordinates,...
        "confidence": ...,   # Confidence score
    },
    ...
]
  • Dump this list to stdout