Skip to content

Commit f482059

Browse files
committed
Cleaned up maskrcnn implementation
1 parent a41807d commit f482059

File tree

4 files changed

+29
-27
lines changed

4 files changed

+29
-27
lines changed

app/api/models.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,14 @@
55
from ..config import Config
66
from PIL import Image
77

8-
if len(Config.MASK_RCNN_FILE) != 0:
8+
import os
9+
10+
MODEL_LOADED = len(Config.MASK_RCNN_FILE) != 0 and os.path.isfile(Config.MASK_RCNN_FILE)
11+
12+
if MODEL_LOADED:
913
from ..util.mask_rcnn import model as maskrcnn
14+
else:
15+
print("MaskRCNN model is disabled.", flush=True)
1016

1117
api = Namespace('model', description='Model related operations')
1218

@@ -21,8 +27,8 @@ class MaskRCNN(Resource):
2127
@api.expect(image_upload)
2228
def post(self):
2329
""" COCO data test """
24-
if len(Config.MASK_RCNN_FILE) == 0:
25-
return {"coco": {}}
30+
if not MODEL_LOADED:
31+
return {"disabled": True, "coco": {}}
2632

2733
args = image_upload.parse_args()
2834
im = Image.open(args.get('image'))

app/util/mask_rcnn.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
from keras.preprocessing.image import img_to_array
21
from ..config import Config as AnnotatorConfig
32
from skimage.transform import resize
43
import imantics as im
54
import cv2
65

6+
from keras.preprocessing.image import img_to_array
77
from mrcnn.config import Config
88
import mrcnn.utils as utils
99
import mrcnn.model as modellib

docker-compose.dev.yml

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -35,25 +35,25 @@ services:
3535
- FILE_WATCHER=true
3636
- FLASK_APP=app
3737
- FLASK_ENV=development
38-
- MASK_RCNN_FILE=/models/mask_rcnn_coco.h5
39-
# Default coco classes (order matters)
40-
- |
41-
MASK_RCNN_CLASSES=
42-
BG,person,bicycle,car,motorcycle,airplane,
43-
bus,train,truck,boat,traffic light,
44-
fire hydrant,stop sign,parking meter,bench,bird,
45-
cat,dog,horse,sheep,cow,elephant,bear,
46-
zebra,giraffe,backpack,umbrella,handbag,tie,
47-
suitcase,frisbee,skis,snowboard,sports ball,
48-
kite,baseball bat,baseball glove,skateboard,
49-
surfboard,tennis racket,bottle,wine glass,cup,
50-
fork,knife,spoon,bowl,banana',apple,
51-
sandwich,orange,broccoli,carrot,hot dog,pizza,
52-
donut,cake,chair,couch,potted plant,bed,
53-
dining table,toilet,tv,laptop,mouse,remote,
54-
keyboard,cell phone,microwave,oven,toaster,
55-
sink,refrigerator,book,clock,vase,scissors,
56-
teddy bear,hair drier,toothbrush
38+
# - MASK_RCNN_FILE=/models/mask_rcnn_coco.h5
39+
# # Default coco classes (order matters)
40+
# - |
41+
# MASK_RCNN_CLASSES=
42+
# BG,person,bicycle,car,motorcycle,airplane,
43+
# bus,train,truck,boat,traffic light,
44+
# fire hydrant,stop sign,parking meter,bench,bird,
45+
# cat,dog,horse,sheep,cow,elephant,bear,
46+
# zebra,giraffe,backpack,umbrella,handbag,tie,
47+
# suitcase,frisbee,skis,snowboard,sports ball,
48+
# kite,baseball bat,baseball glove,skateboard,
49+
# surfboard,tennis racket,bottle,wine glass,cup,
50+
# fork,knife,spoon,bowl,banana',apple,
51+
# sandwich,orange,broccoli,carrot,hot dog,pizza,
52+
# donut,cake,chair,couch,potted plant,bed,
53+
# dining table,toilet,tv,laptop,mouse,remote,
54+
# keyboard,cell phone,microwave,oven,toaster,
55+
# sink,refrigerator,book,clock,vase,scissors,
56+
# teddy bear,hair drier,toothbrush
5757
networks:
5858
- cocoannotator
5959
depends_on:

run.py

Lines changed: 0 additions & 4 deletions
This file was deleted.

0 commit comments

Comments
 (0)