提交 feab570d 编写于 作者: H HydrogenSulfate

merge develop & zoom QRCode for ShiTu APP demo

......@@ -25,17 +25,16 @@ PaddleClas supports Python wheel package for prediction. At present, PaddleClas
## 1. Installation
* installing from pypi
* **[Recommended]** Installing from PyPI:
```bash
pip3 install paddleclas==2.2.1
pip3 install paddleclas
```
* build own whl package and install
* Please build and install locally if you need to use the develop branch of PaddleClas to experience the latest functions, or need to redevelop based on PaddleClas. The command is as follows:
```bash
python3 setup.py bdist_wheel
pip3 install dist/*
python3 setup.py install
```
<a name="2"></a>
......
......@@ -25,14 +25,14 @@ git clone https://gitee.com/paddlepaddle/PaddleClas.git -b develop
## 2. Install PaddleClas and requirements
It is recommanded that installing from PyPI:
* **[Recommended]** Installing from PyPI:
```shell
pip install paddleclas
```
PaddleClas dependencies are listed in file `requirements.txt`, you can use the following command to install the dependencies.
* Please build and install locally if you need to use the develop branch of PaddleClas to experience the latest functions, or need to redevelop based on PaddleClas. The command is as follows:
```
pip install --upgrade -r requirements.txt -i https://mirror.baidu.com/pypi/simple
```shell
python setup.py install
```
......@@ -94,7 +94,7 @@ MobileNetV1
## 3. 方法说明
PaddleClas 提供的 backbone 网络均基于图像分类数据集训练得到,因此网络的尾部带有用于分类的全连接层,而在特定任务场景下,需要去掉分类的全连接层。在部分下游任务中,例如目标检测场景,需要获取到网络中间层的输出结果,也可能需要对网络的中间层进行修改,因此 `TheseusLayer` 提供了 3 个接口函数用于实现不同的修改功能。
PaddleClas 提供的 backbone 网络均基于图像分类数据集训练得到,因此网络的尾部带有用于分类的全连接层,而在特定任务场景下,需要去掉分类的全连接层。在部分下游任务中,例如目标检测场景,需要获取到网络中间层的输出结果,也可能需要对网络的中间层进行修改,因此 `TheseusLayer` 提供了 3 个接口函数用于实现不同的修改功能。下面基于 PaddleClas whl 进行说明,首先需要安装 PaddleClas:`pip install paddleclas`
<a name="3.1"></a>
......@@ -122,7 +122,6 @@ def stop_after(self, stop_layer_name: str) -> bool:
`MobileNetV1` 网络为例,参数 `stop_layer_name``"blocks[0].depthwise_conv.conv"`,具体效果可以参考下方代码案例进行尝试。
```python
# cd <root-path-to-PaddleClas> or pip install paddleclas to import paddleclas
import paddleclas
net = paddleclas.MobileNetV1()
......@@ -168,7 +167,6 @@ def update_res(
import numpy as np
import paddle
# cd <root-path-to-PaddleClas> or pip install paddleclas to import paddleclas
import paddleclas
np_input = np.zeros((1, 3, 224, 224))
......@@ -241,7 +239,6 @@ def upgrade_sublayer(self,
```python
from paddle import nn
# cd <root-path-to-PaddleClas> or pip install paddleclas to import paddleclas
import paddleclas
# 该函数必须有两个形参
......
......@@ -23,17 +23,16 @@ PaddleClas 支持 Python Whl 包方式进行预测,目前 Whl 包方式仅支
<a name="1"></a>
## 1. 安装 paddleclas
* pip 安装
* **[推荐]** 直接 pip 安装:
```bash
pip3 install paddleclas==2.2.1
pip3 install paddleclas
```
* 本地构建并安装
* 如需使用 PaddleClas develop 分支体验最新功能,或是需要基于 PaddleClas 进行二次开发,请本地构建安装:
```bash
python3 setup.py bdist_wheel
pip3 install dist/*
python3 setup.py install
```
<a name="2"></a>
......
......@@ -98,16 +98,16 @@ git clone https://gitee.com/paddlepaddle/PaddleClas.git -b release/2.4
### 1.3 安装 PaddleClas 及其 Python 依赖库
建议直接从 PyPI 安装 PaddleClas:
* **[建议]** 直接安装 PaddleClas:
```shell
pip install paddleclas
```
PaddleClas 的 Python 依赖库在 `requirements.txt` 中给出,可通过如下命令安装
* 如需使用 PaddleClas develop 分支体验最新功能,或是需要基于 PaddleClas 进行二次开发,请本地构建安装,命令如下
```shell
pip install --upgrade -r requirements.txt -i https://mirror.baidu.com/pypi/simple
python setup.py install
```
<a name='2'></a>
......
......@@ -42,9 +42,10 @@
### 1.1 安装 PP-ShiTu android demo
可以通过扫描二维码或者[点击链接](https://paddle-imagenet-models-name.bj.bcebos.com/demos/PP-ShiTu.apk)下载并安装APP
**注:** 华为鸿蒙OS 3.0的系统可能会出现无法调用摄像头的情况,建议更换低版本系统或者使用其它安卓机型进行快速体验。
<img src="../../images/quick_start/android_demo/PPShiTu_qcode.png" height="250" width="250" />
<div align=center><img src="../../images/quick_start/android_demo/PPShiTu_qcode.png" height="400" width="400"/></div>
<a name="功能体验"></a>
......
......@@ -117,9 +117,9 @@ class TheseusLayer(nn.Layer):
layer_list = parse_pattern_str(pattern=pattern, parent_layer=self)
if not layer_list:
continue
sub_layer_parent = layer_list[-2]["layer"] if len(
layer_list) > 1 else self
sub_layer = layer_list[-1]["layer"]
sub_layer_name = layer_list[-1]["name"]
sub_layer_index_list = layer_list[-1]["index_list"]
......@@ -214,14 +214,15 @@ def save_sub_res_hook(layer, input, output):
layer.res_dict[layer.res_name] = output
def set_identity(parent_layer: nn.Layer, layer_name: str,
index_list: str=None) -> bool:
"""set the layer specified by layer_name and index_list to Indentity.
def set_identity(parent_layer: nn.Layer,
layer_name: str,
layer_index_list: str=None) -> bool:
"""set the layer specified by layer_name and layer_index_list to Indentity.
Args:
parent_layer (nn.Layer): The parent layer of target layer specified by layer_name and index_list.
parent_layer (nn.Layer): The parent layer of target layer specified by layer_name and layer_index_list.
layer_name (str): The name of target layer to be set to Indentity.
index_list (str, optional): The index of target layer to be set to Indentity in parent_layer. Defaults to None.
layer_index_list (str, optional): The index of target layer to be set to Indentity in parent_layer. Defaults to None.
Returns:
bool: True if successfully, False otherwise.
......@@ -235,16 +236,19 @@ def set_identity(parent_layer: nn.Layer, layer_name: str,
if sub_layer_name == layer_name:
stop_after = True
if index_list and stop_after:
stop_after = False
for sub_layer_index in parent_layer._sub_layers[
layer_name]._sub_layers:
if stop_after:
parent_layer._sub_layers[layer_name][
sub_layer_index] = Identity()
continue
if layer_index == sub_layer_index:
stop_after = True
if layer_index_list and stop_after:
layer_container = parent_layer._sub_layers[layer_name]
for num, layer_index in enumerate(layer_index_list):
stop_after = False
for i in range(num):
layer_container = layer_container[layer_index_list[i]]
for sub_layer_index in layer_container._sub_layers:
if stop_after:
parent_layer._sub_layers[layer_name][
sub_layer_index] = Identity()
continue
if layer_index == sub_layer_index:
stop_after = True
return stop_after
......@@ -307,4 +311,5 @@ def parse_pattern_str(pattern: str, parent_layer: nn.Layer) -> Union[
pattern_list = pattern_list[1:]
parent_layer = target_layer
return layer_list
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册