IOPaint/iopaint/plugins/base_plugin.py

28 lines
668 B
Python
Raw Normal View History

2023-03-26 06:37:58 +02:00
from loguru import logger
2024-01-02 04:07:35 +01:00
import numpy as np
2024-01-05 08:19:23 +01:00
from iopaint.schema import RunPluginRequest
2023-03-26 06:37:58 +02:00
class BasePlugin:
name: str
support_gen_image: bool = False
support_gen_mask: bool = False
2023-03-26 06:37:58 +02:00
def __init__(self):
err_msg = self.check_dep()
if err_msg:
logger.error(err_msg)
exit(-1)
def gen_image(self, rgb_np_img, req: RunPluginRequest) -> np.ndarray:
2024-01-02 04:07:35 +01:00
# return RGBA np image or BGR np image
2023-03-26 06:37:58 +02:00
...
def gen_mask(self, rgb_np_img, req: RunPluginRequest) -> np.ndarray:
# return GRAY or BGR np image, 255 means foreground, 0 means background
...
2023-03-26 06:37:58 +02:00
def check_dep(self):
...