Skip to content

Commit 1a62b37

Browse files
committed
Fixed model import in coco_utils, closes #65
1 parent d37b955 commit 1a62b37

File tree

3 files changed

+17
-17
lines changed

3 files changed

+17
-17
lines changed

app/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
from .image_folder import ImageFolderHandler
77
from .api import blueprint as api
88
from .config import Config
9-
from .models import db, ImageModel, create_from_json
9+
from .models import *
1010
from .authentication import login_manager
1111
from .util import query_util, color_util
1212

app/models.py

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import os
2+
import cv2
23
import json
34
import datetime
45
import numpy as np
@@ -7,11 +8,12 @@
78
from mongoengine.queryset.visitor import Q
89
from flask_login import UserMixin, current_user
910

10-
from .util.coco_util import decode_seg
11+
1112
from .util import color_util
1213
from .config import Config
1314
from PIL import Image
1415

16+
1517
db = MongoEngine()
1618

1719

@@ -366,3 +368,15 @@ def create_from_json(json_file):
366368
upsert(DatasetModel, query={ "name": name}, update=dataset_json)
367369

368370

371+
def decode_seg(mask, segmentation):
372+
"""
373+
Create binary mask from segmentation
374+
"""
375+
pts = [
376+
np.array(anno).reshape(-1, 2).round().astype(int)
377+
for anno in segmentation
378+
]
379+
mask = cv2.fillPoly(mask, pts, 1)
380+
381+
return mask
382+

app/util/coco_util.py

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11
import pycocotools.mask as mask
2-
import numpy as np
3-
import cv2
42

53
from .query_util import fix_ids
64
from ..models import *
@@ -90,6 +88,7 @@ def get_image_coco(image):
9088
:param image: ImageModel
9189
:return: Coco in dictionary format
9290
"""
91+
print(DatasetModel, flush=True)
9392
dataset = DatasetModel.objects(id=image.dataset_id).first()
9493
image = fix_ids(image)
9594

@@ -176,19 +175,6 @@ def get_dataset_coco(dataset):
176175
return coco
177176

178177

179-
def decode_seg(mask, segmentation):
180-
"""
181-
Create binary mask from segmentation
182-
"""
183-
pts = [
184-
np.array(anno).reshape(-1, 2).round().astype(int)
185-
for anno in segmentation
186-
]
187-
mask = cv2.fillPoly(mask, pts, 1)
188-
189-
return mask
190-
191-
192178
def _fit(value, max_value, min_value):
193179

194180
if value > max_value:

0 commit comments

Comments
 (0)