未验证 提交 30e35c98 编写于 作者: S SunAhong1993 提交者: GitHub

fix the bug and fix the doc (#582)

* fix the code

* fix the visit_tuple

* Update stargan.md

* Update ultra_light_fast_generic_face_detector.md

* fix the docs
上级 e1595a0c
......@@ -34,4 +34,4 @@ out =main(ipt)
> 若运行代码无误,则说明代码中有op不支持动转静,我们将会再未来支持;若报错,则说明pytorch2paddle转换出错,请提issue,我们将及时回复。
**Q5. 目前支持了哪些op的转换呢?**
A: 可详见[X2Paddle支持的op列表](./docs/inference_model_convertor/op_list.md)
A: 可详见[X2Paddle支持的op列表](op_list.md)
......@@ -16,7 +16,7 @@
| VGG16 | [code](https://github.com/tensorflow/models/tree/master/research/slim/nets) |
| ResNet_V1_101 | [code](https://github.com/tensorflow/models/tree/master/research/slim/nets) |
| ResNet_V2_101 | [code](https://github.com/tensorflow/models/tree/master/research/slim/nets) |
| UNet | [code1](https://github.com/jakeret/tf_unet )/[code2](https://github.com/lyatdawn/Unet-Tensorflow) |
| UNet | [code1](https://github.com/jakeret/tf_unet)/[code2](https://github.com/lyatdawn/Unet-Tensorflow) |
| MTCNN | [code](https://github.com/AITTSMD/MTCNN-Tensorflow) |
| YOLO-V3| [code](https://github.com/YunYang1994/tensorflow-yolov3) |
| FALSR | [code](https://github.com/xiaomi-automl/FALSR) |
......@@ -49,7 +49,7 @@
## ONNX预测模型
**注:** 部分模型来源于PyTorch,PyTorch的转换可参考[pytorch_to_onnx.md](pytorch_to_onnx.md)
**注:** 部分模型来源于PyTorch,PyTorch的转换可参考[pytorch_to_onnx.md](../inference_model_convertor/pytorch2onnx.md)
| 模型 | 来源 | operator version|备注|
|-------|--------|---------|---------|
......@@ -82,7 +82,7 @@
| MNasNet | [code](https://github.com/pytorch/vision/blob/master/torchvision/models/mnasnet.py) |-|
| MobileNetV2 | [code](https://github.com/pytorch/vision/blob/master/torchvision/models/mobilenet.py) |-|
| ResNet18 | [code](https://github.com/pytorch/vision/blob/master/torchvision/models/resnet.py) |-|
| ShuffleNetV2 | [code](https://github.com/pytorch/vision/blob/master/torchvision/models/shufflenet.py) |-|
| ShuffleNetV2 | [code](https://github.com/pytorch/vision/blob/master/torchvision/models/shufflenetv2.py) |-|
| SqueezeNet | [code](https://github.com/pytorch/vision/blob/master/torchvision/models/squeezenet.py) |-|
| VGG16 | [code](https://github.com/pytorch/vision/blob/master/torchvision/models/vgg.py) |-|
| InceptionV3 | [code](https://github.com/pytorch/vision/blob/master/torchvision/models/inception.py) |-|
......@@ -90,7 +90,7 @@
| FCN_ResNet50 | [code](https://github.com/pytorch/vision/blob/master/torchvision/models/segmentation/fcn.py) |-|
| CamembertForQuestionAnswering | [code](https://huggingface.co/transformers/model_doc/camembert.html) |只支持trace模式|
| DPRContextEncoder | [code](https://huggingface.co/transformers/model_doc/dpr.html) |只支持trace模式|
| ElectraModel | [code](https://huggingface.co/transformers/model_doc/electra.html ) |只支持trace模式|
| ElectraModel | [code](https://huggingface.co/transformers/model_doc/electra.html) |只支持trace模式|
| FlaubertModel | [code](https://huggingface.co/transformers/model_doc/flaubert.html) |只支持trace模式|
| Roberta| [code](https://huggingface.co/transformers/model_doc/roberta.html) |只支持trace模式|
| XLMRobertaForTokenClassification|[code](https://huggingface.co/transformers/model_doc/xlmroberta.html) |只支持trace模式|
......@@ -98,7 +98,7 @@
| EasyOCR_recognizer|[code](https://github.com/JaidedAI/EasyOCR/blob/master/easyocr/recognition.py) |-|
| SwinTransformer|[code](https://github.com/microsoft/Swin-Transformer/) |-|
| BASNet|[code](https://github.com/xuebinqin/BASNet) |-|
| DBFace |[code](https://github.com/dlunion/DBFacet) |-|
| DBFace |[code](https://github.com/dlunion/DBFace) |-|
## PyTorch训练项目
| 模型 | 转换前代码 | 转换后代码 |
......
......@@ -3,7 +3,7 @@
| 类别 | 简介 |
| ---------- | ------------------------- |
| [基础操作类](./ops/README.md) | 主要为`torch.XX`类API |
| [组网类]((./nn/README.md)) | 主要为`torch.nn.XX`类下组网相关的API |
| [组网类](./nn/README.md) | 主要为`torch.nn.XX`类下组网相关的API |
| [Loss类](./loss/README.md) |主要为`torch.nn.XX`类下loss相关的API |
| [工具类](./utils/README.md) | 主要为`torch.nn.XX`类下分布式相关的API和`torch.utils.XX`类API|
| [视觉类](./vision/README.md) | 主要为`torchvision.XX`类API |
......@@ -116,7 +116,7 @@ NN_MAPPER = {
该情况需要完成以下几个步骤:
***步骤1***[x2paddle/project_convertor/pytorch/mapper.py](.../../x2paddle/project_convertor/pytorch/mapper.py)中对应的MAPPER中添加PyTorch API的字符串以及Paddle API的字符串、映射处理类,具体实现如下:
***步骤1***[x2paddle/project_convertor/pytorch/mapper.py](../../x2paddle/project_convertor/pytorch/mapper.py)中对应的MAPPER中添加PyTorch API的字符串以及Paddle API的字符串、映射处理类,具体实现如下:
```python
# key为PyTorch API字符串;
......
......@@ -3,9 +3,9 @@
``` shell
# 下载项目
git clone https://github.com/yunjey/stargan.git
cd stargan
git checkout 30867d6f85a3bb99c38ae075de651004747c42d4
# 下载预训练模型
cd stargan
bash download.sh pretrained-celeba-128x128
# 下载数据集
bash download.sh celeba
......@@ -99,7 +99,7 @@ class Solver(object):
### 运行训练代码
``` shell
cd paddle_project/stargan
cd paddle_project
python main.py --mode train --dataset CelebA --image_size 128 --c_dim 5 --sample_dir stargan_celeba/samples --log_dir stargan_celeba/logs --model_save_dir stargan_celeba/models --result_dir stargan_celeba/results --selected_attrs Black_Hair Blond_Hair Brown_Hair Male Young --celeba_image_dir ./data/celeba/images --attr_path ./data/celeba/list_attr_celeba.txt
```
......
......@@ -5,9 +5,10 @@
``` shell
# 下载项目
git clone https://github.com/Linzaer/Ultra-Light-Fast-Generic-Face-Detector-1MB.git
cd Ultra-Light-Fast-Generic-Face-Detector-1MB
git checkout 492a02471671b49c56be8d90cda54c94749d2980
```
2. 根据Generate VOC format training data set and training process的README.md所示下载数据集,并存放于Ultra-Light-Fast-Generic-Face-Detector-1MB/data/文件夹下。
2. 根据[Generate VOC format training data set and training process的README.md](https://github.com/Linzaer/Ultra-Light-Fast-Generic-Face-Detector-1MB#generate-voc-format-training-data-set-and-training-process)所示下载数据集,并存放于Ultra-Light-Fast-Generic-Face-Detector-1MB/data/文件夹下。
### 第一步:转换前代码预处理
1. 将代码中的[或操作符](https://github.com/Linzaer/Ultra-Light-Fast-Generic-Face-Detector-1MB/blob/master/vision/utils/box_utils.py#L153)替换为如下代码:
``` python
......@@ -83,7 +84,7 @@ class VOCDataset(data.Dataset):
### 运行训练代码
``` shell
cd paddle_project/Ultra-Light-Fast-Generic-Face-Detector-1MB
cd paddle_projec
sh train-version-RFB.sh
```
***转换后的代码可在[这里](https://github.com/SunAhong1993/Ultra-Light-Fast-Generic-Face-Detector-1MB/tree/paddle)进行查看。***
......@@ -1188,8 +1188,8 @@ class CaffeOpMapper(OpMapper):
"scale_factor": params.scale,
"mode": "nearest"}
self.paddle_graph.add_layer(
"paddle.nn.functioanl.interpolate",
inputs={"input": input.name},
"paddle.nn.functional.interpolate",
inputs={"x": input.name},
outputs=[node.layer_name],
**layer_attrs)
......
......@@ -1247,8 +1247,8 @@ class CaffeOpMapper(OpMapper):
"scale_factor": params.scale,
"mode": "nearest"}
self.paddle_graph.add_layer(
"paddle.nn.functioanl.interpolate",
inputs={"input": input.name},
"paddle.nn.functional.interpolate",
inputs={"x": input.name},
outputs=[node.layer_name],
**layer_attrs)
......
......@@ -431,8 +431,9 @@ class AstUpdater(ast.NodeVisitor):
elts_nodes = getattr(node, "elts")
elts = list()
for elts_node in elts_nodes:
elts.append(self.visit(elts_node))
elts = tuple(elts)
elt = self.visit(elts_node)
elts.append(elt if isinstance(elt, str) else str(elt))
elts = "({})".format(", ".join(elts))
return elts
def visit_Assign(self, node):
......
......@@ -275,7 +275,7 @@ API_MAPPER = {
"torch.min": ["x2paddle.torch2paddle.min", None],
"torch.argmax": ["paddle.argmax", OneMathMapper],
"torch.argmin": ["paddle.argmin", OneMathMapper],
"torch.stack": ["paddle.stacks", StackMapper],
"torch.stack": ["paddle.stack", StackMapper],
"torch.log": ["paddle.log", OneMathMapper],
"torch.randperm": ["paddle.randperm", RandpermMapper],
"torch.rand": ["x2paddle.torch2paddle.rand", None],
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册