README_en.md 3.0 KB
Newer Older
H
haoyuying 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107
# attgan_celeba

|Module Name|attgan_celeba|
| :--- | :---: |
|Category |image generation|
|Network |AttGAN|
|Dataset|Celeba|
|Fine-tuning supported or not |No|
|Module Size |167MB|
|Latest update date|2021-02-26|
|Data indicators |-|


## I. Basic Information 

- ### Application Effect Display
  - Sample results:

    <p align="center">
    <img src="https://user-images.githubusercontent.com/35907364/137855667-43c5c40c-28f5-45d8-accc-028e185b988f.JPG" width=1200><br/>
    The image attributes are: original image, Bald, Bangs, Black_Hair, Blond_Hair, Brown_Hair, Bushy_Eyebrows, Eyeglasses, Gender, Mouth_Slightly_Open, Mustache, No_Beard, Pale_Skin, Aged<br/>
    </p>


- ### Module Introduction

  - AttGAN is a Generative Adversarial Network, which uses classification loss and reconstruction loss to train the network. The PaddleHub Module is trained one Celeba dataset and currently supports attributes of "Bald", "Bangs", "Black_Hair", "Blond_Hair", "Brown_Hair", "Bushy_Eyebrows", "Eyeglasses", "Gender", "Mouth_Slightly_Open", "Mustache", "No_Beard", "Pale_Skin", "Aged".


## II. Installation

- ### 1、Environmental Dependence

  - paddlepaddle >= 1.5.2 

  - paddlehub >= 1.0.0  | [How to install PaddleHub](../../../../docs/docs_ch/get_start/installation.rst)

- ### 2、Installation

  - ```shell
    $ hub install attgan_celeba==1.0.0
    ```

  - In case of any problems during installation, please refer to:[Windows_Quickstart](../../../../docs/docs_ch/get_start/windows_quickstart.md)
    | [Linux_Quickstart](../../../../docs/docs_ch/get_start/linux_quickstart.md) | [Mac_Quickstart](../../../../docs/docs_ch/get_start/mac_quickstart.md).

 

## III. Module API Prediction

- ### 1、Command line Prediction

  - ```shell
    $ hub run attgan_celeba --image "/PATH/TO/IMAGE" --style "target_attribute" 
    ```

  - **Parameters**

    - image: image path

    - style: Specify the attributes to be converted. The options are "Bald", "Bangs", "Black_Hair", "Blond_Hair", "Brown_Hair", "Bushy_Eyebrows", "Eyeglasses", "Gender", "Mouth_Slightly_Open", "Mustache", "No_Beard", "Pale_Skin", "Aged". You can choose one of the options.


- ### 2、Prediction Code Example

  - ```python
    import paddlehub as hub

    attgan = hub.Module(name="attgan_celeba")

    test_img_path = ["/PATH/TO/IMAGE"]
    trans_attr = ["Bangs"]

    # set input dict
    input_dict = {"image": test_img_path, "style": trans_attr}

    # execute predict and print the result
    results = attgan.generate(data=input_dict)
    print(results)
    ```

- ### 3、API

  - ```python
    def generate(data)
    ```

    - Style transfer API.

    - **Parameter**

      - data(list[dict]): each element in the list is dict and each field is: 
          - image (list\[str\]): Each element in the list is the path of the image to be converted.
          - style (list\[str\]): Each element in the list is a string, fill in the face attributes to be converted.

    - **Return**
      - res (list\[str\]): Save path of the result.



## IV. Release Note

- 1.0.0

  First release