<jupyter_start><jupyter_text><jupyter_code>import warnings
warnings.filterwarnings("ignore")
!pip install keras==2.1.0 
!pip install tensorflow==1.15.0
!python setup.py install
import os 
import sys
import random
import math
import numpy as np
import cv2
import matplotlib.pyplot as plt
import json
from imgaug import augmenters as iaa
from tqdm import tqdm
import pandas as pd 
import glob
from imgaug import augmenters as iaa
import scipy.misc
import matplotlib
from keras.preprocessing.image import load_img
from keras.preprocessing.image import img_to_array
from mrcnn.visualize import display_instances
from mrcnn.config import Config
from mrcnn.model import MaskRCNN


# define the test configuration
class TestConfig(Config):
     NAME = "test"
     GPU_COUNT = 1
     IMAGES_PER_GPU = 1
     NUM_CLASSES = 9
    
# define 81 classes that the coco model knowns about
class_names = ['BG', 'Fire_truck','Ambulance','hiace','bus','truck','car','jeep','bike']


model = MaskRCNN(mode='inference', model_dir='./', config=TestConfig())
#model.load_weights('D:\\projects\\desktop\\mask_rcnn_firetruck_cfg_0094.h5', by_name=True)

#model.load_weights('D:\\projects\\automatic _traffic_system\\model\\6_13\\low_learning_rate_mask_rcnn_7vfiretruck_cfg_0008.h5', by_name=True)
'''
from folder 6
1.low_learning_rate_mask_rcnn_7vfiretruck_cfg_0008.h5
2.low_learning_rate_mask_rcnn_7vfiretruck_cfg_0005.h5
3.heads_mask_rcnn_7vfiretruck_cfg_0004.h5
4.best_of_low_learning_ratemask_rcnn_7vfiretruck_cfg_0007.h5
'''



model.load_weights('D:\\projects\\automatic _traffic_system\\models_for_eight_class\\mask_rcnn_eight_class_cfgh_0016.h5', by_name=True)
#for images

# load coco model weights

# load photograph
#img = load_img('/kaggle/input/elephant/elephant.jpg')
img = load_img('D:\\projects\\automatic _traffic_system\\picture\\download.jpg')

img = img_to_array(img)
# make prediction
results = model.detect([img], verbose=0)
# get dictionary for first prediction
r = results[0]
# show photo with bounding boxes, masks, class labels and scores
display_instances(img, r['rois'], r['masks'], r['class_ids'], class_names, r['scores'])<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.10365029292474087, 'fraction_numerical': 0.028391167192429023, 'mean_word_length': 5.235955056179775, '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': 1, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '232545', 'license': 'MIT', 'n_tokens_mistral': 855, 'n_tokens_neox': 793, 'n_words': 166, 'path': 'eight_class_image.ipynb', 'repo_name': 'Sujangyawali/Fraud_detection', 'size': '2219'}