Segment Anything Model for Julia?

Watching Meta’s Segment Anything Model (SAM) exploding online and wondering anyone is working on a port of the Python version to Julia

or if a similar model could be trained using the Julia ecosystem as the training data has been made public (SA-1B Dataset)

SAM seems like a fundamental tool for many AI/image processing tasks that would be a same not to have access to.

1 Like

Not your question, but i got it to run pretty quickly with pycall and im currently writing a few helpers and an interactive tool to segment interactively with makie :wink:
Will soon publish something …

4 Likes

That does seem useful & cool. It would be great to have a Julia port since that would free us of python package management dependency hell. Since the license is Apache, a direct port seems like it might be the most straightforward way to go. I’m in the middle of other things now, but if anyone wants to give this a stab (manually, or using their favorite AI coding assistant to build the first draft) I’d be happy to review a package prototype.

5 Likes

Do you mean the whole training cycle or just recreating the inference process with their weights?

I think the latter. Is there an up to date way of reading pth files in Julia that contain the trained model info? I assume some manual work would be required to build out the right neural network components to mirror the pytorch setup and then initialize it with the right data from the pth checkpoint.

I’ve seen Pickle.jl recommended. It includes special support for pth files.

For anyone that comes looking there is now a julia wrapper for SAM:

Courtesy of @sdanisch and @Raf

4 Likes

Theres a bit more work still until its registered, but it works fine already.

1 Like