developmentseed / segment-anything-services

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

refactor to a python module and add tests #32

Closed rbavery closed 9 months ago

rbavery commented 11 months ago

This adds tests with pytest and factors out decode and encode logic to a sam_serve module so that it was easier to test. It also adds a section in the README with a guide for locally testing the decoder with pytest. The module sam_serve is installed in each service Dockerfile from a python wheel file that needs to be generated with hatch build. This can also be uploaded to pypi with hatch publish

The notebook example has also been updated to reflect the new handler structure. payloads to the decoder need to have a "decode_type" specified that can be any one of

"single_point" (implemented)

not implemented "multi_point" "bbox"

the payload should also have an input_prompt key isntead of the previous "input_point" key to reflect that the prompt can be a point, multiple foreground points, multiple foreground and multipkle background points, a bbox, etc.

we might want to change these endpoints to reflect all the variations.

I tested both gpu and cpu services locally. Would appreciate a review if you have time @Rub21 . Then we can merge in your recent work on #25