import random
from detectron2.utils.visualizer import Visualizer
dataset_dicts = DatasetCatalog.get('microcontroller/train')
for d in random.sample(dataset_dicts, 10):
img = cv2.imread(d["file_name"])
v = Visualizer(img[:, :, ::-1], metadata=microcontroller_metadata, scale=0.5)
v = v.draw_dataset_dict(d)
plt.figure(figsize = (14, 10))
plt.imshow(cv2.cvtColor(v.get_image()[:, :, ::-1], cv2.COLOR_BGR2RGB))
plt.show()
当我尝试在 google colab 上执行此块时,出现文件错误。是微控制器/火车路径与谷歌 colab 中文件的位置冲突吗?我对这个和谷歌 colab 很陌生,所以欢迎任何帮助!
错误:
---------------------------------------------------------------------------
FileNotFoundError Traceback (most recent call last)
<ipython-input-23-61997d2db896> in <module>()
2 from detectron2.utils.visualizer import Visualizer
3
----> 4 dataset_dicts = DatasetCatalog.get('microcontroller/train')
5 for d in random.sample(dataset_dicts, 10):
6 img = cv2.imread(d["file_name"])
7 frames
/usr/local/lib/python3.7/dist-packages/pandas/io/parsers.py in __init__(self, src, **kwds)
2008 kwds["usecols"] = self.usecols
2009
-> 2010 self._reader = parsers.TextReader(src, **kwds)
2011 self.unnamed_cols = self._reader.unnamed_cols
2012
pandas/_libs/parsers.pyx in pandas._libs.parsers.TextReader.__cinit__()
pandas/_libs/parsers.pyx in pandas._libs.parsers.TextReader._setup_parser_source()
FileNotFoundError: [Errno 2] No such file or directory: '../input/microcontroller-detection/Microcontroller Detection/train_labels.csv'