主页 > 游戏开发  > 

使用vscode调试transformers源码

使用vscode调试transformers源码
简要介绍如何使用vscode调试transformers源码 以源码的方式安装transformers(官方手册为Editable install)

优先参考官方手册

git clone github /huggingface/transformers.git cd transformers pip install -e . 以下展示transformers/examples/pytorch/image-classification样例的调试方法

阅读image-classification的README.md文件,可知需要下载数据集beans和ViT模型(默认为google/vit-base-patch16-224-in21k),下图是我的数据集目录:

配置launch.json文件,这里面需要根据自己的路径修改一些变量,仅供参考:

{ // Use IntelliSense to learn about possible attributes. // Hover to view descriptions of existing attributes. // For more information, visit: go.microsoft /fwlink/?linkid=830387 "version": "0.2.0", "configurations": [ { "name": "Python Debugger: Current File", "type": "debugpy", "request": "launch", "program": "${file}", "console": "integratedTerminal" }, { "name": "run_image_classification.py", "type": "debugpy", "request": "launch", "program": "${workspaceFolder}/transformers/examples/pytorch/image-classification/run_image_classification.py", "args": [ "--train_dir", "transformers/examples/pytorch/image-classification/beans/data/train", "--validation_dir", "transformers/examples/pytorch/image-classification/beans/data/validation", "--output_dir", "./beans_outputs/", "--remove_unused_columns","False", "--label_column_name", "label", "--do_train", "--do_eval", "--num_train_epochs", "5", ], "console": "integratedTerminal", "justMyCode": false, "env": { "PYTHONPATH": "${workspaceFolder}" } }, ] } 进入调试环境即可跳转transformers源码阅读

标签:

使用vscode调试transformers源码由讯客互联游戏开发栏目发布,感谢您对讯客互联的认可,以及对我们原创作品以及文章的青睐,非常欢迎各位朋友分享到个人网站或者朋友圈,但转载请说明文章出处“使用vscode调试transformers源码