developmentseed / segment-anything-services

Running segment-anything image embedding, prompting, and mask generation as torchserve services
Apache License 2.0
93 stars 10 forks source link

Working image embedding endpoint on local torchserve #1

Closed rbavery closed 1 year ago

rbavery commented 1 year ago

I think the main things to do are

  1. Changing initialize step to load a different onnx model produced from https://github.com/developmentseed/segment-anything-geo/blob/main/notebooks/sam_onnx_model_example_fox.ipynb
  2. maybe change session run, dictionary key might be different: https://github.com/developmentseed/segment-anything-geo/blob/main/mdv5_handler.py#L112
  3. remove postprocessing, cleanup unused modules
  4. Package the handler and onnx model in a .mar file with torch-model-archiver.

I think the preprocessing step with letterbox can go unchanged, it fits the problem of object detection and preserves aspect ratio of the images as much as possible. Though if the ONNX model is dynamic and doesn't need a fixed image size, this can also be removed from the handler.