-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: implement blend tab and copy buttons (#62)
- Loading branch information
Showing
15 changed files
with
226 additions
and
37 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
from logging import getLogger | ||
from typing import List, Optional | ||
|
||
from PIL import Image | ||
|
||
from onnx_web.output import save_image | ||
|
||
from ..device_pool import JobContext, ProgressCallback | ||
from ..params import ImageParams, StageParams | ||
from ..utils import ServerContext, is_debug | ||
|
||
logger = getLogger(__name__) | ||
|
||
|
||
def blend_mask( | ||
_job: JobContext, | ||
server: ServerContext, | ||
_stage: StageParams, | ||
_params: ImageParams, | ||
*, | ||
sources: Optional[List[Image.Image]] = None, | ||
mask: Optional[Image.Image] = None, | ||
_callback: ProgressCallback = None, | ||
**kwargs, | ||
) -> Image.Image: | ||
logger.info("blending image using mask") | ||
|
||
l_mask = Image.new("RGBA", mask.size, color="black") | ||
l_mask.alpha_composite(mask) | ||
l_mask = l_mask.convert("L") | ||
|
||
if is_debug(): | ||
save_image(server, "last-mask.png", mask) | ||
save_image(server, "last-mask-l.png", l_mask) | ||
|
||
return Image.composite(sources[0], sources[1], l_mask) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.