Module Name | UGATIT_83w |
---|---|
Category | Image editing |
Network | U-GAT-IT |
Dataset | selfie2anime |
Fine-tuning supported or not | No |
Module Size | 41MB |
Latest update date | 2021-02-26 |
Data indicators | - |
-
-
paddlepaddle >= 1.8.2
-
paddlehub >= 1.8.0
-
-
-
$ hub install UGATIT_83w
-
In case of any problems during installation, please refer to:Windows_Quickstart | Linux_Quickstart | Mac_Quickstart
-
-
-
import cv2 import paddlehub as hub model = hub.Module(name='UGATIT_83w', use_gpu=False) result = model.style_transfer(images=[cv2.imread('/PATH/TO/IMAGE')]) # or # result = model.style_transfer(paths=['/PATH/TO/IMAGE'])
-
-
-
def style_transfer( self, images=None, paths=None, batch_size=1, output_dir='output', visualization=False )
-
Style transfer API, convert the input face image into anime style.
-
Parameters
- images (list[numpy.ndarray]): Image data, ndarray.shape is in the format [H, W, C], BGR.
- paths (list[str]): image path,default is None;
- batch_size (int): Batch size, default is 1;
- visualization (bool): Whether to save the recognition results as picture files, default is False.
- output_dir (str): Save path of images,
output
by default.
NOTE: Choose one of
paths
andimages
to provide data. -
Return
- res (list[numpy.ndarray]): Result, ndarray.shape is in the format [H, W, C].
-
-
-
PaddleHub Serving can deploy an online service of Style transfer task.
-
-
Run the startup command:
-
$ hub serving start -m UGATIT_83w
-
-
The servitization API is now deployed and the default port number is 8866.
-
NOTE: If GPU is used for prediction, set CUDA_VISIBLE_DEVICES environment variable before the service, otherwise it need not be set.
-
-
-
With a configured server, use the following lines of code to send the prediction request and obtain the result
-
import requests import json import cv2 import base64 def cv2_to_base64(image): data = cv2.imencode('.jpg', image)[1] return base64.b64encode(data.tostring()).decode('utf8') # Send an HTTP request data = {'images':[cv2_to_base64(cv2.imread("/PATH/TO/IMAGE"))]} headers = {"Content-type": "application/json"} url = "http://127.0.0.1:8866/predict/UGATIT_83w" r = requests.post(url=url, headers=headers, data=json.dumps(data)) # print prediction results print(r.json()["results"])
-
-
-
1.0.0
First release