Exemplo n.º 1
0
import visualize
from visualize import display_images
import model as modellib
from model import log

import balloon

get_ipython().magic(u'matplotlib inline')

# ## Configurations
#
# Configurations are defined in balloon.py

# In[2]:

config = balloon.BalloonConfig()
BALLOON_DIR = os.path.join(ROOT_DIR, "datasets/balloon")

# ## Dataset

# In[3]:

# Load dataset
# Get the dataset from the releases page
# https://github.com/matterport/Mask_RCNN/releases
dataset = balloon.BalloonDataset()
dataset.load_balloon(BALLOON_DIR, "train")

# Must call before using the dataset
dataset.prepare()


sys.path.append(ROOT_DIR)  # Specifies the path for looking the following packages
from mrcnn import utils
from mrcnn import visualize
from mrcnn.visualize import display_images
from mrcnn import model as modellib
from mrcnn.model import log
import balloon

# Creating the deractory to save logs and weights of the model
MODEL_DIR = os.path.join(ROOT_DIR,"logs")

# Loading the configuration:Object name, No. of epochs and all hyperparameters
config = balloon.BalloonConfig() # Configurations are defined in 'balloon.py' and 'config.py'


# To modify (if needed) some setting in config.
class InferenceConfig(config.__class__):
    GPU_COUNT = 1
    IMAGES_PER_GPU = 1
    

import cv2
import numpy as np


def random_colors(N):
    np.random.seed(1)
    colors = [tuple(255 * np.random.rand(3)) for _ in range(N)]