derekray311511 / SAM-webui

Apache License 2.0
60 stars 7 forks source link

Save cut out? #3

Closed ANTONIOPSD closed 1 year ago

ANTONIOPSD commented 1 year ago

Is there any way of saving just the masked area of the image so it can be used to remove background from images?

I'm talking about the real part of the image and not the masked colors (saving the image removing non masked areas)

derekray311511 commented 1 year ago

The current version didn’t allow you to save the cut out image, but this is a good idea. I will add this function as soon as possible!

derekray311511 commented 1 year ago

I have added a menu beside the save image button. Feel free to try it!

ANTONIOPSD commented 1 year ago

EDIT: nevermind, images are saved in a subfolder with the name of the image, didn't notice. Silly me

For some reason images do not save, I tested all save options. It was also not saving before the changes.

STEPS: I set the save path: ![imagen](https://user-images.githubusercontent.com/1978099/236230138-f9821a9a-6ef1-4ff0-a971-51d35b4d9698.png) Select the cut out: ![imagen](https://user-images.githubusercontent.com/1978099/236230225-d5b495d0-b7a9-493e-bf5f-745a52ed6c87.png) Click on save: ![imagen](https://user-images.githubusercontent.com/1978099/236230298-0455796d-d016-41d7-bdc2-722f1145814f.png) Bot no images are saved. I'm running it on: Windows 11 Python 3.10 Cuda Enabled Console output: ![imagen](https://user-images.githubusercontent.com/1978099/236231357-83635999-2a1e-4032-b149-4098b4c1c0c1.png) ![imagen](https://user-images.githubusercontent.com/1978099/236231524-ced27b4b-39ea-471c-b05f-c84893dba4c8.png)
ANTONIOPSD commented 1 year ago

Ok I just tested the new save cut out image function but the saved image is not transparent:

imagen

The black part should be transparent

ANTONIOPSD commented 1 year ago

Also it would be nice to have a function to blur the edges of the cutout to make it smooth like antialiasing

derekray311511 commented 1 year ago

Sorry for the late reply. I have let the cutout image to have the alpha channel so that the black part of image would be transparent. You can try it again now! As for the blurring edge function is depend on the application of user, I add a slider to let the user decide the level they want to blur the edge. You can checkout the blurEdge branch to try this function! Thanks.

ANTONIOPSD commented 1 year ago

I tested it, and it appears to be functioning properly. However, the smoothing effect does not seem very smooth. Nevertheless, since the main concern was the cut-out feature, I will mark this issue as resolved.