Search code examples
pythonlinuxgoogle-colaboratorydetectron

Detectron MetadaCatalog and DatasetCatalog import Failed


I'm trying the include of Detectron2.data on Google Colab. I made the connection for colab & my drive. And after that:

!pip install pyyaml
!pip install detectron2 -f https://dl.fbaipublicfiles.com/detectron2/wheels/cu101/torch1.7/index.html

It worked without any error.

i have been trying this;

import numpy as np
import os, json, cv2, random
from google.colab.patches import cv2_imshow


import detectron2
from detectron2.data import MetadataCatalog, DatasetCatalog
from detectron2.utils.visualizer import Visualizer
from detectron2 import model_zoo

But the outputs like this: enter image description here

How can i fix that?


Solution

  • I fixed like this:

    !pip install pyyaml==5.1
    import torch, torchvision
    print(torch.__version__, torch.cuda.is_available())
    !gcc --version
    
    
    import torch
    assert torch.__version__.startswith("1.8")   
    !pip install detectron2 -f https://dl.fbaipublicfiles.com/detectron2/wheels/cu101/torch1.8/index.html
    # exit(0)  # After installation, you need to "restart runtime" in Colab. This line can also restart runtime
    

    from: https://colab.research.google.com/drive/16jcaJoc6bCFAQ96jDe2HwtXj7BMD_-m5#scrollTo=ZyAvNCJMmvFF