未验证 提交 27b1e6d9 编写于 作者: K KP 提交者: GitHub

Merge pull request #1710 from rainyfly/add_English_Readme

Add english readme
......@@ -25,8 +25,6 @@
- ### 1、环境依赖
- paddlepaddle >= 1.8.2
- paddlehub >= 1.8.0 | [如何安装paddlehub](../../../../docs/docs_ch/get_start/installation.rst)
- ### 2、安装
......@@ -38,7 +36,7 @@
| [零基础Linux安装](../../../../docs/docs_ch/get_start/linux_quickstart.md) | [零基础MacOS安装](../../../../docs/docs_ch/get_start/mac_quickstart.md)
## 三、模型API预测
- ### 1、代码示例
- ### 1、预测代码示例
- ```python
import paddlehub as hub
......
# stgan_bald
|Module Name|stgan_bald|
| :--- | :---: |
|Category|image generation|
|Network|STGAN|
|Dataset|CelebA|
|Fine-tuning supported or not|No|
|Module Size|287MB|
|Latest update date|2021-02-26|
|Data indicators|-|
## I.Basic Information
- ### Application Effect Display
- Please refer to this [link](https://aistudio.baidu.com/aistudio/projectdetail/1145381)
- ### Module Introduction
- This module is based on STGAN model, trained on CelebA dataset, and can be used to predict bald appearance after 1, 3 and 5 years.
## II.Installation
- ### 1、Environmental Dependence
- paddlehub >= 1.8.0 | [How to install PaddleHub](../../../../docs/docs_en/get_start/installation.rst)
- ### 2、Installation
- ```shell
$ hub install stgan_bald
```
- In case of any problems during installation, please refer to: [Windows_Quickstart](../../../../docs/docs_en/get_start/windows_quickstart.md) | [Linux_Quickstart](../../../../docs/docs_en/get_start/linux_quickstart.md) | [Mac_Quickstart](../../../../docs/docs_en/get_start/mac_quickstart.md)
## III.Module API Prediction
- ### 1、Prediction Code Example
- ```python
import paddlehub as hub
import cv2
stgan_bald = hub.Module(name="stgan_bald")
result = stgan_bald.bald(images=[cv2.imread('/PATH/TO/IMAGE')])
# or
# result = stgan_bald.bald(paths=['/PATH/TO/IMAGE'])
```
- ### 2、API
- ```python
def bald(images=None,
paths=None,
use_gpu=False,
visualization=False,
output_dir="bald_output")
```
- Bald appearance generation API.
- **Parameters**
- images (list\[numpy.ndarray\]): image data, ndarray.shape is in the format [H, W, C], BGR;
- paths (list[str]): image path;
- use_gpu (bool): use GPU or not; **set the CUDA_VISIBLE_DEVICES environment variable first if you are using GPU**
- visualization (bool): Whether to save the results as picture files;
- output_dir (str): save path of images;
**NOTE:** choose one parameter to provide data from paths and images
- **Return**
- res (list\[numpy.ndarray\]): result list,ndarray.shape is \[H, W, C\]
## IV.Server Deployment
- PaddleHub Serving can deploy an online service of bald appearance generation.
- ### Step 1: Start PaddleHub Serving
- Run the startup command:
- ```shell
$ hub serving start -m stgan_bald
```
- 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.
- ### Step 2: Send a predictive request
- With a configured server, use the following lines of code to send the prediction request and obtain the result
- ```python
import requests
import json
import cv2
import base64
import numpy as np
def cv2_to_base64(image):
data = cv2.imencode('.jpg', image)[1]
return base64.b64encode(data.tostring()).decode('utf8')
def base64_to_cv2(b64str):
data = base64.b64decode(b64str.encode('utf8'))
data = np.fromstring(data, np.uint8)
data = cv2.imdecode(data, cv2.IMREAD_COLOR)
return data
# 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/stgan_bald"
r = requests.post(url=url, headers=headers, data=json.dumps(data))
# save results
one_year =cv2.cvtColor(base64_to_cv2(r.json()["results"]['data_0']), cv2.COLOR_RGB2BGR)
three_year =cv2.cvtColor(base64_to_cv2(r.json()["results"]['data_1']), cv2.COLOR_RGB2BGR)
five_year =cv2.cvtColor(base64_to_cv2(r.json()["results"]['data_2']), cv2.COLOR_RGB2BGR)
cv2.imwrite("stgan_bald_server.png", one_year)
```
## V.Release Note
* 1.0.0
First release
- ```shell
$ hub install stgan_bald==1.0.0
```
# Photo2Cartoon
|模型名称|Photo2Cartoon|
| :--- | :---: |
|类别|图像 - 图像生成|
|网络|U-GAT-IT|
|数据集|cartoon_data|
|是否支持Fine-tuning|否|
|模型大小|205MB|
|最新更新日期|2021-02-26|
|数据指标|-|
## 一、模型基本信息
- ### 应用效果展示
- 样例结果示例:
<p align="center">
<img src="https://img-blog.csdnimg.cn/20201224164040624.jpg" hspace='10'/> <br />
</p>
- ### 模型介绍
- 本模型封装自[小视科技photo2cartoon项目的paddlepaddle版本](https://github.com/minivision-ai/photo2cartoon-paddle)
## 二、安装
- ### 1、环境依赖
- paddlepaddle >= 2.0.0
- paddlehub >= 2.0.0 | [如何安装paddlehub](../../../../docs/docs_ch/get_start/installation.rst)
- ### 2、安装
- ```shell
$ hub install Photo2Cartoon
```
- 如您安装时遇到问题,可参考:[零基础windows安装](../../../../docs/docs_ch/get_start/windows_quickstart.md)
| [零基础Linux安装](../../../../docs/docs_ch/get_start/linux_quickstart.md) | [零基础MacOS安装](../../../../docs/docs_ch/get_start/mac_quickstart.md)
## 三、模型API预测
- ### 1、代码示例
- ```python
import paddlehub as hub
import cv2
model = hub.Module(name="Photo2Cartoon")
result = model.Cartoon_GEN(images=[cv2.imread('/PATH/TO/IMAGE')])
# or
# result = model.Cartoon_GEN(paths=['/PATH/TO/IMAGE'])
```
- ### 2、API
- ```python
def Cartoon_GEN(images=None,
paths=None,
batch_size=1,
output_dir='output',
visualization=False,
use_gpu=False):
```
- 人像卡通化图像生成API。
- **参数**
- images (list\[numpy.ndarray\]): 图片数据,ndarray.shape 为 \[H, W, C\]<br/>
- paths (list\[str\]): 输入图像路径;<br/>
- output\_dir (str): 图片的保存路径,默认设为 output;<br/>
- batch_size (int) : batch大小;<br/>
- visualization (bool) : 是否将结果保存为图片文件;;<br/>
- use_gpu (bool) : 是否使用 GPU 进行推理。
**NOTE:** paths和images两个参数选择其一进行提供数据
- **返回**
- res (list\[numpy.ndarray\]): 输出图像数据,ndarray.shape 为 \[H, W, C\]
## 四、更新历史
* 1.0.0
初始发布
- ```shell
$ hub install Photo2Cartoon==1.0.0
# Photo2Cartoon
|模型名称|Photo2Cartoon|
| :--- | :---: |
|类别|图像 - 图像生成|
|网络|U-GAT-IT|
|数据集|cartoon_data|
|是否支持Fine-tuning|否|
|模型大小|205MB|
|最新更新日期|2021-02-26|
|数据指标|-|
## 一、模型基本信息
- ### 应用效果展示
- 样例结果示例:
<p align="center">
<img src="https://img-blog.csdnimg.cn/20201224164040624.jpg" hspace='10'/> <br />
</p>
- ### 模型介绍
- 本模型封装自[小视科技photo2cartoon项目的paddlepaddle版本](https://github.com/minivision-ai/photo2cartoon-paddle)
## 二、安装
- ### 1、环境依赖
- paddlepaddle >= 2.0.0
- paddlehub >= 2.0.0 | [如何安装paddlehub](../../../../docs/docs_ch/get_start/installation.rst)
- ### 2、安装
- ```shell
$ hub install Photo2Cartoon
```
- 如您安装时遇到问题,可参考:[零基础windows安装](../../../../docs/docs_ch/get_start/windows_quickstart.md)
| [零基础Linux安装](../../../../docs/docs_ch/get_start/linux_quickstart.md) | [零基础MacOS安装](../../../../docs/docs_ch/get_start/mac_quickstart.md)
## 三、模型API预测
- ### 1、预测代码示例
- ```python
import paddlehub as hub
import cv2
model = hub.Module(name="Photo2Cartoon")
result = model.Cartoon_GEN(images=[cv2.imread('/PATH/TO/IMAGE')])
# or
# result = model.Cartoon_GEN(paths=['/PATH/TO/IMAGE'])
```
- ### 2、API
- ```python
def Cartoon_GEN(images=None,
paths=None,
batch_size=1,
output_dir='output',
visualization=False,
use_gpu=False):
```
- 人像卡通化图像生成API。
- **参数**
- images (list\[numpy.ndarray\]): 图片数据,ndarray.shape 为 \[H, W, C\];<br/>
- paths (list\[str\]): 输入图像路径;<br/>
- output\_dir (str): 图片的保存路径,默认设为 output;<br/>
- batch_size (int) : batch大小;<br/>
- visualization (bool) : 是否将结果保存为图片文件;;<br/>
- use_gpu (bool) : 是否使用 GPU 进行推理。
**NOTE:** paths和images两个参数选择其一进行提供数据
- **返回**
- res (list\[numpy.ndarray\]): 输出图像数据,ndarray.shape 为 \[H, W, C\]
## 四、更新历史
* 1.0.0
初始发布
- ```shell
$ hub install Photo2Cartoon==1.0.0
```
# Photo2Cartoon
|Module Name|Photo2Cartoon|
| :--- | :---: |
|Category|image generation|
|Network|U-GAT-IT|
|Dataset|cartoon_data|
|Fine-tuning supported or not|No|
|Module Size|205MB|
|Latest update date|2021-02-26|
|Data indicators|-|
## I.Basic Information
- ### Application Effect Display
- Sample results:
<p align="center">
<img src="https://img-blog.csdnimg.cn/20201224164040624.jpg" hspace='10'/> <br />
</p>
- ### Module Introduction
- This module encapsulates project [photo2cartoon](https://github.com/minivision-ai/photo2cartoon-paddle).
## II.Installation
- ### 1、Environmental Dependence
- paddlepaddle >= 2.0.0
- paddlehub >= 2.0.0 | [How to install PaddleHub](../../../../docs/docs_en/get_start/installation.rst)
- ### 2、Installation
- ```shell
$ hub install Photo2Cartoon
```
- In case of any problems during installation, please refer to: [Windows_Quickstart](../../../../docs/docs_en/get_start/windows_quickstart.md) | [Linux_Quickstart](../../../../docs/docs_en/get_start/linux_quickstart.md) | [Mac_Quickstart](../../../../docs/docs_en/get_start/mac_quickstart.md)
## III.Module API Prediction
- ### 1、Prediction Code Example
- ```python
import paddlehub as hub
import cv2
model = hub.Module(name="Photo2Cartoon")
result = model.Cartoon_GEN(images=[cv2.imread('/PATH/TO/IMAGE')])
# or
# result = model.Cartoon_GEN(paths=['/PATH/TO/IMAGE'])
```
- ### 2、API
- ```python
def Cartoon_GEN(images=None,
paths=None,
batch_size=1,
output_dir='output',
visualization=False,
use_gpu=False):
```
- Cartoon style generation API.
- **Parameters**
- images (list\[numpy.ndarray\]): image data, ndarray.shape is in the format [H, W, C], BGR;
- paths (list[str]): image path;
- output_dir (str): save path of images;
- batch_size (int): the size of batch;
- visualization (bool): Whether to save the results as picture files;
- use_gpu (bool): use GPU or not; **set the CUDA_VISIBLE_DEVICES environment variable first if you are using GPU**
**NOTE:** choose one parameter to provide data from paths and images
- **Return**
- res (list\[numpy.ndarray\]): result list,ndarray.shape is \[H, W, C\]
## IV.Release Note
* 1.0.0
First release
- ```shell
$ hub install Photo2Cartoon==1.0.0
```
# U2Net_Portrait
|模型名称|U2Net_Portrait|
| :--- | :---: |
|类别|图像 - 图像生成|
|网络|U^2Net|
|数据集|-|
|是否支持Fine-tuning|否|
|模型大小|254MB|
|最新更新日期|2021-02-26|
|数据指标|-|
## 一、模型基本信息
- ### 应用效果展示
- 样例结果示例:
<p align="center">
<img src="https://ai-studio-static-online.cdn.bcebos.com/07f73466f3294373965e06c141c4781992f447104a94471dadfabc1c3d920861" height='50%' hspace='10'/>
<br />
输入图像
<br />
<img src="https://ai-studio-static-online.cdn.bcebos.com/c6ab02cf27414a5ba5921d9e6b079b487f6cda6026dc4d6dbca8f0167ad7cae3" height='50%' hspace='10'/>
<br />
输出图像
<br />
</p>
- ### 模型介绍
- U2Net_Portrait 可以用于提取人脸的素描结果。
## 二、安装
- ### 1、环境依赖
- paddlepaddle >= 2.0.0
- paddlehub >= 2.0.0 | [如何安装paddlehub](../../../../docs/docs_ch/get_start/installation.rst)
- ### 2、安装
- ```shell
$ hub install U2Net_Portrait
```
- 如您安装时遇到问题,可参考:[零基础windows安装](../../../../docs/docs_ch/get_start/windows_quickstart.md)
| [零基础Linux安装](../../../../docs/docs_ch/get_start/linux_quickstart.md) | [零基础MacOS安装](../../../../docs/docs_ch/get_start/mac_quickstart.md)
## 三、模型API预测
- ### 1、预测代码示例
- ```python
import paddlehub as hub
import cv2
model = hub.Module(name="U2Net_Portrait")
result = model.Portrait_GEN(images=[cv2.imread('/PATH/TO/IMAGE')])
# or
# result = model.Portrait_GEN(paths=['/PATH/TO/IMAGE'])
```
- ### 2、API
- ```python
def Portrait_GEN(images=None,
paths=None,
scale=1,
batch_size=1,
output_dir='output',
face_detection=True,
visualization=False):
```
- 人脸画像生成API。
- **参数**
- images (list\[numpy.ndarray\]): 图片数据,ndarray.shape 为 \[H, W, C\]<br/>
- paths (list\[str\]): 输入图像路径;<br/>
- scale (float) : 缩放因子(与face_detection相关联);<br/>
- batch_size (int) : batch大小;<br/>
- output\_dir (str): 图片的保存路径,默认设为 output;<br/>
- visualization (bool) : 是否将结果保存为图片文件;;<br/>
**NOTE:** paths和images两个参数选择其一进行提供数据
- **返回**
- res (list\[numpy.ndarray\]): 输出图像数据,ndarray.shape 为 \[H, W, C\]
## 四、更新历史
* 1.0.0
初始发布
- ```shell
$ hub install U2Net_Portrait==1.0.0
```
# U2Net_Portrait
|模型名称|U2Net_Portrait|
| :--- | :---: |
|类别|图像 - 图像生成|
|网络|U^2Net|
|数据集|-|
|是否支持Fine-tuning|否|
|模型大小|254MB|
|最新更新日期|2021-02-26|
|数据指标|-|
## 一、模型基本信息
- ### 应用效果展示
- 样例结果示例:
<p align="center">
<img src="https://ai-studio-static-online.cdn.bcebos.com/07f73466f3294373965e06c141c4781992f447104a94471dadfabc1c3d920861" height='50%' hspace='10'/>
<br />
输入图像
<br />
<img src="https://ai-studio-static-online.cdn.bcebos.com/c6ab02cf27414a5ba5921d9e6b079b487f6cda6026dc4d6dbca8f0167ad7cae3" height='50%' hspace='10'/>
<br />
输出图像
<br />
</p>
- ### 模型介绍
- U2Net_Portrait 可以用于提取人脸的素描结果。
## 二、安装
- ### 1、环境依赖
- paddlepaddle >= 2.0.0
- paddlehub >= 2.0.0 | [如何安装paddlehub](../../../../docs/docs_ch/get_start/installation.rst)
- ### 2、安装
- ```shell
$ hub install U2Net_Portrait
```
- 如您安装时遇到问题,可参考:[零基础windows安装](../../../../docs/docs_ch/get_start/windows_quickstart.md)
| [零基础Linux安装](../../../../docs/docs_ch/get_start/linux_quickstart.md) | [零基础MacOS安装](../../../../docs/docs_ch/get_start/mac_quickstart.md)
## 三、模型API预测
- ### 1、预测代码示例
- ```python
import paddlehub as hub
import cv2
model = hub.Module(name="U2Net_Portrait")
result = model.Portrait_GEN(images=[cv2.imread('/PATH/TO/IMAGE')])
# or
# result = model.Portrait_GEN(paths=['/PATH/TO/IMAGE'])
```
- ### 2、API
- ```python
def Portrait_GEN(images=None,
paths=None,
scale=1,
batch_size=1,
output_dir='output',
face_detection=True,
visualization=False):
```
- 人脸画像生成API。
- **参数**
- images (list\[numpy.ndarray\]): 图片数据,ndarray.shape 为 \[H, W, C\];<br/>
- paths (list\[str\]): 输入图像路径;<br/>
- scale (float) : 缩放因子(与face_detection相关联);<br/>
- batch_size (int) : batch大小;<br/>
- output\_dir (str): 图片的保存路径,默认设为 output;<br/>
- visualization (bool) : 是否将结果保存为图片文件;;<br/>
**NOTE:** paths和images两个参数选择其一进行提供数据
- **返回**
- res (list\[numpy.ndarray\]): 输出图像数据,ndarray.shape 为 \[H, W, C\]
## 四、更新历史
* 1.0.0
初始发布
- ```shell
$ hub install U2Net_Portrait==1.0.0
```
# U2Net_Portrait
|Module Name|U2Net_Portrait|
| :--- | :---: |
|Category|image generation|
|Network|U^2Net|
|Dataset|-|
|Fine-tuning supported or not|No|
|Module Size|254MB|
|Latest update date|2021-02-26|
|Data indicators|-|
## I.Basic Information
- ### Application Effect Display
- Sample results:
<p align="center">
<img src="https://ai-studio-static-online.cdn.bcebos.com/07f73466f3294373965e06c141c4781992f447104a94471dadfabc1c3d920861" height='50%' hspace='10'/>
<br />
Input image
<br />
<img src="https://ai-studio-static-online.cdn.bcebos.com/c6ab02cf27414a5ba5921d9e6b079b487f6cda6026dc4d6dbca8f0167ad7cae3" height='50%' hspace='10'/>
<br />
Output image
<br />
</p>
- ### Module Introduction
- U2Net_Portrait can be used to create a face portrait.
## II.Installation
- ### 1、Environmental Dependence
- paddlepaddle >= 2.0.0
- paddlehub >= 2.0.0 | [How to install PaddleHub](../../../../docs/docs_en/get_start/installation.rst)
- ### 2、Installation
- ```shell
$ hub install U2Net_Portrait
```
- In case of any problems during installation, please refer to: [Windows_Quickstart](../../../../docs/docs_en/get_start/windows_quickstart.md) | [Linux_Quickstart](../../../../docs/docs_en/get_start/linux_quickstart.md) | [Mac_Quickstart](../../../../docs/docs_en/get_start/mac_quickstart.md)
## III.Module API Prediction
- ### 1、Prediction Code Example
- ```python
import paddlehub as hub
import cv2
model = hub.Module(name="U2Net_Portrait")
result = model.Portrait_GEN(images=[cv2.imread('/PATH/TO/IMAGE')])
# or
# result = model.Portrait_GEN(paths=['/PATH/TO/IMAGE'])
```
- ### 2、API
- ```python
def Portrait_GEN(images=None,
paths=None,
scale=1,
batch_size=1,
output_dir='output',
face_detection=True,
visualization=False):
```
- Portrait generation API.
- **Parameters**
- images (list\[numpy.ndarray\]): image data, ndarray.shape is in the format [H, W, C], BGR;
- paths (list[str]): image path;
- scale (float) : scale for resizing image;<br/>
- batch_size (int): the size of batch;
- output_dir (str): save path of images;
- visualization (bool): Whether to save the results as picture files;
**NOTE:** choose one parameter to provide data from paths and images
- **Return**
- res (list\[numpy.ndarray\]): result list,ndarray.shape is \[H, W, C\]
## IV.Release Note
* 1.0.0
First release
- ```shell
$ hub install U2Net_Portrait==1.0.0
```
......@@ -50,7 +50,7 @@
## 三、模型API预测
- ### 1、代码示例
- ### 1、预测代码示例
- ```python
import paddlehub as hub
......
# UGATIT_100w
|Module Name|UGATIT_100w|
| :--- | :---: |
|Category|image generation|
|Network|U-GAT-IT|
|Dataset|selfie2anime|
|Fine-tuning supported or not|No|
|Module Size|41MB|
|Latest update date|2021-02-26|
|Data indicators|-|
## I.Basic Information
- ### Application Effect Display
- Sample results:
<p align="center">
<img src="https://ai-studio-static-online.cdn.bcebos.com/d130fabd8bd34e53b2f942b3766eb6bbd3c19c0676d04abfbd5cc4b83b66f8b6" height='80%' hspace='10'/>
<br />
Input image
<br />
<img src="https://ai-studio-static-online.cdn.bcebos.com/8538af03b3f14b1884fcf4eec48965baf939e35a783d40129085102057438c77" height='80%' hspace='10'/>
<br />
Output image
<br />
</p>
- ### Module Introduction
- UGATIT is a model for style transfer. This module can be used to transfer a face image to cartoon style. For more information, please refer to [UGATIT-Paddle Project](https://github.com/miraiwk/UGATIT-paddle).
## II.Installation
- ### 1、Environmental Dependence
- paddlepaddle >= 1.8.0
- paddlehub >= 1.8.0 | [How to install PaddleHub](../../../../docs/docs_en/get_start/installation.rst)
- ### 2、Installation
- ```shell
$ hub install UGATIT_100w
```
- In case of any problems during installation, please refer to: [Windows_Quickstart](../../../../docs/docs_en/get_start/windows_quickstart.md) | [Linux_Quickstart](../../../../docs/docs_en/get_start/linux_quickstart.md) | [Mac_Quickstart](../../../../docs/docs_en/get_start/mac_quickstart.md)
## III.Module API Prediction
- ### 1、Prediction Code Example
- ```python
import paddlehub as hub
import cv2
model = hub.Module(name="UGATIT_100w")
result = model.style_transfer(images=[cv2.imread('/PATH/TO/IMAGE')])
# or
# result = model.style_transfer(paths=['/PATH/TO/IMAGE'])
```
- ### 2、API
- ```python
def style_transfer(images=None,
paths=None,
batch_size=1,
output_dir='output',
visualization=False)
```
- Style transfer API.
- **Parameters**
- images (list\[numpy.ndarray\]): image data, ndarray.shape is in the format [H, W, C], BGR;
- paths (list[str]): image path;
- batch_size (int): the size of batch;
- visualization (bool): Whether to save the results as picture files;
- output_dir (str): save path of images;
**NOTE:** choose one parameter to provide data from paths and images
- **Return**
- res (list\[numpy.ndarray\]): result list,ndarray.shape is \[H, W, C\]
## IV.Server Deployment
- PaddleHub Serving can deploy an online service of style transfer.
- ### Step 1: Start PaddleHub Serving
- Run the startup command:
- ```shell
$ hub serving start -m UGATIT_100w
```
- 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.
- ### Step 2: Send a predictive request
- With a configured server, use the following lines of code to send the prediction request and obtain the result
- ```python
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_100w"
r = requests.post(url=url, headers=headers, data=json.dumps(data))
# print prediction results
print(r.json()["results"])
```
## V.Release Note
* 1.0.0
First release
- ```shell
$ hub install UGATIT_100w==1.0.0
```
......@@ -51,7 +51,7 @@
## 三、模型API预测
- ### 1、代码示例
- ### 1、预测代码示例
- ```python
import paddlehub as hub
......
# animegan_v1_hayao_60
|Module Name|animegan_v1_hayao_60|
| :--- | :---: |
|Category|image generation|
|Network|AnimeGAN|
|Dataset|The Wind Rises|
|Fine-tuning supported or not|No|
|Module Size|18MB|
|Latest update date|2021-07-30|
|Data indicators|-|
## I.Basic Information
- ### Application Effect Display
- Sample results:
<p align="center">
<img src="https://ai-studio-static-online.cdn.bcebos.com/bd002c4bb6a7427daf26988770bb18648b7d8d2bfd6746bfb9a429db4867727f" width = "450" height = "300" hspace='10'/>
<br />
Input Image
<br />
<img src="https://ai-studio-static-online.cdn.bcebos.com/10175bb964e94ce18608a84b0ab6ebfe154b523df42f44a3a851b2d91dd17a63" width = "450" height = "300" hspace='10'/>
<br />
Output Image
<br />
</p>
- ### Module Introduction
- AnimeGAN V1 is a style transfer model, which can transfer a image style to Miyazaki carton style. For more information, please refer to [AnimeGAN V1 Project](https://github.com/TachibanaYoshino/AnimeGAN).
## II.Installation
- ### 1、Environmental Dependence
- paddlepaddle >= 1.8.0
- paddlehub >= 1.8.0 | [How to install PaddleHub](../../../../docs/docs_en/get_start/installation.rst)
- ### 2、Installation
- ```shell
$ hub install animegan_v1_hayao_60
```
- In case of any problems during installation, please refer to: [Windows_Quickstart](../../../../docs/docs_en/get_start/windows_quickstart.md) | [Linux_Quickstart](../../../../docs/docs_en/get_start/linux_quickstart.md) | [Mac_Quickstart](../../../../docs/docs_en/get_start/mac_quickstart.md)
## III.Module API Prediction
- ### 1、Prediction Code Example
- ```python
import paddlehub as hub
import cv2
model = hub.Module(name="animegan_v1_hayao_60")
result = model.style_transfer(images=[cv2.imread('/PATH/TO/IMAGE')])
# or
# result = model.style_transfer(paths=['/PATH/TO/IMAGE'])
```
- ### 2、API
- ```python
def style_transfer(images=None,
paths=None,
output_dir='output',
visualization=False,
min_size=32,
max_size=1024)
```
- Style transfer API.
- **Parameters**
- images (list\[numpy.ndarray\]): image data, ndarray.shape is in the format [H, W, C], BGR;
- paths (list[str]): image path;
- output_dir (str): save path of images;
- visualization (bool): Whether to save the results as picture files;
- min\_size (int): min size of image shape,default is 32;
- max\_size (int): max size of image shape,default is 1024.
**NOTE:** choose one parameter to provide data from paths and images
- **Return**
- res (list\[numpy.ndarray\]): result list,ndarray.shape is \[H, W, C\]
## IV.Server Deployment
- PaddleHub Serving can deploy an online service of style transfer.
- ### Step 1: Start PaddleHub Serving
- Run the startup command:
- ```shell
$ hub serving start -m animegan_v1_hayao_60
```
- 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.
- ### Step 2: Send a predictive request
- With a configured server, use the following lines of code to send the prediction request and obtain the result
- ```python
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/animegan_v1_hayao_60"
r = requests.post(url=url, headers=headers, data=json.dumps(data))
# print prediction results
print(r.json()["results"])
```
## V.Release Note
* 1.0.0
First release
* 1.0.1
Adapt to paddlehub2.0
* 1.0.2
Delete optional parameter batch_size
- ```shell
$ hub install animegan_v1_hayao_60==1.0.2
```
......@@ -49,7 +49,7 @@
## 三、模型API预测
- ### 1、代码示例
- ### 1、预测代码示例
- ```python
import paddlehub as hub
......
# animegan_v2_hayao_64
|Module Name|animegan_v2_hayao_64|
| :--- | :---: |
|Category|image generation|
|Network|AnimeGAN|
|Dataset|The Wind Rises|
|Fine-tuning supported or not|No|
|Module Size|9.4MB|
|Latest update date|2021-07-30|
|Data indicators|-|
## I.Basic Information
- ### Application Effect Display
- Sample results:
<p align="center">
<img src="https://ai-studio-static-online.cdn.bcebos.com/bd002c4bb6a7427daf26988770bb18648b7d8d2bfd6746bfb9a429db4867727f" width = "450" height = "300" hspace='10'/>
<br />
Input image
<br />
<img src="https://ai-studio-static-online.cdn.bcebos.com/49620341f1fe4f00af4d93c22694897a1ae578a235844a1db1bbb4bd37bf750b" width = "450" height = "300" hspace='10'/>
<br />
Output image
<br />
</p>
- ### Module Introduction
- AnimeGAN V2 is a style transfer model, which can transfer a image style to Miyazaki carton style. For more information, please refer to [AnimeGAN V2 Project](https://github.com/TachibanaYoshino/AnimeGANv2).
## II.Installation
- ### 1、Environmental Dependence
- paddlepaddle >= 1.8.0
- paddlehub >= 1.8.0 | [How to install PaddleHub](../../../../docs/docs_en/get_start/installation.rst)
- ### 2、Installation
- ```shell
$ hub install animegan_v2_hayao_64
```
- In case of any problems during installation, please refer to: [Windows_Quickstart](../../../../docs/docs_en/get_start/windows_quickstart.md) | [Linux_Quickstart](../../../../docs/docs_en/get_start/linux_quickstart.md) | [Mac_Quickstart](../../../../docs/docs_en/get_start/mac_quickstart.md)
## III.Module API Prediction
- ### 1、Prediction Code Example
- ```python
import paddlehub as hub
import cv2
model = hub.Module(name="animegan_v2_hayao_64")
result = model.style_transfer(images=[cv2.imread('/PATH/TO/IMAGE')])
# or
# result = model.style_transfer(paths=['/PATH/TO/IMAGE'])
```
- ### 3、API
- ```python
def style_transfer(images=None,
paths=None,
output_dir='output',
visualization=False,
min_size=32,
max_size=1024)
```
- Style transfer API.
- **Parameters**
- images (list\[numpy.ndarray\]): image data, ndarray.shape is in the format [H, W, C], BGR;
- paths (list[str]): image path;
- output_dir (str): save path of images;
- visualization (bool): Whether to save the results as picture files;
- min\_size (int): min size of image shape,default is 32;
- max\_size (int): max size of image shape,default is 1024.
**NOTE:** choose one parameter to provide data from paths and images
- **Return**
- res (list\[numpy.ndarray\]): result list,ndarray.shape is \[H, W, C\]
## IV.Server Deployment
- PaddleHub Serving can deploy an online service of style transfer.
- ### Step 1: Start PaddleHub Serving
- Run the startup command:
- ```shell
$ hub serving start -m animegan_v2_hayao_64
```
- 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.
- ### Step 2: Send a predictive request
- With a configured server, use the following lines of code to send the prediction request and obtain the result
- ```python
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/animegan_v2_hayao_64"
r = requests.post(url=url, headers=headers, data=json.dumps(data))
# print prediction results
print(r.json()["results"])
```
## V.Release Note
* 1.0.0
First release
* 1.0.1
Adapt to paddlehub2.0
* 1.0.2
Delete optional parameter batch_size
- ```shell
$ hub install animegan_v2_hayao_64==1.0.2
```
......@@ -51,7 +51,7 @@
## 三、模型API预测
- ### 1、代码示例
- ### 1、预测代码示例
- ```python
import paddlehub as hub
......
# animegan_v2_hayao_99
|Module Name|animegan_v2_hayao_99|
| :--- | :---: |
|Category|image generation|
|Network|AnimeGAN|
|Dataset|The Wind Rises|
|Fine-tuning supported or not|No|
|Module Size|9.4MB|
|Latest update date|2021-07-30|
|Data indicators|-|
## I.Basic Information
- ### Application Effect Display
- Sample results:
<p align="center">
<img src="https://ai-studio-static-online.cdn.bcebos.com/bd002c4bb6a7427daf26988770bb18648b7d8d2bfd6746bfb9a429db4867727f" width = "450" height = "300" hspace='10'/>
<br />
Input image
<br />
<img src="https://ai-studio-static-online.cdn.bcebos.com/16195e03d7e0412d990349587c587a26d9ae9e2ed1ec4fa1b4dc994e948d1f7d" width = "450" height = "300" hspace='10'/>
<br />
Output image
<br />
</p>
- ### Module Introduction
- AnimeGAN V2 is a style transfer model, which can transfer a image style to Miyazaki carton style. For more information, please refer to [AnimeGAN V2 Project](https://github.com/TachibanaYoshino/AnimeGANv2).
## II.Installation
- ### 1、Environmental Dependence
- paddlepaddle >= 1.8.0
- paddlehub >= 1.8.0 | [How to install PaddleHub](../../../../docs/docs_en/get_start/installation.rst)
- ### 2、Installation
- ```shell
$ hub install animegan_v2_hayao_99
```
- In case of any problems during installation, please refer to: [Windows_Quickstart](../../../../docs/docs_en/get_start/windows_quickstart.md) | [Linux_Quickstart](../../../../docs/docs_en/get_start/linux_quickstart.md) | [Mac_Quickstart](../../../../docs/docs_en/get_start/mac_quickstart.md)
## III.Module API Prediction
- ### 1、Prediction Code Example
- ```python
import paddlehub as hub
import cv2
model = hub.Module(name="animegan_v2_hayao_99")
result = model.style_transfer(images=[cv2.imread('/PATH/TO/IMAGE')])
# or
# result = model.style_transfer(paths=['/PATH/TO/IMAGE'])
```
- ### 2、API
- ```python
def style_transfer(images=None,
paths=None,
output_dir='output',
visualization=False,
min_size=32,
max_size=1024)
```
- Style transfer API.
- **Parameters**
- images (list\[numpy.ndarray\]): image data, ndarray.shape is in the format [H, W, C], BGR;
- paths (list[str]): image path;
- output_dir (str): save path of images;
- visualization (bool): Whether to save the results as picture files;
- min\_size (int): min size of image shape,default is 32;
- max\_size (int): max size of image shape,default is 1024.
**NOTE:** choose one parameter to provide data from paths and images
- **Return**
- res (list\[numpy.ndarray\]): result list,ndarray.shape is \[H, W, C\]
## IV.Server Deployment
- PaddleHub Serving can deploy an online service of style transfer.
- ### Step 1: Start PaddleHub Serving
- Run the startup command:
- ```shell
$ hub serving start -m animegan_v2_hayao_99
```
- 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.
- ### Step 2: Send a predictive request
- With a configured server, use the following lines of code to send the prediction request and obtain the result
- ```python
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/animegan_v2_hayao_99"
r = requests.post(url=url, headers=headers, data=json.dumps(data))
# print prediction results
print(r.json()["results"])
```
## V.Release Note
* 1.0.0
First release
* 1.0.1
Adapt to paddlehub2.0
* 1.0.2
Delete optional parameter batch_size
- ```shell
$ hub install animegan_v2_hayao_99==1.0.2
```
......@@ -50,7 +50,7 @@
## 三、模型API预测
- ### 1、代码示例
- ### 1、预测代码示例
- ```python
import paddlehub as hub
......
# animegan_v2_paprika_74
|Module Name|animegan_v2_paprika_74|
| :--- | :---: |
|Category|image generation|
|Network|AnimeGAN|
|Dataset|Paprika|
|Fine-tuning supported or not|No|
|Module Size|9.4MB|
|Latest update date|2021-02-26|
|Data indicators|-|
## I.Basic Information
- ### Application Effect Display
- Sample results:
<p align="center">
<img src="https://ai-studio-static-online.cdn.bcebos.com/bd002c4bb6a7427daf26988770bb18648b7d8d2bfd6746bfb9a429db4867727f" width = "450" height = "300" hspace='10'/>
<br />
Input Image
<br />
<img src="https://ai-studio-static-online.cdn.bcebos.com/6574669d87b24bab9627c6e33896528b4a0bf5af1cd84ca29655d68719f2d551" width = "450" height = "300" hspace='10'/>
<br />
Output Image
<br />
</p>
- ### Module Introduction
- AnimeGAN V2 is a style transfer model, which can transfer a image style to paprika carton style. For more information, please refer to [AnimeGAN V2 Project](https://github.com/TachibanaYoshino/AnimeGANv2).
## II.Installation
- ### 1、Environmental Dependence
- paddlepaddle >= 1.8.0
- paddlehub >= 1.8.0 | [How to install PaddleHub](../../../../docs/docs_en/get_start/installation.rst)
- ### 2、Installation
- ```shell
$ hub install animegan_v2_paprika_74
```
- In case of any problems during installation, please refer to: [Windows_Quickstart](../../../../docs/docs_en/get_start/windows_quickstart.md) | [Linux_Quickstart](../../../../docs/docs_en/get_start/linux_quickstart.md) | [Mac_Quickstart](../../../../docs/docs_en/get_start/mac_quickstart.md)
## III.Module API Prediction
- ### 1、Prediction Code Example
- ```python
import paddlehub as hub
import cv2
model = hub.Module(name="animegan_v2_paprika_74")
result = model.style_transfer(images=[cv2.imread('/PATH/TO/IMAGE')])
# or
# result = model.style_transfer(paths=['/PATH/TO/IMAGE'])
```
- ### 2、API
- ```python
def style_transfer(images=None,
paths=None,
output_dir='output',
visualization=False,
min_size=32,
max_size=1024)
```
- Style transfer API.
- **Parameters**
- images (list\[numpy.ndarray\]): image data, ndarray.shape is in the format [H, W, C], BGR;
- paths (list[str]): image path;
- output_dir (str): save path of images;
- visualization (bool): Whether to save the results as picture files;
- min\_size (int): min size of image shape,default is 32;
- max\_size (int): max size of image shape,default is 1024.
- **Return**
- res (list\[numpy.ndarray\]): result list,ndarray.shape is \[H, W, C\]
## IV.Server Deployment
- PaddleHub Serving can deploy an online service of style transfer.
- ### Step 1: Start PaddleHub Serving
- Run the startup command:
- ```shell
$ hub serving start -m animegan_v2_paprika_74
```
- 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.
- ### Step 2: Send a predictive request
- With a configured server, use the following lines of code to send the prediction request and obtain the result
- ```python
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/animegan_v2_paprika_74"
r = requests.post(url=url, headers=headers, data=json.dumps(data))
# print prediction results
print(r.json()["results"])
```
## V.Release Note
* 1.0.0
First release
* 1.0.1
Adapt to paddlehub2.0
* 1.0.2
Delete optional parameter batch_size
- ```shell
$ hub install animegan_v2_paprika_74==1.0.2
```
......@@ -50,7 +50,7 @@
## 三、模型API预测
- ### 1、代码示例
- ### 1、预测代码示例
- ```python
import paddlehub as hub
......
# animegan_v2_paprika_98
|Module Name|animegan_v2_paprika_98|
| :--- | :---: |
|Category|image generation|
|Network|AnimeGAN|
|Dataset|Paprika|
|Fine-tuning supported or not|No|
|Module Size|9.4MB|
|Latest update date|2021-07-30|
|Data indicators|-|
## I.Basic Information
- ### Application Effect Display
- Sample results:
<p align="center">
<img src="https://ai-studio-static-online.cdn.bcebos.com/bd002c4bb6a7427daf26988770bb18648b7d8d2bfd6746bfb9a429db4867727f" width = "450" height = "300" hspace='10'/>
<br />
Input image
<br />
<img src="https://ai-studio-static-online.cdn.bcebos.com/495436a627ef423ab572536c5f2ba6d0eb99b1ce098947a5ac02af36e7eb85f7" width = "450" height = "300" hspace='10'/>
<br />
Output image
<br />
</p>
- ### Module Introduction
- AnimeGAN V2 is a style transfer model, which can transfer a image style to paprika carton style. For more information, please refer to [AnimeGAN V2 Project](https://github.com/TachibanaYoshino/AnimeGANv2).
## II.Installation
- ### 1、Environmental Dependence
- paddlepaddle >= 1.8.0
- paddlehub >= 1.8.0 | [How to install PaddleHub](../../../../docs/docs_en/get_start/installation.rst)
- ### 2、Installation
- ```shell
$ hub install animegan_v2_paprika_98
```
- In case of any problems during installation, please refer to: [Windows_Quickstart](../../../../docs/docs_en/get_start/windows_quickstart.md) | [Linux_Quickstart](../../../../docs/docs_en/get_start/linux_quickstart.md) | [Mac_Quickstart](../../../../docs/docs_en/get_start/mac_quickstart.md)
## III.Module API Prediction
- ### 1、Prediction Code Example
- ```python
import paddlehub as hub
import cv2
model = hub.Module(name="animegan_v2_paprika_98")
result = model.style_transfer(images=[cv2.imread('/PATH/TO/IMAGE')])
# or
# result = model.style_transfer(paths=['/PATH/TO/IMAGE'])
```
- ### 2、API
- ```python
def style_transfer(images=None,
paths=None,
output_dir='output',
visualization=False,
min_size=32,
max_size=1024)
```
- Style transfer API.
- **Parameters**
- images (list\[numpy.ndarray\]): image data, ndarray.shape is in the format [H, W, C], BGR;
- paths (list[str]): image path;
- output_dir (str): save path of images;
- visualization (bool): Whether to save the results as picture files;
- min\_size (int): min size of image shape,default is 32;
- max\_size (int): max size of image shape,default is 1024.
**NOTE:** choose one parameter to provide data from paths and images
- **Return**
- res (list\[numpy.ndarray\]): result list,ndarray.shape is \[H, W, C\]
## IV.Server Deployment
- PaddleHub Serving can deploy an online service of style transfer.
- ### Step 1: Start PaddleHub Serving
- Run the startup command:
- ```shell
$ hub serving start -m animegan_v2_paprika_98
```
- 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.
- ### Step 2: Send a predictive request
- With a configured server, use the following lines of code to send the prediction request and obtain the result
- ```python
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/animegan_v2_paprika_98"
r = requests.post(url=url, headers=headers, data=json.dumps(data))
# print prediction results
print(r.json()["results"])
```
## V.Release Note
* 1.0.0
First release
* 1.0.1
Adapt to paddlehub2.0
* 1.0.2
Delete optional parameter batch_size
- ```shell
$ hub install animegan_v2_paprika_98==1.0.2
```
......@@ -50,7 +50,7 @@
## 三、模型API预测
- ### 1、代码示例
- ### 1、预测代码示例
- ```python
import paddlehub as hub
......
# animegan_v2_shinkai_33
|Module Name|animegan_v2_shinkai_33|
| :--- | :---: |
|Category|image generation|
|Network|AnimeGAN|
|Dataset|Your Name, Weathering with you|
|Fine-tuning supported or not|No|
|Module Size|9.4MB|
|Latest update date|2021-07-30|
|Data indicators|-|
## I.Basic Information
- ### Application Effect Display
- Sample results:
<p align="center">
<img src="https://ai-studio-static-online.cdn.bcebos.com/bd002c4bb6a7427daf26988770bb18648b7d8d2bfd6746bfb9a429db4867727f" width = "450" height = "300" hspace='10'/>
<br />
Input image
<br />
<img src="https://ai-studio-static-online.cdn.bcebos.com/776a84a0d97c452bbbe479592fbb8f5c6fe9c45f3b7e41fd8b7da80bf52ee668" width = "450" height = "300" hspace='10'/>
<br />
Output image
<br />
</p>
- ### Module Introduction
- AnimeGAN V2 is a style transfer model, which can transfer a image style to Shinkai carton style. For more information, please refer to [AnimeGAN V2 Project](https://github.com/TachibanaYoshino/AnimeGANv2).
## II.Installation
- ### 1、Environmental Dependence
- paddlepaddle >= 1.8.0
- paddlehub >= 1.8.0 | [How to install PaddleHub](../../../../docs/docs_en/get_start/installation.rst)
- ### 2、Installation
- ```shell
$ hub install animegan_v2_shinkai_33
```
- In case of any problems during installation, please refer to: [Windows_Quickstart](../../../../docs/docs_en/get_start/windows_quickstart.md) | [Linux_Quickstart](../../../../docs/docs_en/get_start/linux_quickstart.md) | [Mac_Quickstart](../../../../docs/docs_en/get_start/mac_quickstart.md)
## III.Module API Prediction
- ### 1、Prediction Code Example
- ```python
import paddlehub as hub
import cv2
model = hub.Module(name="animegan_v2_shinkai_33")
result = model.style_transfer(images=[cv2.imread('/PATH/TO/IMAGE')])
# or
# result = model.style_transfer(paths=['/PATH/TO/IMAGE'])
```
- ### 2、API
- ```python
def style_transfer(images=None,
paths=None,
output_dir='output',
visualization=False,
min_size=32,
max_size=1024)
```
- Style transfer API.
- **Parameters**
- images (list\[numpy.ndarray\]): image data, ndarray.shape is in the format [H, W, C], BGR;
- paths (list[str]): image path;
- output_dir (str): save path of images;
- visualization (bool): Whether to save the results as picture files;
- min\_size (int): min size of image shape,default is 32;
- max\_size (int): max size of image shape,default is 1024.
**NOTE:** choose one parameter to provide data from paths and images
- **Return**
- res (list\[numpy.ndarray\]): result list,ndarray.shape is \[H, W, C\]
## IV.Server Deployment
- PaddleHub Serving can deploy an online service of style transfer.
- ### Step 1: Start PaddleHub Serving
- Run the startup command:
- ```shell
$ hub serving start -m animegan_v2_shinkai_33
```
- 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.
- ### Step 2: Send a predictive request
- With a configured server, use the following lines of code to send the prediction request and obtain the result
- ```python
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/animegan_v2_shinkai_33"
r = requests.post(url=url, headers=headers, data=json.dumps(data))
# print prediction results
print(r.json()["results"])
```
## V.Release Note
* 1.0.0
First release
* 1.0.1
Adapt to paddlehub2.0
* 1.0.2
Delete optional parameter batch_size
- ```shell
$ hub install animegan_v2_shinkai_33==1.0.2
```
......@@ -50,7 +50,7 @@
## 三、模型API预测
- ### 1、代码示例
- ### 1、预测代码示例
- ```python
import paddlehub as hub
......
# animegan_v2_shinkai_53
|Module Name|animegan_v2_shinkai_53|
| :--- | :---: |
|Category|image generation|
|Network|AnimeGAN|
|Dataset|Your Name, Weathering with you|
|Fine-tuning supported or not|No|
|Module Size|9.4MB|
|Latest update date|2021-07-30|
|Data indicators|-|
## I.Basic Information
- ### Application Effect Display
- Sample results:
<p align="center">
<img src="https://ai-studio-static-online.cdn.bcebos.com/bd002c4bb6a7427daf26988770bb18648b7d8d2bfd6746bfb9a429db4867727f" width = "450" height = "300" hspace='10'/>
<br />
Input image
<br />
<img src="https://ai-studio-static-online.cdn.bcebos.com/fa4ba157e73c48658c4c9c6b8b92f5c99231d1d19556472788b1e5dd58d5d6cc" width = "450" height = "300" hspace='10'/>
<br />
Output image
<br />
</p>
- ### Module Introduction
- AnimeGAN V2 is a style transfer model, which can transfer a image style to Shinkai carton style. For more information, please refer to [AnimeGAN V2 Project](https://github.com/TachibanaYoshino/AnimeGANv2).
## II.Installation
- ### 1、Environmental Dependence
- paddlepaddle >= 1.8.0
- paddlehub >= 1.8.0 | [How to install PaddleHub](../../../../docs/docs_en/get_start/installation.rst)
- ### 2、Installation
- ```shell
$ hub install animegan_v2_shinkai_53
```
- In case of any problems during installation, please refer to: [Windows_Quickstart](../../../../docs/docs_en/get_start/windows_quickstart.md) | [Linux_Quickstart](../../../../docs/docs_en/get_start/linux_quickstart.md) | [Mac_Quickstart](../../../../docs/docs_en/get_start/mac_quickstart.md)
## III.Module API Prediction
- ### 1、Prediction Code Example
- ```python
import paddlehub as hub
import cv2
model = hub.Module(name="animegan_v2_shinkai_53")
result = model.style_transfer(images=[cv2.imread('/PATH/TO/IMAGE')])
# or
# result = model.style_transfer(paths=['/PATH/TO/IMAGE'])
```
- ### 2、API
- ```python
def style_transfer(images=None,
paths=None,
output_dir='output',
visualization=False,
min_size=32,
max_size=1024)
```
- Style transfer API.
- **Parameters**
- images (list\[numpy.ndarray\]): image data, ndarray.shape is in the format [H, W, C], BGR;
- paths (list[str]): image path;
- output_dir (str): save path of images;
- visualization (bool): Whether to save the results as picture files;
- min\_size (int): min size of image shape,default is 32;
- max\_size (int): max size of image shape,default is 1024.
**NOTE:** choose one parameter to provide data from paths and images
- **Return**
- res (list\[numpy.ndarray\]): result list,ndarray.shape is \[H, W, C\]
## IV.Server Deployment
- PaddleHub Serving can deploy an online service of style transfer.
- ### Step 1: Start PaddleHub Serving
- Run the startup command:
- ```shell
$ hub serving start -m animegan_v2_shinkai_53
```
- 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.
- ### Step 2: Send a predictive request
- With a configured server, use the following lines of code to send the prediction request and obtain the result
- ```python
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/animegan_v2_shinkai_53"
r = requests.post(url=url, headers=headers, data=json.dumps(data))
# print prediction results
print(r.json()["results"])
```
## V.Release Note
* 1.0.0
First release
* 1.0.1
Adapt to paddlehub2.0
* 1.0.2
Delete optional parameter batch_size
- ```shell
$ hub install animegan_v2_shinkai_53==1.0.2
```
......@@ -48,7 +48,7 @@
$ hub run stylepro_artistic --input_path "/PATH/TO/IMAGE"
```
- 通过命令行方式实现风格转换模型的调用,更多请见 [PaddleHub命令行指令](../../../../docs/docs_ch/tutorial/cmd_usage.rst)
- ### 2、代码示例
- ### 2、预测代码示例
- ```python
import paddlehub as hub
......
# stylepro_artistic
|Module Name|stylepro_artistic|
| :--- | :---: |
|Category|image generation|
|Network|StyleProNet|
|Dataset|MS-COCO + WikiArt|
|Fine-tuning supported or not|No|
|Module Size|28MB|
|Latest update date|2021-02-26|
|Data indicators|-|
## I.Basic Information
- ### Application Effect Display
- Sample results:
<p align="center">
<img src="https://paddlehub.bj.bcebos.com/resources/style.png" width='80%' hspace='10'/> <br />
</p>
- ### Module Introduction
- StyleProNet is a model for style transfer, which is light-weight and responds quickly. This module is based on StyleProNet, trained on WikiArt(MS-COCO) and WikiArt(style) datasets, and can be used for style transfer. For more information, please refer to [StyleProNet](https://arxiv.org/abs/2003.07694).
## II.Installation
- ### 1、Environmental Dependence
- paddlepaddle >= 1.6.2
- paddlehub >= 1.6.0 | [How to install PaddleHub](../../../../docs/docs_en/get_start/installation.rst)
- ### 2、Installation
- ```shell
$ hub install stylepro_artistic
```
- In case of any problems during installation, please refer to: [Windows_Quickstart](../../../../docs/docs_en/get_start/windows_quickstart.md) | [Linux_Quickstart](../../../../docs/docs_en/get_start/linux_quickstart.md) | [Mac_Quickstart](../../../../docs/docs_en/get_start/mac_quickstart.md)
## III.Module API Prediction
- ### 1、Command line Prediction
- ```shell
$ hub run stylepro_artistic --input_path "/PATH/TO/IMAGE"
```
- If you want to call the Hub module through the command line, please refer to: [PaddleHub Command Line Instruction](../../../../docs/docs_ch/tutorial/cmd_usage.rst)
- ### 2、Prediction Code Example
- ```python
import paddlehub as hub
import cv2
stylepro_artistic = hub.Module(name="stylepro_artistic")
result = stylepro_artistic.style_transfer(
images=[{
'content': cv2.imread('/PATH/TO/CONTENT_IMAGE'),
'styles': [cv2.imread('/PATH/TO/STYLE_IMAGE')]
}])
# or
# result = stylepro_artistic.style_transfer(
# paths=[{
# 'content': '/PATH/TO/CONTENT_IMAGE',
# 'styles': ['/PATH/TO/STYLE_IMAGE']
# }])
```
- ### 3、API
- ```python
def style_transfer(images=None,
paths=None,
alpha=1,
use_gpu=False,
visualization=False,
output_dir='transfer_result')
```
- Style transfer API.
- **Parameters**
- images (list\[dict\]): each element is a dict,includes:
- content (numpy.ndarray): input image array,shape is \[H, W, C\],BGR format;<br/>
- styles (list\[numpy.ndarray\]) : list of style image arrays,shape is \[H, W, C\],BGR format;<br/>
- weights (list\[float\], optioal) : weight for each style, if not set, each style has the same weight;<br/>
- paths (list\[dict\]): each element is a dict,includes:
- content (str): path for input image;<br/>
- styles (list\[str\]) : paths for style images;<br/>
- weights (list\[float\], optioal) : weight for each style, if not set, each style has the same weight;<br/>
- alpha (float) : alpha value,\[0, 1\] ,default is 1<br/>
- use_gpu (bool): use GPU or not; **set the CUDA_VISIBLE_DEVICES environment variable first if you are using GPU**
- visualization (bool): Whether to save the results as picture files;
- output_dir (str): save path of images;
**NOTE:** choose one parameter to provide data from paths and images
- **Return**
- res (list\[dict\]): results
- path (str): path for input image
- data (numpy.ndarray): output image
- ```python
def save_inference_model(dirname,
model_filename=None,
params_filename=None,
combined=True)
```
- Save model to specific path
- **Parameters**
- dirname: output dir for saving model
- model\_filename: filename for saving model
- params\_filename: filename for saving parameters
- combined: whether save parameters into one file
## IV.Server Deployment
- PaddleHub Serving can deploy an online service of style transfer.
- ### Step 1: Start PaddleHub Serving
- Run the startup command:
- ```shell
$ hub serving start -m stylepro_artistic
```
- 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.
- ### Step 2: Send a predictive request
- With a configured server, use the following lines of code to send the prediction request and obtain the result
- ```python
import requests
import json
import cv2
import base64
import numpy as np
def cv2_to_base64(image):
data = cv2.imencode('.jpg', image)[1]
return base64.b64encode(data.tostring()).decode('utf8')
def base64_to_cv2(b64str):
data = base64.b64decode(b64str.encode('utf8'))
data = np.fromstring(data, np.uint8)
data = cv2.imdecode(data, cv2.IMREAD_COLOR)
return data
# Send an HTTP request
data = {'images':[
{
'content':cv2_to_base64(cv2.imread('/PATH/TO/CONTENT_IMAGE')),
'styles':[cv2_to_base64(cv2.imread('/PATH/TO/STYLE_IMAGE'))]
}
]}
headers = {"Content-type": "application/json"}
url = "http://127.0.0.1:8866/predict/stylepro_artistic"
r = requests.post(url=url, headers=headers, data=json.dumps(data))
# print prediction results
print(base64_to_cv2(r.json()["results"][0]['data']))
```
## V.Release Note
* 1.0.0
First release
* 1.0.1
- ```shell
$ hub install stylepro_artistic==1.0.1
```
# DriverStatusRecognition
|Module Name|DriverStatusRecognition|
| :--- | :---: |
|Category|image classification|
|Network|MobileNetV3_small_ssld|
|Dataset|Distractible Driver Dataset|
|Fine-tuning supported or not|No|
|Module Size|6MB|
|Latest update date|-|
|Data indicators|-|
## I.Basic Information
- ### Module Introduction
- This module can be used for recognizing distractible drivers by analysing the expression on the face.
## II.Installation
- ### 1、Environmental Dependence
- paddlepaddle >= 2.0.0
- paddlehub >= 2.0.0 | [How to install PaddleHub](../../../../docs/docs_en/get_start/installation.rst)
- paddlex >= 1.3.7
- ### 2、Installation
- ```shell
$ hub install DriverStatusRecognition
```
- In case of any problems during installation, please refer to: [Windows_Quickstart](../../../../docs/docs_en/get_start/windows_quickstart.md) | [Linux_Quickstart](../../../../docs/docs_en/get_start/linux_quickstart.md) | [Mac_Quickstart](../../../../docs/docs_en/get_start/mac_quickstart.md)
- ### 3、Online experience
[AI Studio](https://aistudio.baidu.com/aistudio/projectdetail/1649513)
## III.Module API Prediction
- ### 1、Command line Prediction
- ```shell
$ hub run DriverStatusRecognition --input_path /PATH/TO/IMAGE
```
- If you want to call the Hub module through the command line, please refer to: [PaddleHub Command Line Instruction](../../../../docs/docs_ch/tutorial/cmd_usage.rst)
- ### 2、Prediction Code Example
- ```python
import paddlehub as hub
import cv2
classifier = hub.Module(name="DriverStatusRecognition")
images = [cv2.imread('/PATH/TO/IMAGE')]
results = classifier.predict(images=images)
for result in results:
print(result)
```
- ### 3、API
- ```python
def predict(images)
```
- classification API.
- **Parameters**
- images (list\[numpy.ndarray\]): image data, ndarray.shape is in the format [H, W, C], BGR;
- **Return**
- result(list[dict]): classication results, each element in the list is dict, key is the label name, and value is the corresponding probability
## IV.Release Note
* 1.0.0
First release
- ```shell
$ hub install DriverStatusRecognition==1.0.0
```
# SnakeIdentification
|Module Name|SnakeIdentification|
| :--- | :---: |
|Category|image classification|
|Network|ResNet50_vd_ssld|
|Dataset|Snake Dataset|
|Fine-tuning supported or not|No|
|Module Size|84MB|
|Latest update date|-|
|Data indicators|-|
## I.Basic Information
- ### Module Introduction
- This module can be used to identify the kind of snake, and judge the toxicity.
## II.Installation
- ### 1、Environmental Dependence
- paddlepaddle >= 2.0.0
- paddlehub >= 2.0.0 | [How to install PaddleHub](../../../../docs/docs_en/get_start/installation.rst)
- paddlex >= 1.3.7
- ### 2、Installation
- ```shell
$ hub install SnakeIdentification
```
- In case of any problems during installation, please refer to: [Windows_Quickstart](../../../../docs/docs_en/get_start/windows_quickstart.md) | [Linux_Quickstart](../../../../docs/docs_en/get_start/linux_quickstart.md) | [Mac_Quickstart](../../../../docs/docs_en/get_start/mac_quickstart.md)
- ### 3、Online experience
[AI Studio](https://aistudio.baidu.com/aistudio/projectdetail/1646951)
## III.Module API Prediction
- ### 1、Command line Prediction
- ```shell
$ hub run SnakeIdentification --input_path /PATH/TO/IMAGE
```
- If you want to call the Hub module through the command line, please refer to: [PaddleHub Command Line Instruction](../../../../docs/docs_ch/tutorial/cmd_usage.rst)
- ### 2、Prediction Code Example
- ```python
import paddlehub as hub
import cv2
classifier = hub.Module(name="SnakeIdentification")
images = [cv2.imread('/PATH/TO/IMAGE')]
results = classifier.predict(images=images)
for result in results:
print(result)
```
- ### 3、API
- ```python
def predict(images)
```
- classification API.
- **Parameters**
- images (list\[numpy.ndarray\]): image data, ndarray.shape is in the format [H, W, C], BGR;
- **Return**
- result(list[dict]): classication results, each element in the list is dict, key is the label name, and value is the corresponding probability
## IV.Release Note
* 1.0.0
First release
- ```shell
$ hub install SnakeIdentification==1.0.0
```
# alexnet_imagenet
|Module Name|alexnet_imagenet|
| :--- | :---: |
|Category|image classification|
|Network|AlexNet|
|Dataset|ImageNet-2012|
|Fine-tuning supported or not|No|
|Module Size|234MB|
|Latest update date|-|
|Data indicators|-|
## I.Basic Information
- ### Module Introduction
- AlexNet was a classification model proposed by Alex Krizhevsky in 2012, and gained the champion of ILSVRC 2012. This module is based on AlexNet, trained on ImageNet-2012, and can predict an image of size 224*224*3.
## II.Installation
- ### 1、Environmental Dependence
- paddlepaddle >= 1.4.0
- paddlehub >= 1.0.0 | [How to install PaddleHub](../../../../docs/docs_en/get_start/installation.rst)
- ### 2、Installation
- ```shell
$ hub install alexnet_imagenet
```
- In case of any problems during installation, please refer to: [Windows_Quickstart](../../../../docs/docs_en/get_start/windows_quickstart.md) | [Linux_Quickstart](../../../../docs/docs_en/get_start/linux_quickstart.md) | [Mac_Quickstart](../../../../docs/docs_en/get_start/mac_quickstart.md)
## III.Module API Prediction
- ### 1、Command line Prediction
- ```shell
$ hub run alexnet_imagenet --input_path "/PATH/TO/IMAGE"
```
- If you want to call the Hub module through the command line, please refer to: [PaddleHub Command Line Instruction](../../../../docs/docs_ch/tutorial/cmd_usage.rst)
- ### 2、Prediction Code Example
- ```python
import paddlehub as hub
import cv2
classifier = hub.Module(name="alexnet_imagenet")
test_img_path = "/PATH/TO/IMAGE"
input_dict = {"image": [test_img_path]}
result = classifier.classification(data=input_dict)
```
- ### 3、API
- ```python
def classification(data)
```
- classification API.
- **Parameters**
- data (dict): key is "image", value is a list of image paths
- **Return**
- result(list[dict]): classication results, each element in the list is dict, key is the label name, and value is the corresponding probability
## IV.Release Note
* 1.0.0
First release
- ```shell
$ hub install alexnet_imagenet==1.0.0
```
# darknet53_imagenet
|Module Name|darknet53_imagenet|
| :--- | :---: |
|Category|image classification|
|Network|DarkNet|
|Dataset|ImageNet-2012|
|Fine-tuning supported or not|No|
|Module Size|160MB|
|Latest update date|-|
|Data indicators|-|
## I.Basic Information
- ### Module Introduction
- DarkNet is a classification model proposed by Joseph Redmon, which uses Yolov3 as backbone to extract features. This module is based on darknet53, trained on ImageNet-2012, and can predict an image of size 224*224*3.
## II.Installation
- ### 1、Environmental Dependence
- paddlepaddle >= 1.4.0
- paddlehub >= 1.0.0 | [How to install PaddleHub](../../../../docs/docs_en/get_start/installation.rst)
- ### 2、Installation
- ```shell
$ hub install darknet53_imagenet
```
- In case of any problems during installation, please refer to: [Windows_Quickstart](../../../../docs/docs_en/get_start/windows_quickstart.md) | [Linux_Quickstart](../../../../docs/docs_en/get_start/linux_quickstart.md) | [Mac_Quickstart](../../../../docs/docs_en/get_start/mac_quickstart.md)
## III.Module API Prediction
- ### 1、Command line Prediction
- ```shell
$ hub run darknet53_imagenet --input_path "/PATH/TO/IMAGE"
```
- If you want to call the Hub module through the command line, please refer to: [PaddleHub Command Line Instruction](../../../../docs/docs_ch/tutorial/cmd_usage.rst)
- ### 2、Prediction Code Example
- ```python
import paddlehub as hub
import cv2
classifier = hub.Module(name="darknet53_imagenet")
test_img_path = "/PATH/TO/IMAGE"
input_dict = {"image": [test_img_path]}
result = classifier.classification(data=input_dict)
```
- ### 3、API
- ```python
def classification(data)
```
- classification API.
- **Parameters**
- data (dict): key is "image", value is a list of image paths
- **Return**
- result(list[dict]): classication results, each element in the list is dict, key is the label name, and value is the corresponding probability
## IV.Release Note
* 1.0.0
First release
- ```shell
$ hub install darknet53_imagenet==1.0.0
```
# densenet121_imagenet
|Module Name|densenet121_imagenet|
| :--- | :---: |
|Category|image classification|
|Network|DenseNet|
|Dataset|ImageNet-2012|
|Fine-tuning supported or not|No|
|Module Size|34MB|
|Latest update date|-|
|Data indicators|-|
## I.Basic Information
- ### Module Introduction
- DenseNet is the model in CVPR2017 best paper. Every layer outputs its result as input for the layer after it, and forms the dense connection topology. The dense connection ease the probblem of vanishing gradient and improve the information flow. This module is based on DenseNet121, trained on ImageNet-2012, and can predict an image of size 224*224*3.
## II.Installation
- ### 1、Environmental Dependence
- paddlepaddle >= 1.4.0
- paddlehub >= 1.0.0 | [How to install PaddleHub](../../../../docs/docs_en/get_start/installation.rst)
- ### 2、Installation
- ```shell
$ hub install densenet121_imagenet
```
- In case of any problems during installation, please refer to: [Windows_Quickstart](../../../../docs/docs_en/get_start/windows_quickstart.md) | [Linux_Quickstart](../../../../docs/docs_en/get_start/linux_quickstart.md) | [Mac_Quickstart](../../../../docs/docs_en/get_start/mac_quickstart.md)
## III.Module API Prediction
- ### 1、Command line Prediction
- ```shell
$ hub run densenet121_imagenet --input_path "/PATH/TO/IMAGE"
```
- If you want to call the Hub module through the command line, please refer to: [PaddleHub Command Line Instruction](../../../../docs/docs_ch/tutorial/cmd_usage.rst)
- ### 2、Prediction Code Example
- ```python
import paddlehub as hub
import cv2
classifier = hub.Module(name="densenet121_imagenet")
test_img_path = "/PATH/TO/IMAGE"
input_dict = {"image": [test_img_path]}
result = classifier.classification(data=input_dict)
```
- ### 3、API
- ```python
def classification(data)
```
- classification API.
- **Parameters**
- data (dict): key is "image", value is a list of image paths
- **Return**
- result(list[dict]): classication results, each element in the list is dict, key is the label name, and value is the corresponding probability
## IV.Release Note
* 1.0.0
First release
- ```shell
$ hub install densenet121_imagenet==1.0.0
```
# densenet161_imagenet
|Module Name|densenet161_imagenet|
| :--- | :---: |
|Category|image classification|
|Network|DenseNet|
|Dataset|ImageNet-2012|
|Fine-tuning supported or not|No|
|Module Size|114MB|
|Latest update date|-|
|Data indicators|-|
## I.Basic Information
- ### Module Introduction
- DenseNet is the model in CVPR2017 best paper. Every layer outputs its result as input for the layer after it, and forms the dense connection topology. The dense connection ease the probblem of vanishing gradient and improve the information flow. This module is based on DenseNet161, trained on ImageNet-2012, and can predict an image of size 224*224*3.
## II.Installation
- ### 1、Environmental Dependence
- paddlepaddle >= 1.4.0
- paddlehub >= 1.0.0 | [How to install PaddleHub](../../../../docs/docs_en/get_start/installation.rst)
- ### 2、Installation
- ```shell
$ hub install densenet161_imagenet
```
- In case of any problems during installation, please refer to: [Windows_Quickstart](../../../../docs/docs_en/get_start/windows_quickstart.md) | [Linux_Quickstart](../../../../docs/docs_en/get_start/linux_quickstart.md) | [Mac_Quickstart](../../../../docs/docs_en/get_start/mac_quickstart.md)
## III.Module API Prediction
- ### 1、Command line Prediction
- ```shell
$ hub run densenet161_imagenet --input_path "/PATH/TO/IMAGE"
```
- If you want to call the Hub module through the command line, please refer to: [PaddleHub Command Line Instruction](../../../../docs/docs_ch/tutorial/cmd_usage.rst)
- ### 2、Prediction Code Example
- ```python
import paddlehub as hub
import cv2
classifier = hub.Module(name="densenet161_imagenet")
test_img_path = "/PATH/TO/IMAGE"
input_dict = {"image": [test_img_path]}
result = classifier.classification(data=input_dict)
```
- ### 3、API
- ```python
def classification(data)
```
- classification API.
- **Parameters**
- data (dict): key is "image", value is a list of image paths
- **Return**
- result(list[dict]): classication results, each element in the list is dict, key is the label name, and value is the corresponding probability
## IV.Release Note
* 1.0.0
First release
- ```shell
$ hub install densenet161_imagenet==1.0.0
```
# densenet169_imagenet
|Module Name|densenet169_imagenet|
| :--- | :---: |
|Category|image classification|
|Network|DenseNet|
|Dataset|ImageNet-2012|
|Fine-tuning supported or not|No|
|Module Size|59MB|
|Latest update date|-|
|Data indicators|-|
## I.Basic Information
- ### Module Introduction
- DenseNet is the model in CVPR2017 best paper. Every layer outputs its result as input for the layer after it, and forms the dense connection topology. The dense connection ease the probblem of vanishing gradient and improve the information flow. This module is based on DenseNet169, trained on ImageNet-2012, and can predict an image of size 224*224*3.
## II.Installation
- ### 1、Environmental Dependence
- paddlepaddle >= 1.4.0
- paddlehub >= 1.0.0 | [How to install PaddleHub](../../../../docs/docs_en/get_start/installation.rst)
- ### 2、Installation
- ```shell
$ hub install densenet169_imagenet
```
- In case of any problems during installation, please refer to: [Windows_Quickstart](../../../../docs/docs_en/get_start/windows_quickstart.md) | [Linux_Quickstart](../../../../docs/docs_en/get_start/linux_quickstart.md) | [Mac_Quickstart](../../../../docs/docs_en/get_start/mac_quickstart.md)
## III.Module API Prediction
- ### 1、Command line Prediction
- ```shell
$ hub run densenet169_imagenet --input_path "/PATH/TO/IMAGE"
```
- If you want to call the Hub module through the command line, please refer to: [PaddleHub Command Line Instruction](../../../../docs/docs_ch/tutorial/cmd_usage.rst)
- ### 2、Prediction Code Example
- ```python
import paddlehub as hub
import cv2
classifier = hub.Module(name="densenet169_imagenet")
test_img_path = "/PATH/TO/IMAGE"
input_dict = {"image": [test_img_path]}
result = classifier.classification(data=input_dict)
```
- ### 3、API
- ```python
def classification(data)
```
- classification API.
- **Parameters**
- data (dict): key is "image", value is a list of image paths
- **Return**
- result(list[dict]): classication results, each element in the list is dict, key is the label name, and value is the corresponding probability
## IV.Release Note
* 1.0.0
First release
- ```shell
$ hub install densenet169_imagenet==1.0.0
```
# densenet201_imagenet
|Module Name|densenet201_imagenet|
| :--- | :---: |
|Category|image classification|
|Network|DenseNet|
|Dataset|ImageNet-2012|
|Fine-tuning supported or not|No|
|Module Size|82MB|
|Latest update date|-|
|Data indicators|-|
## I.Basic Information
- ### Module Introduction
- DenseNet is the model in CVPR2017 best paper. Every layer outputs its result as input for the layer after it, and forms the dense connection topology. The dense connection ease the probblem of vanishing gradient and improve the information flow. This module is based on DenseNet201, trained on ImageNet-2012, and can predict an image of size 224*224*3.
## II.Installation
- ### 1、Environmental Dependence
- paddlepaddle >= 1.4.0
- paddlehub >= 1.0.0 | [How to install PaddleHub](../../../../docs/docs_en/get_start/installation.rst)
- ### 2、Installation
- ```shell
$ hub install densenet201_imagenet
```
- In case of any problems during installation, please refer to: [Windows_Quickstart](../../../../docs/docs_en/get_start/windows_quickstart.md) | [Linux_Quickstart](../../../../docs/docs_en/get_start/linux_quickstart.md) | [Mac_Quickstart](../../../../docs/docs_en/get_start/mac_quickstart.md)
## III.Module API Prediction
- ### 1、Command line Prediction
- ```shell
$ hub run densenet201_imagenet --input_path "/PATH/TO/IMAGE"
```
- If you want to call the Hub module through the command line, please refer to: [PaddleHub Command Line Instruction](../../../../docs/docs_ch/tutorial/cmd_usage.rst)
- ### 2、Prediction Code Example
- ```python
import paddlehub as hub
import cv2
classifier = hub.Module(name="densenet201_imagenet")
test_img_path = "/PATH/TO/IMAGE"
input_dict = {"image": [test_img_path]}
result = classifier.classification(data=input_dict)
```
- ### 3、API
- ```python
def classification(data)
```
- classification API.
- **Parameters**
- data (dict): key is "image", value is a list of image paths
- **Return**
- result(list[dict]): classication results, each element in the list is dict, key is the label name, and value is the corresponding probability
## IV.Release Note
* 1.0.0
First release
- ```shell
$ hub install densenet201_imagenet==1.0.0
```
# densenet264_imagenet
|Module Name|densenet264_imagenet|
| :--- | :---: |
|Category|image classification|
|Network|DenseNet|
|Dataset|ImageNet-2012|
|Fine-tuning supported or not|No|
|Module Size|135MB|
|Latest update date|-|
|Data indicators|-|
## I.Basic Information
- ### Module Introduction
- DenseNet is the model in CVPR2017 best paper. Every layer outputs its result as input for the layer after it, and forms the dense connection topology. The dense connection ease the probblem of vanishing gradient and improve the information flow. This module is based on DenseNet264, trained on ImageNet-2012, and can predict an image of size 224*224*3.
## II.Installation
- ### 1、Environmental Dependence
- paddlepaddle >= 1.4.0
- paddlehub >= 1.0.0 | [How to install PaddleHub](../../../../docs/docs_en/get_start/installation.rst)
- ### 2、Installation
- ```shell
$ hub install densenet264_imagenet
```
- In case of any problems during installation, please refer to: [Windows_Quickstart](../../../../docs/docs_en/get_start/windows_quickstart.md) | [Linux_Quickstart](../../../../docs/docs_en/get_start/linux_quickstart.md) | [Mac_Quickstart](../../../../docs/docs_en/get_start/mac_quickstart.md)
## III.Module API Prediction
- ### 1、Command line Prediction
- ```shell
$ hub run densenet264_imagenet --input_path "/PATH/TO/IMAGE"
```
- If you want to call the Hub module through the command line, please refer to: [PaddleHub Command Line Instruction](../../../../docs/docs_ch/tutorial/cmd_usage.rst)
- ### 2、Prediction Code Example
- ```python
import paddlehub as hub
import cv2
classifier = hub.Module(name="densenet264_imagenet")
test_img_path = "/PATH/TO/IMAGE"
input_dict = {"image": [test_img_path]}
result = classifier.classification(data=input_dict)
```
- ### 3、API
- ```python
def classification(data)
```
- classification API.
- **Parameters**
- data (dict): key is "image", value is a list of image paths
- **Return**
- result(list[dict]): classication results, each element in the list is dict, key is the label name, and value is the corresponding probability
## IV.Release Note
* 1.0.0
First release
- ```shell
$ hub install densenet264_imagenet==1.0.0
```
# dpn107_imagenet
|Module Name|dpn107_imagenet|
| :--- | :---: |
|Category|image classification|
|Network|DPN|
|Dataset|ImageNet-2012|
|Fine-tuning supported or not|No|
|Module Size|335MB|
|Latest update date|-|
|Data indicators|-|
## I.Basic Information
- ### Module Introduction
- DPN(Dual Path Networks) is the champion of ILSVRC2017 in Object Localization Task. This module is based on DPN107, trained on ImageNet-2012, can predict an image of size 224*224*3.
## II.Installation
- ### 1、Environmental Dependence
- paddlepaddle >= 1.4.0
- paddlehub >= 1.0.0 | [How to install PaddleHub](../../../../docs/docs_en/get_start/installation.rst)
- ### 2、Installation
- ```shell
$ hub install dpn107_imagenet
```
- In case of any problems during installation, please refer to: [Windows_Quickstart](../../../../docs/docs_en/get_start/windows_quickstart.md) | [Linux_Quickstart](../../../../docs/docs_en/get_start/linux_quickstart.md) | [Mac_Quickstart](../../../../docs/docs_en/get_start/mac_quickstart.md)
## III.Module API Prediction
- ### 1、Command line Prediction
- ```shell
$ hub run dpn107_imagenet --input_path "/PATH/TO/IMAGE"
```
- If you want to call the Hub module through the command line, please refer to: [PaddleHub Command Line Instruction](../../../../docs/docs_ch/tutorial/cmd_usage.rst)
- ### 2、Prediction Code Example
- ```python
import paddlehub as hub
import cv2
classifier = hub.Module(name="dpn107_imagenet")
test_img_path = "/PATH/TO/IMAGE"
input_dict = {"image": [test_img_path]}
result = classifier.classification(data=input_dict)
```
- ### 3、API
- ```python
def classification(data)
```
- classification API.
- **Parameters**
- data (dict): key is "image", value is a list of image paths
- **Return**
- result(list[dict]): classication results, each element in the list is dict, key is the label name, and value is the corresponding probability
## IV.Release Note
* 1.0.0
First release
- ```shell
$ hub install dpn107_imagenet==1.0.0
```
# dpn131_imagenet
|Module Name|dpn131_imagenet|
| :--- | :---: |
|Category|image classification|
|Network|DPN|
|Dataset|ImageNet-2012|
|Fine-tuning supported or not|No|
|Module Size|306MB|
|Latest update date|-|
|Data indicators|-|
## I.Basic Information
- ### Module Introduction
- DPN(Dual Path Networks) is the champion of ILSVRC2017 in Object Localization Task. This module is based on DPN131, trained on ImageNet-2012, can predict an image of size 224*224*3.
## II.Installation
- ### 1、Environmental Dependence
- paddlepaddle >= 1.4.0
- paddlehub >= 1.0.0 | [How to install PaddleHub](../../../../docs/docs_en/get_start/installation.rst)
- ### 2、Installation
- ```shell
$ hub install dpn131_imagenet
```
- In case of any problems during installation, please refer to: [Windows_Quickstart](../../../../docs/docs_en/get_start/windows_quickstart.md) | [Linux_Quickstart](../../../../docs/docs_en/get_start/linux_quickstart.md) | [Mac_Quickstart](../../../../docs/docs_en/get_start/mac_quickstart.md)
## III.Module API Prediction
- ### 1、Command line Prediction
- ```shell
$ hub run dpn131_imagenet --input_path "/PATH/TO/IMAGE"
```
- If you want to call the Hub module through the command line, please refer to: [PaddleHub Command Line Instruction](../../../../docs/docs_ch/tutorial/cmd_usage.rst)
- ### 2、Prediction Code Example
- ```python
import paddlehub as hub
import cv2
classifier = hub.Module(name="dpn131_imagenet")
test_img_path = "/PATH/TO/IMAGE"
input_dict = {"image": [test_img_path]}
result = classifier.classification(data=input_dict)
```
- ### 3、API
- ```python
def classification(data)
```
- classification API.
- **Parameters**
- data (dict): key is "image", value is a list of image paths
- **Return**
- result(list[dict]): classication results, each element in the list is dict, key is the label name, and value is the corresponding probability
## IV.Release Note
* 1.0.0
First release
- ```shell
$ hub install dpn131_imagenet==1.0.0
```
# dpn68_imagenet
|Module Name|dpn68_imagenet|
| :--- | :---: |
|Category|image classification|
|Network|DPN|
|Dataset|ImageNet-2012|
|Fine-tuning supported or not|No|
|Module Size|50MB|
|Latest update date|-|
|Data indicators|-|
## I.Basic Information
- ### Module Introduction
- DPN(Dual Path Networks) is the champion of ILSVRC2017 in Object Localization Task. This module is based on DPN68, trained on ImageNet-2012, can predict an image of size 224*224*3.
## II.Installation
- ### 1、Environmental Dependence
- paddlepaddle >= 1.4.0
- paddlehub >= 1.0.0 | [How to install PaddleHub](../../../../docs/docs_en/get_start/installation.rst)
- ### 2、Installation
- ```shell
$ hub install dpn68_imagenet
```
- In case of any problems during installation, please refer to: [Windows_Quickstart](../../../../docs/docs_en/get_start/windows_quickstart.md) | [Linux_Quickstart](../../../../docs/docs_en/get_start/linux_quickstart.md) | [Mac_Quickstart](../../../../docs/docs_en/get_start/mac_quickstart.md)
## III.Module API Prediction
- ### 1、Command line Prediction
- ```shell
$ hub run dpn68_imagenet --input_path "/PATH/TO/IMAGE"
```
- If you want to call the Hub module through the command line, please refer to: [PaddleHub Command Line Instruction](../../../../docs/docs_ch/tutorial/cmd_usage.rst)
- ### 2、Prediction Code Example
- ```python
import paddlehub as hub
import cv2
classifier = hub.Module(name="dpn68_imagenet")
test_img_path = "/PATH/TO/IMAGE"
input_dict = {"image": [test_img_path]}
result = classifier.classification(data=input_dict)
```
- ### 3、API
- ```python
def classification(data)
```
- classification API.
- **Parameters**
- data (dict): key is "image", value is a list of image paths
- **Return**
- result(list[dict]): classication results, each element in the list is dict, key is the label name, and value is the corresponding probability
## IV.Release Note
* 1.0.0
First release
- ```shell
$ hub install dpn68_imagenet==1.0.0
```
# dpn92_imagenet
|Module Name|dpn92_imagenet|
| :--- | :---: |
|Category|image classification|
|Network|DPN|
|Dataset|ImageNet-2012|
|Fine-tuning supported or not|No|
|Module Size|146MB|
|Latest update date|-|
|Data indicators|-|
## I.Basic Information
- ### Module Introduction
- DPN(Dual Path Networks) is the champion of ILSVRC2017 in Object Localization Task. This module is based on DPN92, trained on ImageNet-2012, can predict an image of size 224*224*3.
## II.Installation
- ### 1、Environmental Dependence
- paddlepaddle >= 1.4.0
- paddlehub >= 1.0.0 | [How to install PaddleHub](../../../../docs/docs_en/get_start/installation.rst)
- ### 2、Installation
- ```shell
$ hub install dpn92_imagenet
```
- In case of any problems during installation, please refer to: [Windows_Quickstart](../../../../docs/docs_en/get_start/windows_quickstart.md) | [Linux_Quickstart](../../../../docs/docs_en/get_start/linux_quickstart.md) | [Mac_Quickstart](../../../../docs/docs_en/get_start/mac_quickstart.md)
## III.Module API Prediction
- ### 1、Command line Prediction
- ```shell
$ hub run dpn92_imagenet --input_path "/PATH/TO/IMAGE"
```
- If you want to call the Hub module through the command line, please refer to: [PaddleHub Command Line Instruction](../../../../docs/docs_ch/tutorial/cmd_usage.rst)
- ### 2、Prediction Code Example
- ```python
import paddlehub as hub
import cv2
classifier = hub.Module(name="dpn92_imagenet")
test_img_path = "/PATH/TO/IMAGE"
input_dict = {"image": [test_img_path]}
result = classifier.classification(data=input_dict)
```
- ### 3、API
- ```python
def classification(data)
```
- classification API.
- **Parameters**
- data (dict): key is "image", value is a list of image paths
- **Return**
- result(list[dict]): classication results, each element in the list is dict, key is the label name, and value is the corresponding probability
## IV.Release Note
* 1.0.0
First release
- ```shell
$ hub install dpn92_imagenet==1.0.0
```
# dpn98_imagenet
|Module Name|dpn98_imagenet|
| :--- | :---: |
|Category|image classification|
|Network|DPN|
|Dataset|ImageNet-2012|
|Fine-tuning supported or not|No|
|Module Size|238MB|
|Latest update date|-|
|Data indicators|-|
## I.Basic Information
- ### Module Introduction
- DPN(Dual Path Networks) is the champion of ILSVRC2017 in Object Localization Task. This module is based on DPN98, trained on ImageNet-2012, can predict an image of size 224*224*3.
## II.Installation
- ### 1、Environmental Dependence
- paddlepaddle >= 1.4.0
- paddlehub >= 1.0.0 | [How to install PaddleHub](../../../../docs/docs_en/get_start/installation.rst)
- ### 2、Installation
- ```shell
$ hub install dpn98_imagenet
```
- In case of any problems during installation, please refer to: [Windows_Quickstart](../../../../docs/docs_en/get_start/windows_quickstart.md) | [Linux_Quickstart](../../../../docs/docs_en/get_start/linux_quickstart.md) | [Mac_Quickstart](../../../../docs/docs_en/get_start/mac_quickstart.md)
## III.Module API Prediction
- ### 1、Command line Prediction
- ```shell
$ hub run dpn98_imagenet --input_path "/PATH/TO/IMAGE"
```
- If you want to call the Hub module through the command line, please refer to: [PaddleHub Command Line Instruction](../../../../docs/docs_ch/tutorial/cmd_usage.rst)
- ### 2、Prediction Code Example
- ```python
import paddlehub as hub
import cv2
classifier = hub.Module(name="dpn98_imagenet")
test_img_path = "/PATH/TO/IMAGE"
input_dict = {"image": [test_img_path]}
result = classifier.classification(data=input_dict)
```
- ### 3、API
- ```python
def classification(data)
```
- classification API.
- **Parameters**
- data (dict): key is "image", value is a list of image paths
- **Return**
- result(list[dict]): classication results, each element in the list is dict, key is the label name, and value is the corresponding probability
## IV.Release Note
* 1.0.0
First release
- ```shell
$ hub install dpn98_imagenet==1.0.0
```
# efficientnetb0_imagenet
|Module Name|efficientnetb0_imagenet|
| :--- | :---: |
|Category|image classification|
|Network|EfficientNet|
|Dataset|ImageNet-2012|
|Fine-tuning supported or not|No|
|Module Size|22MB|
|Latest update date|-|
|Data indicators|-|
## I.Basic Information
- ### Module Introduction
- EfficientNet is a light-weight model proposed by google, which consists of MBConv, and takes advantage of squeeze-and-excitation operation. This module is based on EfficientNetB0, trained on ImageNet-2012 dataset, and can predict an image of size 224*224*3.
## II.Installation
- ### 1、Environmental Dependence
- paddlepaddle >= 1.6.2
- paddlehub >= 1.6.0 | [How to install PaddleHub](../../../../docs/docs_en/get_start/installation.rst)
- ### 2、Installation
- ```shell
$ hub install efficientnetb0_imagenet
```
- In case of any problems during installation, please refer to: [Windows_Quickstart](../../../../docs/docs_en/get_start/windows_quickstart.md) | [Linux_Quickstart](../../../../docs/docs_en/get_start/linux_quickstart.md) | [Mac_Quickstart](../../../../docs/docs_en/get_start/mac_quickstart.md)
## III.Module API Prediction
- ### 1、Command line Prediction
- ```shell
$ hub run efficientnetb0_imagenet --input_path "/PATH/TO/IMAGE"
```
- If you want to call the Hub module through the command line, please refer to: [PaddleHub Command Line Instruction](../../../../docs/docs_ch/tutorial/cmd_usage.rst)
- ### 2、Prediction Code Example
- ```python
import paddlehub as hub
import cv2
classifier = hub.Module(name="efficientnetb0_imagenet")
result = classifier.classification(images=[cv2.imread('/PATH/TO/IMAGE')])
# or
# result = classifier.classification(paths=['/PATH/TO/IMAGE'])
```
- ### 3、API
- ```python
def classification(images=None,
paths=None,
batch_size=1,
use_gpu=False,
top_k=1):
```
- classification API.
- **Parameters**
- images (list\[numpy.ndarray\]): image data, ndarray.shape is in the format [H, W, C], BGR;
- paths (list[str]): image path;
- batch_size (int): the size of batch;
- use_gpu (bool): use GPU or not; **set the CUDA_VISIBLE_DEVICES environment variable first if you are using GPU**
- top\_k (int): return the first k results
- **Return**
- res (list\[dict\]): classication results, each element in the list is dict, key is the label name, and value is the corresponding probability
## IV.Server Deployment
- PaddleHub Serving can deploy an online service of image classification.
- ### Step 1: Start PaddleHub Serving
- Run the startup command:
- ```shell
$ hub serving start -m efficientnetb0_imagenet
```
- 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.
- ### Step 2: Send a predictive request
- With a configured server, use the following lines of code to send the prediction request and obtain the result
- ```python
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/efficientnetb0_imagenet"
r = requests.post(url=url, headers=headers, data=json.dumps(data))
# print prediction results
print(r.json()["results"])
```
## V.Release Note
* 1.0.0
First release
* 1.1.0
Improve the prediction performance and users' experience
- ```shell
$ hub install efficientnetb0_imagenet==1.1.0
```
# efficientnetb0_small_imagenet
|Module Name|efficientnetb0_small_imagenet|
| :--- | :---: |
|Category|image classification|
|Network|EfficientNet|
|Dataset|ImageNet-2012|
|Fine-tuning supported or not|No|
|Module Size|20MB|
|Latest update date|-|
|Data indicators|-|
## I.Basic Information
- ### Module Introduction
- EfficientNet is a light-weight model proposed by google, which consists of MBConv, and takes advantage of squeeze-and-excitation operation. This module is based on EfficientNetB0, trained on ImageNet-2012 dataset, and can predict an image of size 224*224*3.
## II.Installation
- ### 1、Environmental Dependence
- paddlepaddle >= 1.6.2
- paddlehub >= 1.6.0 | [How to install PaddleHub](../../../../docs/docs_en/get_start/installation.rst)
- ### 2、Installation
- ```shell
$ hub install efficientnetb0_small_imagenet
```
- In case of any problems during installation, please refer to: [Windows_Quickstart](../../../../docs/docs_en/get_start/windows_quickstart.md) | [Linux_Quickstart](../../../../docs/docs_en/get_start/linux_quickstart.md) | [Mac_Quickstart](../../../../docs/docs_en/get_start/mac_quickstart.md)
## III.Module API Prediction
- ### 1、Command line Prediction
- ```shell
$ hub run efficientnetb0_small_imagenet --input_path "/PATH/TO/IMAGE"
```
- If you want to call the Hub module through the command line, please refer to: [PaddleHub Command Line Instruction](../../../../docs/docs_ch/tutorial/cmd_usage.rst)
- ### 2、Prediction Code Example
- ```python
import paddlehub as hub
import cv2
classifier = hub.Module(name="efficientnetb0_small_imagenet")
result = classifier.classification(images=[cv2.imread('/PATH/TO/IMAGE')])
# or
# result = classifier.classification(paths=['/PATH/TO/IMAGE'])
```
- ### 3、API
- ```python
def classification(images=None,
paths=None,
batch_size=1,
use_gpu=False,
top_k=1):
```
- classification API.
- **Parameters**
- images (list\[numpy.ndarray\]): image data, ndarray.shape is in the format [H, W, C], BGR;
- paths (list[str]): image path;
- batch_size (int): the size of batch;
- use_gpu (bool): use GPU or not; **set the CUDA_VISIBLE_DEVICES environment variable first if you are using GPU**
- top\_k (int): return the first k results
- **Return**
- res (list\[dict\]): classication results, each element in the list is dict, key is the label name, and value is the corresponding probability
## IV.Server Deployment
- PaddleHub Serving can deploy an online service of image classification.
- ### Step 1: Start PaddleHub Serving
- Run the startup command:
- ```shell
$ hub serving start -m efficientnetb0_small_imagenet
```
- 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.
- ### Step 2: Send a predictive request
- With a configured server, use the following lines of code to send the prediction request and obtain the result
- ```python
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/efficientnetb0_small_imagenet"
r = requests.post(url=url, headers=headers, data=json.dumps(data))
# print prediction results
print(r.json()["results"])
```
## V.Release Note
* 1.0.0
First release
- ```shell
$ hub install efficientnetb0_small_imagenet==1.0.0
```
# efficientnetb1_imagenet
|Module Name|efficientnetb1_imagenet|
| :--- | :---: |
|Category|image classification|
|Network|EfficientNet|
|Dataset|ImageNet-2012|
|Fine-tuning supported or not|No|
|Module Size|33MB|
|Latest update date|-|
|Data indicators|-|
## I.Basic Information
- ### Module Introduction
- EfficientNet is a light-weight model proposed by google, which consists of MBConv, and takes advantage of squeeze-and-excitation operation. This module is based on EfficientNetB1, trained on ImageNet-2012 dataset, and can predict an image of size 224*224*3.
## II.Installation
- ### 1、Environmental Dependence
- paddlepaddle >= 1.6.2
- paddlehub >= 1.6.0 | [How to install PaddleHub](../../../../docs/docs_en/get_start/installation.rst)
- ### 2、Installation
- ```shell
$ hub install efficientnetb1_imagenet
```
- In case of any problems during installation, please refer to: [Windows_Quickstart](../../../../docs/docs_en/get_start/windows_quickstart.md) | [Linux_Quickstart](../../../../docs/docs_en/get_start/linux_quickstart.md) | [Mac_Quickstart](../../../../docs/docs_en/get_start/mac_quickstart.md)
## III.Module API Prediction
- ### 1、Command line Prediction
- ```shell
$ hub run efficientnetb1_imagenet --input_path "/PATH/TO/IMAGE"
```
- If you want to call the Hub module through the command line, please refer to: [PaddleHub Command Line Instruction](../../../../docs/docs_ch/tutorial/cmd_usage.rst)
- ### 2、Prediction Code Example
- ```python
import paddlehub as hub
import cv2
classifier = hub.Module(name="efficientnetb1_imagenet")
result = classifier.classification(images=[cv2.imread('/PATH/TO/IMAGE')])
# or
# result = classifier.classification(paths=['/PATH/TO/IMAGE'])
```
- ### 3、API
- ```python
def classification(images=None,
paths=None,
batch_size=1,
use_gpu=False,
top_k=1):
```
- classification API.
- **Parameters**
- images (list\[numpy.ndarray\]): image data, ndarray.shape is in the format [H, W, C], BGR;
- paths (list[str]): image path;
- batch_size (int): the size of batch;
- use_gpu (bool): use GPU or not; **set the CUDA_VISIBLE_DEVICES environment variable first if you are using GPU**
- top\_k (int): return the first k results
- **Return**
- res (list\[dict\]): classication results, each element in the list is dict, key is the label name, and value is the corresponding probability
## IV.Server Deployment
- PaddleHub Serving can deploy an online service of image classification.
- ### Step 1: Start PaddleHub Serving
- Run the startup command:
- ```shell
$ hub serving start -m efficientnetb1_imagenet
```
- 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.
- ### Step 2: Send a predictive request
- With a configured server, use the following lines of code to send the prediction request and obtain the result
- ```python
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/efficientnetb1_imagenet"
r = requests.post(url=url, headers=headers, data=json.dumps(data))
# print prediction results
print(r.json()["results"])
```
## V.Release Note
* 1.0.0
First release
* 1.1.0
Improve the prediction performance and users' experience
- ```shell
$ hub install efficientnetb1_imagenet==1.1.0
```
# efficientnetb2_imagenet
|Module Name|efficientnetb2_imagenet|
| :--- | :---: |
|Category|image classification|
|Network|EfficientNet|
|Dataset|ImageNet-2012|
|Fine-tuning supported or not|No|
|Module Size|38MB|
|Latest update date|-|
|Data indicators|-|
## I.Basic Information
- ### Module Introduction
- EfficientNet is a light-weight model proposed by google, which consists of MBConv, and takes advantage of squeeze-and-excitation operation. This module is based on EfficientNetB2, trained on ImageNet-2012 dataset, and can predict an image of size 224*224*3.
## II.Installation
- ### 1、Environmental Dependence
- paddlepaddle >= 1.6.2
- paddlehub >= 1.6.0 | [How to install PaddleHub](../../../../docs/docs_en/get_start/installation.rst)
- ### 2、Installation
- ```shell
$ hub install efficientnetb2_imagenet
```
- In case of any problems during installation, please refer to: [Windows_Quickstart](../../../../docs/docs_en/get_start/windows_quickstart.md) | [Linux_Quickstart](../../../../docs/docs_en/get_start/linux_quickstart.md) | [Mac_Quickstart](../../../../docs/docs_en/get_start/mac_quickstart.md)
## III.Module API Prediction
- ### 1、Command line Prediction
- ```shell
$ hub run efficientnetb2_imagenet --input_path "/PATH/TO/IMAGE"
```
- If you want to call the Hub module through the command line, please refer to: [PaddleHub Command Line Instruction](../../../../docs/docs_ch/tutorial/cmd_usage.rst)
- ### 2、Prediction Code Example
- ```python
import paddlehub as hub
import cv2
classifier = hub.Module(name="efficientnetb2_imagenet")
result = classifier.classification(images=[cv2.imread('/PATH/TO/IMAGE')])
# or
# result = classifier.classification(paths=['/PATH/TO/IMAGE'])
```
- ### 3、API
- ```python
def classification(images=None,
paths=None,
batch_size=1,
use_gpu=False,
top_k=1):
```
- classification API.
- **Parameters**
- images (list\[numpy.ndarray\]): image data, ndarray.shape is in the format [H, W, C], BGR;
- paths (list[str]): image path;
- batch_size (int): the size of batch;
- use_gpu (bool): use GPU or not; **set the CUDA_VISIBLE_DEVICES environment variable first if you are using GPU**
- top\_k (int): return the first k results
- **Return**
- res (list\[dict\]): classication results, each element in the list is dict, key is the label name, and value is the corresponding probability
## IV.Server Deployment
- PaddleHub Serving can deploy an online service of image classification.
- ### Step 1: Start PaddleHub Serving
- Run the startup command:
- ```shell
$ hub serving start -m efficientnetb2_imagenet
```
- 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.
- ### Step 2: Send a predictive request
- With a configured server, use the following lines of code to send the prediction request and obtain the result
- ```python
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/efficientnetb2_imagenet"
r = requests.post(url=url, headers=headers, data=json.dumps(data))
# print prediction results
print(r.json()["results"])
```
## V.Release Note
* 1.0.0
First release
* 1.1.0
Improve the prediction performance and users' experience
- ```shell
$ hub install efficientnetb2_imagenet==1.1.0
```
# efficientnetb3_imagenet
|Module Name|efficientnetb3_imagenet|
| :--- | :---: |
|Category|image classification|
|Network|EfficientNet|
|Dataset|ImageNet-2012|
|Fine-tuning supported or not|No|
|Module Size|51MB|
|Latest update date|-|
|Data indicators|-|
## I.Basic Information
- ### Module Introduction
- EfficientNet is a light-weight model proposed by google, which consists of MBConv, and takes advantage of squeeze-and-excitation operation. This module is based on EfficientNetB3, trained on ImageNet-2012 dataset, and can predict an image of size 224*224*3.
## II.Installation
- ### 1、Environmental Dependence
- paddlepaddle >= 1.6.2
- paddlehub >= 1.6.0 | [How to install PaddleHub](../../../../docs/docs_en/get_start/installation.rst)
- ### 2、Installation
- ```shell
$ hub install efficientnetb3_imagenet
```
- In case of any problems during installation, please refer to: [Windows_Quickstart](../../../../docs/docs_en/get_start/windows_quickstart.md) | [Linux_Quickstart](../../../../docs/docs_en/get_start/linux_quickstart.md) | [Mac_Quickstart](../../../../docs/docs_en/get_start/mac_quickstart.md)
## III.Module API Prediction
- ### 1、Command line Prediction
- ```shell
$ hub run efficientnetb3_imagenet --input_path "/PATH/TO/IMAGE"
```
- If you want to call the Hub module through the command line, please refer to: [PaddleHub Command Line Instruction](../../../../docs/docs_ch/tutorial/cmd_usage.rst)
- ### 2、Prediction Code Example
- ```python
import paddlehub as hub
import cv2
classifier = hub.Module(name="efficientnetb3_imagenet")
result = classifier.classification(images=[cv2.imread('/PATH/TO/IMAGE')])
# or
# result = classifier.classification(paths=['/PATH/TO/IMAGE'])
```
- ### 3、API
- ```python
def classification(images=None,
paths=None,
batch_size=1,
use_gpu=False,
top_k=1):
```
- classification API.
- **Parameters**
- images (list\[numpy.ndarray\]): image data, ndarray.shape is in the format [H, W, C], BGR;
- paths (list[str]): image path;
- batch_size (int): the size of batch;
- use_gpu (bool): use GPU or not; **set the CUDA_VISIBLE_DEVICES environment variable first if you are using GPU**
- top\_k (int): return the first k results
- **Return**
- res (list\[dict\]): classication results, each element in the list is dict, key is the label name, and value is the corresponding probability
## IV.Server Deployment
- PaddleHub Serving can deploy an online service of image classification.
- ### Step 1: Start PaddleHub Serving
- Run the startup command:
- ```shell
$ hub serving start -m efficientnetb3_imagenet
```
- 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.
- ### Step 2: Send a predictive request
- With a configured server, use the following lines of code to send the prediction request and obtain the result
- ```python
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/efficientnetb3_imagenet"
r = requests.post(url=url, headers=headers, data=json.dumps(data))
# print prediction results
print(r.json()["results"])
```
## V.Release Note
* 1.0.0
First release
* 1.1.0
Improve the prediction performance and users' experience
- ```shell
$ hub install efficientnetb3_imagenet==1.1.0
```
# efficientnetb4_imagenet
|Module Name|efficientnetb4_imagenet|
| :--- | :---: |
|Category|image classification|
|Network|EfficientNet|
|Dataset|ImageNet-2012|
|Fine-tuning supported or not|No|
|Module Size|77MB|
|Latest update date|-|
|Data indicators|-|
## I.Basic Information
- ### Module Introduction
- EfficientNet is a light-weight model proposed by google, which consists of MBConv, and takes advantage of squeeze-and-excitation operation. This module is based on EfficientNetB4, trained on ImageNet-2012 dataset, and can predict an image of size 224*224*3.
## II.Installation
- ### 1、Environmental Dependence
- paddlepaddle >= 1.6.2
- paddlehub >= 1.6.0 | [How to install PaddleHub](../../../../docs/docs_en/get_start/installation.rst)
- ### 2、Installation
- ```shell
$ hub install efficientnetb4_imagenet
```
- In case of any problems during installation, please refer to: [Windows_Quickstart](../../../../docs/docs_en/get_start/windows_quickstart.md) | [Linux_Quickstart](../../../../docs/docs_en/get_start/linux_quickstart.md) | [Mac_Quickstart](../../../../docs/docs_en/get_start/mac_quickstart.md)
## III.Module API Prediction
- ### 1、Command line Prediction
- ```shell
$ hub run efficientnetb4_imagenet --input_path "/PATH/TO/IMAGE"
```
- If you want to call the Hub module through the command line, please refer to: [PaddleHub Command Line Instruction](../../../../docs/docs_ch/tutorial/cmd_usage.rst)
- ### 2、Prediction Code Example
- ```python
import paddlehub as hub
import cv2
classifier = hub.Module(name="efficientnetb4_imagenet")
result = classifier.classification(images=[cv2.imread('/PATH/TO/IMAGE')])
# or
# result = classifier.classification(paths=['/PATH/TO/IMAGE'])
```
- ### 3、API
- ```python
def classification(images=None,
paths=None,
batch_size=1,
use_gpu=False,
top_k=1):
```
- classification API.
- **Parameters**
- images (list\[numpy.ndarray\]): image data, ndarray.shape is in the format [H, W, C], BGR;
- paths (list[str]): image path;
- batch_size (int): the size of batch;
- use_gpu (bool): use GPU or not; **set the CUDA_VISIBLE_DEVICES environment variable first if you are using GPU**
- top\_k (int): return the first k results
- **Return**
- res (list\[dict\]): classication results, each element in the list is dict, key is the label name, and value is the corresponding probability
## IV.Server Deployment
- PaddleHub Serving can deploy an online service of image classification.
- ### Step 1: Start PaddleHub Serving
- Run the startup command:
- ```shell
$ hub serving start -m efficientnetb4_imagenet
```
- 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.
- ### Step 2: Send a predictive request
- With a configured server, use the following lines of code to send the prediction request and obtain the result
- ```python
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/efficientnetb4_imagenet"
r = requests.post(url=url, headers=headers, data=json.dumps(data))
# print prediction results
print(r.json()["results"])
```
## V.Release Note
* 1.0.0
First release
* 1.1.0
Improve the prediction performance and users' experience
- ```shell
$ hub install efficientnetb4_imagenet==1.1.0
```
# efficientnetb5_imagenet
|Module Name|efficientnetb5_imagenet|
| :--- | :---: |
|Category|image classification|
|Network|EfficientNet|
|Dataset|ImageNet-2012|
|Fine-tuning supported or not|No|
|Module Size|121MB|
|Latest update date|-|
|Data indicators|-|
## I.Basic Information
- ### Module Introduction
- EfficientNet is a light-weight model proposed by google, which consists of MBConv, and takes advantage of squeeze-and-excitation operation. This module is based on EfficientNetB5, trained on ImageNet-2012 dataset, and can predict an image of size 224*224*3.
## II.Installation
- ### 1、Environmental Dependence
- paddlepaddle >= 1.6.2
- paddlehub >= 1.6.0 | [How to install PaddleHub](../../../../docs/docs_en/get_start/installation.rst)
- ### 2、Installation
- ```shell
$ hub install efficientnetb5_imagenet
```
- In case of any problems during installation, please refer to: [Windows_Quickstart](../../../../docs/docs_en/get_start/windows_quickstart.md) | [Linux_Quickstart](../../../../docs/docs_en/get_start/linux_quickstart.md) | [Mac_Quickstart](../../../../docs/docs_en/get_start/mac_quickstart.md)
## III.Module API Prediction
- ### 1、Command line Prediction
- ```shell
$ hub run efficientnetb5_imagenet --input_path "/PATH/TO/IMAGE"
```
- If you want to call the Hub module through the command line, please refer to: [PaddleHub Command Line Instruction](../../../../docs/docs_ch/tutorial/cmd_usage.rst)
- ### 2、Prediction Code Example
- ```python
import paddlehub as hub
import cv2
classifier = hub.Module(name="efficientnetb5_imagenet")
result = classifier.classification(images=[cv2.imread('/PATH/TO/IMAGE')])
# or
# result = classifier.classification(paths=['/PATH/TO/IMAGE'])
```
- ### 3、API
- ```python
def classification(images=None,
paths=None,
batch_size=1,
use_gpu=False,
top_k=1):
```
- classification API.
- **Parameters**
- images (list\[numpy.ndarray\]): image data, ndarray.shape is in the format [H, W, C], BGR;
- paths (list[str]): image path;
- batch_size (int): the size of batch;
- use_gpu (bool): use GPU or not; **set the CUDA_VISIBLE_DEVICES environment variable first if you are using GPU**
- top\_k (int): return the first k results
- **Return**
- res (list\[dict\]): classication results, each element in the list is dict, key is the label name, and value is the corresponding probability
## IV.Server Deployment
- PaddleHub Serving can deploy an online service of image classification.
- ### Step 1: Start PaddleHub Serving
- Run the startup command:
- ```shell
$ hub serving start -m efficientnetb5_imagenet
```
- 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.
- ### Step 2: Send a predictive request
- With a configured server, use the following lines of code to send the prediction request and obtain the result
- ```python
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/efficientnetb5_imagenet"
r = requests.post(url=url, headers=headers, data=json.dumps(data))
# print prediction results
print(r.json()["results"])
```
## V.Release Note
* 1.0.0
First release
* 1.1.0
Improve the prediction performance and users' experience
- ```shell
$ hub install efficientnetb5_imagenet==1.1.0
```
# efficientnetb6_imagenet
|Module Name|efficientnetb6_imagenet|
| :--- | :---: |
|Category|image classification|
|Network|EfficientNet|
|Dataset|ImageNet-2012|
|Fine-tuning supported or not|No|
|Module Size|170MB|
|Latest update date|-|
|Data indicators|-|
## I.Basic Information
- ### Module Introduction
- EfficientNet is a light-weight model proposed by google, which consists of MBConv, and takes advantage of squeeze-and-excitation operation. This module is based on EfficientNetB6, trained on ImageNet-2012 dataset, and can predict an image of size 224*224*3.
## II.Installation
- ### 1、Environmental Dependence
- paddlepaddle >= 1.4.0
- paddlehub >= 1.0.0 | [How to install PaddleHub](../../../../docs/docs_en/get_start/installation.rst)
- ### 2、Installation
- ```shell
$ hub install efficientnetb6_imagenet
```
- In case of any problems during installation, please refer to: [Windows_Quickstart](../../../../docs/docs_en/get_start/windows_quickstart.md) | [Linux_Quickstart](../../../../docs/docs_en/get_start/linux_quickstart.md) | [Mac_Quickstart](../../../../docs/docs_en/get_start/mac_quickstart.md)
## III.Module API Prediction
- ### 1、Command line Prediction
- ```shell
$ hub run efficientnetb6_imagenet --input_path "/PATH/TO/IMAGE"
```
- If you want to call the Hub module through the command line, please refer to: [PaddleHub Command Line Instruction](../../../../docs/docs_ch/tutorial/cmd_usage.rst)
- ### 2、Prediction Code Example
- ```python
import paddlehub as hub
import cv2
classifier = hub.Module(name="efficientnetb6_imagenet")
result = classifier.classification(images=[cv2.imread('/PATH/TO/IMAGE')])
# or
# result = classifier.classification(paths=['/PATH/TO/IMAGE'])
```
- ### 3、API
- ```python
def classification(images=None,
paths=None,
batch_size=1,
use_gpu=False,
top_k=1):
```
- classification API.
- **Parameters**
- images (list\[numpy.ndarray\]): image data, ndarray.shape is in the format [H, W, C], BGR;
- paths (list[str]): image path;
- batch_size (int): the size of batch;
- use_gpu (bool): use GPU or not; **set the CUDA_VISIBLE_DEVICES environment variable first if you are using GPU**
- top\_k (int): return the first k results
- **Return**
- res (list\[dict\]): classication results, each element in the list is dict, key is the label name, and value is the corresponding probability
## IV.Server Deployment
- PaddleHub Serving can deploy an online service of image classification.
- ### Step 1: Start PaddleHub Serving
- Run the startup command:
- ```shell
$ hub serving start -m efficientnetb6_imagenet
```
- 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.
- ### Step 2: Send a predictive request
- With a configured server, use the following lines of code to send the prediction request and obtain the result
- ```python
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/efficientnetb6_imagenet"
r = requests.post(url=url, headers=headers, data=json.dumps(data))
# print prediction results
print(r.json()["results"])
```
## V.Release Note
* 1.0.0
First release
* 1.1.0
Improve the prediction performance and users' experience
- ```shell
$ hub install efficientnetb6_imagenet==1.1.0
```
# efficientnetb7_imagenet
|Module Name|efficientnetb7_imagenet|
| :--- | :---: |
|Category|image classification|
|Network|EfficientNet|
|Dataset|ImageNet-2012|
|Fine-tuning supported or not|No|
|Module Size|260MB|
|Latest update date|-|
|Data indicators|-|
## I.Basic Information
- ### Module Introduction
- EfficientNet is a light-weight model proposed by google, which consists of MBConv, and takes advantage of squeeze-and-excitation operation. This module is based on EfficientNetB7, trained on ImageNet-2012 dataset, and can predict an image of size 224*224*3.
## II.Installation
- ### 1、Environmental Dependence
- paddlepaddle >= 1.6.2
- paddlehub >= 1.6.0 | [How to install PaddleHub](../../../../docs/docs_en/get_start/installation.rst)
- ### 2、Installation
- ```shell
$ hub install efficientnetb7_imagenet
```
- In case of any problems during installation, please refer to: [Windows_Quickstart](../../../../docs/docs_en/get_start/windows_quickstart.md) | [Linux_Quickstart](../../../../docs/docs_en/get_start/linux_quickstart.md) | [Mac_Quickstart](../../../../docs/docs_en/get_start/mac_quickstart.md)
## III.Module API Prediction
- ### 1、Command line Prediction
- ```shell
$ hub run efficientnetb7_imagenet --input_path "/PATH/TO/IMAGE"
```
- If you want to call the Hub module through the command line, please refer to: [PaddleHub Command Line Instruction](../../../../docs/docs_ch/tutorial/cmd_usage.rst)
- ### 2、Prediction Code Example
- ```python
import paddlehub as hub
import cv2
classifier = hub.Module(name="efficientnetb7_imagenet")
result = classifier.classification(images=[cv2.imread('/PATH/TO/IMAGE')])
# or
# result = classifier.classification(paths=['/PATH/TO/IMAGE'])
```
- ### 3、API
- ```python
def classification(images=None,
paths=None,
batch_size=1,
use_gpu=False,
top_k=1):
```
- classification API.
- **Parameters**
- images (list\[numpy.ndarray\]): image data, ndarray.shape is in the format [H, W, C], BGR;
- paths (list[str]): image path;
- batch_size (int): the size of batch;
- use_gpu (bool): use GPU or not; **set the CUDA_VISIBLE_DEVICES environment variable first if you are using GPU**
- top\_k (int): return the first k results
- **Return**
- res (list\[dict\]): classication results, each element in the list is dict, key is the label name, and value is the corresponding probability
## IV.Server Deployment
- PaddleHub Serving can deploy an online service of image classification.
- ### Step 1: Start PaddleHub Serving
- Run the startup command:
- ```shell
$ hub serving start -m efficientnetb7_imagenet
```
- 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.
- ### Step 2: Send a predictive request
- With a configured server, use the following lines of code to send the prediction request and obtain the result
- ```python
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/efficientnetb7_imagenet"
r = requests.post(url=url, headers=headers, data=json.dumps(data))
# print prediction results
print(r.json()["results"])
```
## V.Release Note
* 1.0.0
First release
* 1.1.0
Improve the prediction performance and users' experience
- ```shell
$ hub install efficientnetb7_imagenet==1.1.0
```
# fix_resnext101_32x48d_wsl_imagenet
|Module Name|fix_resnext101_32x48d_wsl_imagenet|
| :--- | :---: |
|Category|image classification|
|Network|ResNeXt|
|Dataset|ImageNet-2012|
|Fine-tuning supported or not|No|
|Module Size|3.1GB|
|Latest update date|-|
|Data indicators|-|
## I.Basic Information
- ### Module Introduction
- ResNeXt is proposed by UC San Diego and Facebook AI Research in 2017. This module is based on ResNeXt model. It is weak-supervised trained on billions of socail images, finetuned on ImageNet-2012 dataset, and can predict an image of size 224*224*3.
## II.Installation
- ### 1、Environmental Dependence
- paddlepaddle >= 1.6.2
- paddlehub >= 1.6.0 | [How to install PaddleHub](../../../../docs/docs_en/get_start/installation.rst)
- ### 2、Installation
- ```shell
$ hub install fix_resnext101_32x48d_wsl_imagenet
```
- In case of any problems during installation, please refer to: [Windows_Quickstart](../../../../docs/docs_en/get_start/windows_quickstart.md) | [Linux_Quickstart](../../../../docs/docs_en/get_start/linux_quickstart.md) | [Mac_Quickstart](../../../../docs/docs_en/get_start/mac_quickstart.md)
## III.Module API Prediction
- ### 1、Command line Prediction
- ```shell
$ hub run fix_resnext101_32x48d_wsl_imagenet --input_path "/PATH/TO/IMAGE"
```
- If you want to call the Hub module through the command line, please refer to: [PaddleHub Command Line Instruction](../../../../docs/docs_ch/tutorial/cmd_usage.rst)
- ### 2、Prediction Code Example
- ```python
import paddlehub as hub
import cv2
classifier = hub.Module(name="fix_resnext101_32x48d_wsl_imagenet")
result = classifier.classification(images=[cv2.imread('/PATH/TO/IMAGE')])
# or
# result = classifier.classification(paths=['/PATH/TO/IMAGE'])
```
- ### 3、API
- ```python
def classification(images=None,
paths=None,
batch_size=1,
use_gpu=False,
top_k=1):
```
- classification API.
- **Parameters**
- images (list\[numpy.ndarray\]): image data, ndarray.shape is in the format [H, W, C], BGR;
- paths (list[str]): image path;
- batch_size (int): the size of batch;
- use_gpu (bool): use GPU or not; **set the CUDA_VISIBLE_DEVICES environment variable first if you are using GPU**
- top\_k (int): return the first k results
- **Return**
- res (list\[dict\]): classication results, each element in the list is dict, key is the label name, and value is the corresponding probability
## IV.Server Deployment
- PaddleHub Serving can deploy an online service of image classification.
- ### Step 1: Start PaddleHub Serving
- Run the startup command:
- ```shell
$ hub serving start -m fix_resnext101_32x48d_wsl_imagenet
```
- 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.
- ### Step 2: Send a predictive request
- With a configured server, use the following lines of code to send the prediction request and obtain the result
- ```python
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/fix_resnext101_32x48d_wsl_imagenet"
r = requests.post(url=url, headers=headers, data=json.dumps(data))
# print prediction results
print(r.json()["results"])
```
## V.Release Note
* 1.0.0
First release
- ```shell
$ hub install fix_resnext101_32x48d_wsl_imagenet==1.0.0
```
......@@ -23,8 +23,6 @@
- ### 1、环境依赖
- paddlepaddle >= 2.0.0
- paddlehub >= 2.0.0 | [如何安装paddlehub](../../../../docs/docs_ch/get_start/installation.rst)
- paddlex >= 1.3.7
......
# food_classification
|Module Name|food_classification|
| :--- | :---: |
|Category|image classification|
|Network|ResNet50_vd_ssld|
|Dataset|Food Dataset|
|Fine-tuning supported or not|No|
|Module Size|91MB|
|Latest update date|-|
|Data indicators|-|
## I.Basic Information
- ### Module Introduction
- This module can be used for food classification.
## II.Installation
- ### 1、Environmental Dependence
- paddlehub >= 2.0.0 | [How to install PaddleHub](../../../../docs/docs_en/get_start/installation.rst)
- paddlex >= 1.3.7
- ### 2、Installation
- ```shell
$ hub install food_classification
```
- In case of any problems during installation, please refer to: [Windows_Quickstart](../../../../docs/docs_en/get_start/windows_quickstart.md) | [Linux_Quickstart](../../../../docs/docs_en/get_start/linux_quickstart.md) | [Mac_Quickstart](../../../../docs/docs_en/get_start/mac_quickstart.md)
## III.Module API Prediction
- ### 1、Command line Prediction
- ```shell
$ hub run food_classification --input_path /PATH/TO/IMAGE
```
- If you want to call the Hub module through the command line, please refer to: [PaddleHub Command Line Instruction](../../../../docs/docs_ch/tutorial/cmd_usage.rst)
- ### 2、Prediction Code Example
- ```python
import paddlehub as hub
import cv2
classifier = hub.Module(name="food_classification")
images = [cv2.imread('/PATH/TO/IMAGE')]
results = classifier.predict(images=images)
for result in results:
print(result)
```
- ### 3、API
- ```python
def predict(images)
```
- classification API.
- **Parameters**
- images (list\[numpy.ndarray\]): image data, ndarray.shape is in the format [H, W, C], BGR;
- **Return**
- result(list[dict]): classication results, each element in the list is dict, key is the label name, and value is the corresponding probability
- category_id (int): category id;
- category(str): category name;
- score(float): probability
## IV.Release Note
* 1.0.0
First release
- ```shell
$ hub install food_classification==1.0.0
```
# googlenet_imagenet
|Module Name|googlenet_imagenet|
| :--- | :---: |
|Category|image classification|
|Network|GoogleNet|
|Dataset|ImageNet-2012|
|Fine-tuning supported or not|No|
|Module Size|28MB|
|Latest update date|-|
|Data indicators|-|
## I.Basic Information
- ### Module Introduction
- GoogleNet was proposed by Christian Szegedy in 2014 and gained the champion of ILSVRC 2014. This module is based on GoogleNet, trained on ImageNet-2012, and can predict an image of size 224*224*3.
## II.Installation
- ### 1、Environmental Dependence
- paddlepaddle >= 1.4.0
- paddlehub >= 1.0.0 | [How to install PaddleHub](../../../../docs/docs_en/get_start/installation.rst)
- ### 2、Installation
- ```shell
$ hub install googlenet_imagenet
```
- In case of any problems during installation, please refer to: [Windows_Quickstart](../../../../docs/docs_en/get_start/windows_quickstart.md) | [Linux_Quickstart](../../../../docs/docs_en/get_start/linux_quickstart.md) | [Mac_Quickstart](../../../../docs/docs_en/get_start/mac_quickstart.md)
## III.Module API Prediction
- ### 1、Command line Prediction
- ```shell
$ hub run googlenet_imagenet --input_path "/PATH/TO/IMAGE"
```
- If you want to call the Hub module through the command line, please refer to: [PaddleHub Command Line Instruction](../../../../docs/docs_ch/tutorial/cmd_usage.rst)
- ### 2、Prediction Code Example
- ```python
import paddlehub as hub
import cv2
classifier = hub.Module(name="googlenet_imagenet")
test_img_path = "/PATH/TO/IMAGE"
input_dict = {"image": [test_img_path]}
result = classifier.classification(data=input_dict)
```
- ### 3、API
- ```python
def classification(data)
```
- classification API.
- **Parameters**
- data (dict): key is "image", value is a list of image paths
- **Return**
- result(list[dict]): classication results, each element in the list is dict, key is the label name, and value is the corresponding probability
## IV.Release Note
* 1.0.0
First release
- ```shell
$ hub install googlenet_imagenet==1.0.0
```
# inception_v4_imagenet
|Module Name|inception_v4_imagenet|
| :--- | :---: |
|Category|image classification|
|Network|Inception_V4|
|Dataset|ImageNet-2012|
|Fine-tuning supported or not|No|
|Module Size|167MB|
|Latest update date|-|
|Data indicators|-|
## I.Basic Information
- ### Module Introduction
- Inception structure is first introduced in GoogLeNet, so GoogLeNet is named Inception-v1. Inception-v4 is an improvement on it, which takas advantage of sereral useful strategies such as batch normalization, residual learning. This module is based on Inception-v4, trained on ImageNet-2012, and can predict an image of size 224*224*3.
## II.Installation
- ### 1、Environmental Dependence
- paddlepaddle >= 1.4.0
- paddlehub >= 1.0.0 | [How to install PaddleHub](../../../../docs/docs_en/get_start/installation.rst)
- ### 2、Installation
- ```shell
$ hub install inception_v4_imagenet
```
- In case of any problems during installation, please refer to: [Windows_Quickstart](../../../../docs/docs_en/get_start/windows_quickstart.md) | [Linux_Quickstart](../../../../docs/docs_en/get_start/linux_quickstart.md) | [Mac_Quickstart](../../../../docs/docs_en/get_start/mac_quickstart.md)
## III.Module API Prediction
- ### 1、Command line Prediction
- ```shell
$ hub run inception_v4_imagenet --input_path "/PATH/TO/IMAGE"
```
- If you want to call the Hub module through the command line, please refer to: [PaddleHub Command Line Instruction](../../../../docs/docs_ch/tutorial/cmd_usage.rst)
- ### 2、Prediction Code Example
- ```python
import paddlehub as hub
import cv2
classifier = hub.Module(name="inception_v4_imagenet")
test_img_path = "/PATH/TO/IMAGE"
input_dict = {"image": [test_img_path]}
result = classifier.classification(data=input_dict)
```
- ### 3、API
- ```python
def classification(data)
```
- classification API.
- **Parameters**
- data (dict): key is "image", value is a list of image paths
- **Return**
- result(list[dict]): classication results, each element in the list is dict, key is the label name, and value is the corresponding probability
## IV.Release Note
* 1.0.0
First release
- ```shell
$ hub install inception_v4_imagenet==1.0.0
```
......@@ -72,6 +72,7 @@
## IV. Release Note
- 1.0.0
......@@ -81,7 +82,7 @@
- 1.0.1
Fix encoding problem in python2
- ```shell
$ hub install resnet_v2_50_imagenet==1.0.1
```
......@@ -18,6 +18,7 @@
- ### 模型介绍
- 使用PaddleHub的SpinalNet预训练模型进行宝石识别或finetune并完成宝石的预测任务。
## 二、安装
- ### 1、环境依赖
......
此差异已折叠。
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册