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:
|
2024-01-02 15:32:40 +01:00
|
|
|
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)
|
|
|
|
|
2024-01-02 15:32:40 +01:00
|
|
|
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
|
|
|
...
|
|
|
|
|
2024-01-02 15:32:40 +01: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):
|
|
|
|
...
|
2024-02-08 09:49:54 +01:00
|
|
|
|
|
|
|
def switch_model(self, new_model_name: str):
|
|
|
|
...
|