-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Advice on creating a simple SegmentAnything2 integration #18168
Comments
What if....
I guess this fits the definition of dirty hack :-) EDIT: What if...
|
or a more generic module allowing to hand over the content of the processed image a that state to a customizable app (e.g. python scripts to play around with arbitrary ai applications) and receive a raster mask (maybe also a processed image). Since an increasing numbers of ai models can be used in a local environment this won't restrict use cases. very important to avoid performance issues: that shouldn't be updated automatically on changes in the pixel pipe; just on an explicit command by the user. |
@dterrahe Honestly not a completely terrible idea haha. I can't see a way in the lua docs to script modules though... Will try to get it going over the weekend. @wpferguson @MStraeten Having something like a module that can handle this type of input / output and is nicely scriptable would be ideal. I couldn't really find a way to make a custom darktable plugin that works on this level, would be happy to give it a shot otherwise. How would you approach this? I also posted the same question on the darktable reddit and people generally really like the idea, I think there'd be quite some interest if there is a not too hacky way to integrate this |
The boilerplate code for a module is src/iop/useless.c. Since all we are interested in is a mask, it might not need many changes. Years ago AP created a module to call Krita from darkroom, pass an image, make changes in Krita, and return the changed data. It would be nice if someone had that code lying around. |
Yeah that'd be amazing... How do people generally go about custom modules? Is it easy to have a github repo up where people can use the custom module? I haven't been able to find examples of this so far... |
You can fork darktable repository and then play around. If it’s good enough for a field test, then you can do a pull request |
I love to use darktable for editing my photos but my main annoyance is that I still need to hand-draw masks for portraits and this can get to a lot of masks quickly....
Therefore I thought I'd give it a shot to see if I could use the output of Segment Anything 2 in Darktable to save me from manually making all these masks! A screenshot of the ui that i whipped up:
r/DarkTable - Working on a simple Segment Anything 2 integration for Darktable, looking for input
My current approach is:
Select some points in the image and let Segment Anything do it's magic
Convert the points to the format that the Path mask uses (I'd change the `darktable:mask_points)
Some problems / thoughts that I currently have:
I'm currently facing some issues when writing back the points to the file. Reading and editing points (translate a mask) is currently no problem for my code but when I replace the mask's path points with the output of the masking code I get masks in very weird shapes
It does not really feel right first extract the outline from the mask and use that as a mask. Using the mask defined on the pixels would be a lot nicer, is there any way that I can get a custom image into the intermediate masks in the rendering pipeline?
Some input from darktable devs who know a lot better then me how this all works would be really appreciated! I've also been looking if it would be nice to convert this into a darktable plugin when it's working reliably but I've had a a lot of trouble finding good resources...
I've also read through the LUA API docs but didn't find any functionality there to alter masks. Maybe there is a way to accomplish this that I didn't find in the docs??
Here is the code:
https://github.com/kalmjasper/segmentanything_darktable
The text was updated successfully, but these errors were encountered: