【问题标题】:How can I run this prediction.py and evaluate_performance.py file?如何运行这个 prediction.py 和 evaluate_performance.py 文件?
【发布时间】:2019-12-24 01:36:35
【问题描述】:

我是一名医科学生,我正在使用 google colab 来学习 fastAI。
在这个项目中,https://github.com/QinglingGo/Classification-of-Objects-using-Deep-Learning-Model, 我可以实现模型的输出,但是不知道如何执行prediction.pyevaluat_performance.py文件。
当我运行 evaluat_performance.py 时,会出现以下消息:

python3: can't open file 'prediction.py': [Errno 2] No such file or directory
/usr/local/lib/python3.6/dist-packages/IPython/utils/traitlets.py:5: UserWarning: IPython.utils.traitlets has moved to a top-level traitlets package.
  warn ("IPython.utils.traitlets has moved to a top-level traitlets package.")
1. Loading Data ...
ImageDataBunch;

Train: LabelList (942 items)
x: SegmentationItemList
Image (3, 256, 256), Image (3, 256, 256), Image (3, 256, 256), Image (3, 256, 256), Image (3, 256, 256)
y: SegmentationLabelList
ImageSegment (1, 256, 256), ImageSegment (1, 256, 256), ImageSegment (1, 256, 256), ImageSegment (1, 256, 256), ImageSegment (1, 256, 256)
Path: / content / drive / My Drive / Colab Notebooks / bbc_train / images;

Valid: LabelList (0 items)
x: SegmentationItemList

y: SegmentationLabelList

Path: / content / drive / My Drive / Colab Notebooks / bbc_train / images;

Test: None
2. Instantiating Model ...
Traceback (most recent call last):
  File "evaluate_preformance.py", line 66, in <module>
    combined_accuracy, classification_accuracy, bbox_score, segmentation_accuracy = evaluate ()
  File "evaluate_preformance.py", line 29, in evaluate
    M = Model (path = model_dir, file = 'export.pkl')
NameError: name 'Model' is not defined.

我不明白.py文件第6行中"from sample_student import Model"的含义?
谁能帮帮我?

提前致谢!

【问题讨论】:

  • 所以从哪里加载数据集。如果它位于谷歌驱动器上,请查看此问题stackoverflow.com/questions/48376580/…。之后,您可以从谷歌驱动器加载相同的预测文件,您可以使用 %run 魔术函数在 jupyter notebook 中运行 python 文件。

标签: machine-learning deep-learning pytorch


【解决方案1】:

我不知道这是否会完全解决您的问题,但这是您在使用此类项目时应牢记的基本事项

请从您的终端转到可以找到名为evaluate_performance.py 代码的python 脚本并使用命令python evaluate_performance.py 的目录。我猜深度学习模型也是在其中一个 python 脚本中定义的。正确设置数据集的所有路径,如果一切正确,您将能够成功运行代码。

请注意,请将所有 python 脚本保存在同一目录中,以便可以从同一目录中的任何位置访问它们。希望这会对你有所帮助。

【讨论】:

    【解决方案2】:

    在你的 jupyter notebook 的新单元格中,运行以下命令。

    %run /path_to_file/filename.py
    

    这将执行 jupyter notebook 中的 python 文件。

    注意:确保您提供正确的目录。 如果路径错误,则会引发找不到文件的错误

    【讨论】:

      猜你喜欢
      • 2021-01-20
      • 1970-01-01
      • 1970-01-01
      • 2022-10-05
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多