AnimeGAN2
Transfer real image to Japanese anime style.
BiWAKO.AnimeGAN
Style Transfer GAN trained for Anime.
Attributes:
Name | Type | Description |
---|---|---|
model_path |
str |
Path to ONNX model file. If the file is automatically downloaded, the destination path is saved to this. |
model |
InferenceSession |
ONNX model. |
input_name |
str |
Name of input node. |
output_name |
str |
Name of output node. |
input_size |
int |
Size of input image. Set to 512. |
__init__(self, model='animeGAN512')
special
Initialize AnimeGAN model.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
model |
str |
Either path to the downloaded model or name of the model to trigger automatic download. Defaults to "animeGAN512". |
'animeGAN512' |
predict(self, image)
Return the predicted image from the AnimeGAN model.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
image |
Image |
Image to predict in str or cv2 image format. |
required |
Returns:
Type | Description |
---|---|
np.ndarray |
Predicted image of size 512*512 in cv2 image format |
render(self, prediction, image=None, input_size=None, **kwargs)
Return the predicted image in original size.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
prediction |
np.ndarray |
Predicted image of size 512*512 in cv2 image format. |
required |
image |
Image |
Original image passed to predict(). Defaults to None. |
None |
input_size |
Tuple[int, int] |
Optional tuple of int to resize. Defaults to None. |
None |
Exceptions:
Type | Description |
---|---|
ValueError |
If none of image or input_size is provided. |
Returns:
Type | Description |
---|---|
np.ndarray |
Predicted image in original size. |