Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PaddlePaddle конвертер #561

Merged

Conversation

IgorKonovalovAleks
Copy link
Contributor

No description provided.

@valentina-kustikova
Copy link
Contributor

@IgorKonovalovAleks, проверка стиля кодирования не прошла, проверьте, пожалуйста.

Usage of the script:

```sh
python converter.py -m <path/to/input/model> -f <source_framework> -p <Pytorch/module/name> -d <output_directory>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pytorch? Либо все мелкими буквами (предпочтительно) или в соответствии с названием библиотеки.


### Paddle converter parameters

- `--model_path` Path to an .onnx or .pth file with the original model.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is a path


- `--model_path` Path to an .onnx or .pth file with the original model.
- `--framework` is a source framework for convertion to PaddlePaddle format.
- `--pytorch_module_name` Module name for PyTorch model (necessary if source framework is Pytorch).
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is a module name

- `--model_path` Path to an .onnx or .pth file with the original model.
- `--framework` is a source framework for convertion to PaddlePaddle format.
- `--pytorch_module_name` Module name for PyTorch model (necessary if source framework is Pytorch).
- `--save_dir` Directory for converted model to be saved to.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is a directory

python converter.py -m .\public\ctdet_coco_dlav0_512\ctdet_coco_dlav0_512.onnx -f onnx -d pd
```

# Conversion from PaddlePaddle
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Директория называется x2paddle, но откуда-то возник обратный конвертер?! Надо либо вынести, либо переименовать директорию.


- `--model_dir` Path to the directory with the original model.
- `--model_filename` Name of the model file name.
- `--params_filename` Name of the parameters file name.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is a name

- `--model_dir` Path to the directory with the original model.
- `--model_filename` Name of the model file name.
- `--params_filename` Name of the parameters file name.
- `--model_path` Path to the resulting .onnx file.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is a path

- `--model_filename` Name of the model file name.
- `--params_filename` Name of the parameters file name.
- `--model_path` Path to the resulting .onnx file.
- `--opset_version` Desired opset version of the resulting ONNX model.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is a desired...

input_examples=[torch.tensor(input_data)])

def convert_onnx_to_paddle(model_path: str, save_dir: str):
print(f'x2paddle --framework=onnx --model={model_path} --save_dir={save_dir}')
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Нигде в ридми нет информации, что требуется какой-то внешний инструмент. Надо где-то это написать.


def convert_paddle_to_onnx(model_dir: str, model_filename: str, params_filename: str,
model_path: str, opset_version: str):
os.system(f'paddle2onnx --model_dir {model_dir} \
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Аналогично, нигде в ридми нет информации, что требуется какой-то внешний инструмент. Надо где-то это написать.

type=str,
dest='model_path')
parser.add_argument('-f', '--framework',
help='Original model framework (ONNX or Pytorch)',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PyTorch вместо Pytorch

@@ -0,0 +1,58 @@
# Conversion to PaddlePaddle

PaddlePaddle converter supports conversion to Paddle format from Pytorch and ONNX formats.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PyTorch вместо Pytorch

Usage of the script:

```sh
python converter.py -m <path/to/input/model> -f <source_framework> -p <PyTorch/module/name> -d <output_directory>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Думаю, что имеет смысл название скрипта изменить, например, srcf2paddle

@valentina-kustikova valentina-kustikova merged commit 40c3036 into itlab-vision:master Dec 10, 2024
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants