<jupyter_start><jupyter_text>Mask R-CNN - Inspect Custom Training DataInspect and visualize data loading and pre-processing code.<jupyter_code>import os
import sys
import itertools
import math
import logging
import json
import re
import random
from collections import OrderedDict
import numpy as np
import matplotlib
import matplotlib.pyplot as plt
import matplotlib.patches as patches
import matplotlib.lines as lines
from matplotlib.patches import Polygon

# Root directory of the project
ROOT_DIR = os.getcwd()

# Import Mask RCNN

sys.path.append(ROOT_DIR)  # To find local version of the library
from mrcnn import utils
from mrcnn import visualize
from mrcnn.visualize import display_images
import mrcnn.model as modellib
from mrcnn.model import log
from mrcnn.immnet import immNetConfig
import imgaug as ia
import imgaug.augmenters as iaa

%matplotlib inline

MODEL_DIR = os.path.join(ROOT_DIR, "logs")

class InferenceConfig(immNetConfig):
    IMAGES_PER_GPU = 1
    GPU_COUNT = 1


config = InferenceConfig()

model = modellib.MaskRCNN(mode='inference', config=config, model_dir=MODEL_DIR/)

# Load weights trained on MS-COCO
model.load_weights('mask_rcnn_imm_0010.h5', by_name=True)
import skimage.io as io
image = io.imread(r'D:\training\2.png')
plt.figure(figsize=(12,10))
io.imshow(image)
# Run detection
results = model.detect([image], verbose=1)

# Visualize results
r = results[0]
visualize.display_instances(image, r['rois'], r['masks'], r['class_ids'], r['scores'])<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.08597883597883597, 'fraction_numerical': 0.009259259259259259, 'mean_word_length': 5.940366972477064, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '319033', 'license': 'MIT', 'n_tokens_mistral': 514, 'n_tokens_neox': 501, 'n_words': 150, 'path': '.ipynb_checkpoints/predict-checkpoint.ipynb', 'repo_name': 'sukruburakcetin/imm-rooftop-detection', 'size': '1512'}