Skip to content

Files

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 

English | 简体中文

AnimeGAN Python Deployment Example

Two steps before deployment

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

AnimeGAN Python Interface

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

predict function

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

batch_predict function

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

Other Documents