Skip to content
This repository has been archived by the owner on Nov 21, 2023. It is now read-only.

Could not find instances2dict_with_polygons #111

Closed
jianminsun opened this issue Feb 6, 2018 · 6 comments
Closed

Could not find instances2dict_with_polygons #111

jianminsun opened this issue Feb 6, 2018 · 6 comments

Comments

@jianminsun
Copy link

import cityscapesscripts.evaluation.instances2dict_with_polygons as cs
I can't not find "instances2dict_with_polygons" in this repo or cityscapesscripts repo. Does anyone know where to find it? Thanks.

@ir413
Copy link
Contributor

ir413 commented Feb 6, 2018

Hi @jianminsun, thanks for reporting the missing file. We will release it with the Cityscapes models and training instructions (please see issue #27 which tracks this).

In the meantime, you can obtain the instnaces2dict_with_polygons.py script by applying the following changes to the instances2dict.py script from the Cityscapes repo:

$ diff instances2dict.py instances2dict_with_polygons.py
--- instances2dict.py   2018-02-06 05:19:33.009812039 -0800
+++ instances2dict_with_polygons.py     2018-02-06 05:22:15.953031446 -0800
@@ -11,7 +11,9 @@
 sys.path.append( os.path.normpath( os.path.join( os.path.dirname( __file__ ) , '..' , 'helpers' ) ) )
 from csHelpers import *

-def instances2dict(imageFileList, verbose=False):
+import cv2
+
+def instances2dict_with_polygons(imageFileList, verbose=False):
     imgCount     = 0
     instanceDict = {}

@@ -35,9 +37,22 @@

         # Loop through all instance ids in instance image
         for instanceId in np.unique(imgNp):
+            if instanceId < 1000:
+                continue
+
             instanceObj = Instance(imgNp, instanceId)
+            instanceObj_dict = instanceObj.toDict()

-            instances[id2label[instanceObj.labelID].name].append(instanceObj.toDict())
+            if id2label[instanceObj.labelID].hasInstances:
+                mask = (imgNp == instanceId).astype(np.uint8)
+                contour, hier = cv2.findContours(
+                    mask.copy(), cv2.RETR_EXTERNAL, cv2.CHAIN_APPROX_NONE)
+
+                polygons = [c.reshape(-1).tolist() for c in contour]
+                instanceObj_dict['contours'] = polygons
+
+            instances[id2label[instanceObj.labelID].name].append(
+                instanceObj_dict)

         imgKey = os.path.abspath(imageFileName)
         instanceDict[imgKey] = instances

@lssily
Copy link

lssily commented Sep 27, 2018

import cityscapesscripts.evaluation.instances2dict_with_polygons as cs
I can't not find "instances2dict_with_polygons" in this repo or cityscapesscripts repo. Does anyone know where to find it? Thanks.

Hi! Recently, I have trained a model on Cityscapes dataset. However, the perforamce is half the result reported by paper. Did that happen to you?

@zhixy
Copy link

zhixy commented Oct 10, 2018

@ir413 @lssily can you just share the generated json files for cityscapes?

@xllau
Copy link

xllau commented Jan 17, 2019

import cityscapesscripts.evaluation.instances2dict_with_polygons as cs
I can't not find "instances2dict_with_polygons" in this repo or cityscapesscripts repo. Does anyone know where to find it? Thanks.

Hi! Recently, I have trained a model on Cityscapes dataset. However, the perforamce is half the result reported by paper. Did that happen to you?

Did you solve the problem, I also meet the problem of the val accuracy problem. It is too low to match the results in paper.

@viet2411
Copy link

viet2411 commented Jun 28, 2019

Sorry I don't really understand this part of convert_cityscapes_to_coco.py:

`
def convert_cityscapes_instance_only(
data_dir, out_dir):
"""Convert from cityscapes format to COCO instance seg format - polygons"""
sets = [
'gtFine_val',
# 'gtFine_train',
# 'gtFine_test',

    # 'gtCoarse_train',
    # 'gtCoarse_val',
    # 'gtCoarse_train_extra'
]
ann_dirs = [
    'gtFine_trainvaltest/gtFine/val',
    # 'gtFine_trainvaltest/gtFine/train',
    # 'gtFine_trainvaltest/gtFine/test',

    # 'gtCoarse/train',
    # 'gtCoarse/train_extra',
    # 'gtCoarse/val'
]

`
I don't understand how I should organize the directory for dataset. What is the correct way to perform this code?
Can anyone share the generated json files for cityscapes?

@lucasjinreal
Copy link

Why not just given that file..... what does these diff can applying for

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants