File tree Expand file tree Collapse file tree 3 files changed +17
-17
lines changed Expand file tree Collapse file tree 3 files changed +17
-17
lines changed Original file line number Diff line number Diff line change 66from .image_folder import ImageFolderHandler
77from .api import blueprint as api
88from .config import Config
9- from .models import db , ImageModel , create_from_json
9+ from .models import *
1010from .authentication import login_manager
1111from .util import query_util , color_util
1212
Original file line number Diff line number Diff line change 11import os
2+ import cv2
23import json
34import datetime
45import numpy as np
78from mongoengine .queryset .visitor import Q
89from flask_login import UserMixin , current_user
910
10- from . util . coco_util import decode_seg
11+
1112from .util import color_util
1213from .config import Config
1314from PIL import Image
1415
16+
1517db = 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+
Original file line number Diff line number Diff line change 11import pycocotools .mask as mask
2- import numpy as np
3- import cv2
42
53from .query_util import fix_ids
64from ..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-
192178def _fit (value , max_value , min_value ):
193179
194180 if value > max_value :
You can’t perform that action at this time.
0 commit comments