1 minute read

Tags: , ,

GitHub Mask_RCNN 安裝步驟 + 地雷小解 (環境不一樣,遇到狀況也不一樣)

  • 我的作業系統
    • OS: Windows 10
  1. 在 conda create new virtural envs

    • conda craete -n name python=3.6.8
    >> conda create -n mask_rcnn python=3.6.8
    >> activate mask_rcnn 
    
  2. clone or download Mask R-CNN

    • cd 到 Mask R-CNN 的資料夾裡面

      Imgur

    • pip install requirements.txt

      • 在安裝 imgaug 出包了 這篇救了我
        • 要直接裝 Shapely(安裝imgaug 出包的原因) 的 whl
    • python setup.py install

      Imgur

  3. 跑 demo.ipynb 檔案

    • Run Mask_RCNN-master\samples\demo.ipynb

        import os
        import sys
        import random
        import math
        import numpy as np
        import skimage.io
        import matplotlib
        import matplotlib.pyplot as plt
             
        # Root directory of the project
        ROOT_DIR = os.path.abspath("../")
             
        # Import Mask RCNN
        sys.path.append(ROOT_DIR)  # To find local version of the library
        from mrcnn import utils
        import mrcnn.model as modellib
        from mrcnn import visualize
        # Import COCO config
        sys.path.append(os.path.join(ROOT_DIR, "samples/coco/"))  # To find local version
        import coco
             
        %matplotlib inline 
             
        # Directory to save logs and trained model
        MODEL_DIR = os.path.join(ROOT_DIR, "logs")
             
        # Local path to trained weights file
        COCO_MODEL_PATH = os.path.join(ROOT_DIR, "mask_rcnn_coco.h5")
        # Download COCO trained weights from Releases if needed
        if not os.path.exists(COCO_MODEL_PATH):
            utils.download_trained_weights(COCO_MODEL_PATH)
             
        # Directory of images to run detection on
        IMAGE_DIR = os.path.join(ROOT_DIR, "images")
      
      • 遇到 ModuleNotFoundError: No module named 'pycocotools' mask rcnn    
         ModuleNotFoundError: No module named 'pycocotools' mask rcnn
        
        • 要去 cocodataset/cocoapi,下載安裝 PythonAPI

          • 在安裝 cocoapi 的時候遇到 invalid numeric argument '/Wno-cpp

            Imgur

    • 看成果!!!

      Imgur