首页 > 解决方案 > 如何为 jupyter 编写 argparse

问题描述

如何argparse在 jupyter notebook 中编写此代码?

ap = argparse.ArgumentParser()

ap.add_argument("-i", "--image", required=True,
    help="path to input image")

ap.add_argument("-y", "--yolo", required=True,
    help="base path to YOLO directory")

ap.add_argument("-c", "--confidence", type=float, default=0.5,
    help="minimum probability to filter weak detections")

ap.add_argument("-t", "--threshold", type=float, default=0.3,
    help="threshold when applying non-maxima suppression")

args = vars(ap.parse_args())

标签: pythonjupyter-notebookargparse

解决方案


为了从命令行执行您的 jupyter notebook 并传递参数,您可以使用 papermill 之类的工具 下面的 github 链接包含有关如何使用它的详细文档

https://github.com/nteract/papermill


推荐阅读