English | 简体中文
Two steps before deployment
-
- Software and hardware should meet the requirements. Please refer to FastDeploy Environment Requirements
-
- Install FastDeploy Python whl package. Refer to FastDeploy Python Installation
This directory provides examples that infer.py
fast finishes the deployment of AnimeGAN on CPU/GPU and GPU accelerated by TensorRT. The script is as follows
# Download the example code for deployment
git clone https://github.com/PaddlePaddle/FastDeploy.git
cd FastDeploy/examples/vision/generation/anemigan/python
# Download prepared test images
wget https://bj.bcebos.com/paddlehub/fastdeploy/style_transfer_testimg.jpg
# CPU inference
python infer.py --model animegan_v1_hayao_60 --image style_transfer_testimg.jpg --device cpu
# GPU inference
python infer.py --model animegan_v1_hayao_60 --image style_transfer_testimg.jpg --device gpu
fd.vision.generation.AnimeGAN(model_file, params_file, runtime_option=None, model_format=ModelFormat.PADDLE)
AnimeGAN model loading and initialization, among which model_file and params_file are the model file and parameter file for Paddle inference.
Parameter
- model_file(str): Model file path
- params_file(str): Parameter file path
- runtime_option(RuntimeOption): Backend inference configuration. None by default, which is the default configuration
- model_format(ModelFormat): Model format. PADDLE format by default
AnimeGAN.predict(input_image)Model prediction interface. Input images and output style transfer results.
Parameter
- input_image(np.ndarray): Input data in HWC or BGR format
Return np.ndarray, the image after style transfer in BGR format
AnimeGAN.batch_predict function (input_images)Model prediction interface. Input a set of images and output style transfer results
Parameter
- input_images(list(np.ndarray)): Input data in HWC or BGR format
Return list(np.ndarray), a set of images after style transfer in BGR format