-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdetector.py
62 lines (51 loc) · 1.55 KB
/
detector.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
import os
import sys
import json
import datetime
import numpy as np
from tqdm import tqdm
import joblib
# Import Mask RCNN
from mrcnn.config import Config
from mrcnn import model as modellib, utils
############################################################
# Configurations
############################################################
class DetectorConfig(Config):
BACKBONE="resnet50"
BATCH_SIZE=8
DETECTION_MAX_INSTANCES=100
DETECTION_MIN_CONFIDENCE=0
DETECTION_NMS_THRESHOLD=0.3
GPU_COUNT=1
IMAGES_PER_GPU=8
IMAGE_CHANNEL_COUNT=3
IMAGE_MAX_DIM=256
IMAGE_MIN_DIM=256
IMAGE_MIN_SCALE=0
LEARNING_MOMENTUM=0.9
LEARNING_RATE=0.001
LOSS_WEIGHTS={'rpn_class_loss': 1.0, 'rpn_bbox_loss': 1.0, 'mrcnn_class_loss': 1.0, 'mrcnn_bbox_loss': 1.0, 'mrcnn_mask_loss': 3.0}
MASK_POOL_SIZE=14
MASK_SHAPE=[28, 28]
MAX_GT_INSTANCES=40
MEAN_PIXEL=[50., 50., 50.]
NAME="iris_feature_finetuned"
NUM_CLASSES=2
POST_NMS_ROIS_INFERENCE=1000
POST_NMS_ROIS_TRAINING=2000
RPN_ANCHOR_SCALES=(8, 16, 32, 64, 128)
RPN_NMS_THRESHOLD=0.9
RPN_TRAIN_ANCHORS_PER_IMAGE=256
STEPS_PER_EPOCH=500
TRAIN_ROIS_PER_IMAGE=256
USE_MINI_MASK=False
USE_RPN_ROIS=True
WEIGHT_DECAY=0.01
############################################################
# Dataset
############################################################
class DetectorDataset(utils.Dataset):
def load_detector(self):
# Add classes. We have only one class to add.
self.add_class("iris_feature", 1, "iris_feature")