Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added .DS_Store
Binary file not shown.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ See helpers/anue_labels.py
python preperation/createLabels.py --datadir $ANUE --id-type $IDTYPE --color [True|False] --instance [True|False] --num-workers $C
```

- ANUE is the path to the AutoNUE dataset
- ANUE is the path to the AutoNUE dataset(the path to the gtFine for any dataset you have downloaded from the IDD website,for example: "/Users/srimanthdhondy/Programs/autodataset/idd20kII",here the idd20kII has two folders gtFine and leftImg8bit)
- IDTYPE can be id, csId, csTrainId, level3Id, level2Id, level1Id.
- color True generates the color masks
- instance True generates the instance masks with the id given by IDTYPE
Expand All @@ -108,6 +108,7 @@ For the supervised domain adaptation and semantic segmentation tasks, the masks
```bash
python preperation/createLabels.py --datadir $ANUE --id-type level3Id --num-workers $C
```
**NOTE**:In the scripts json2instanceImg.py, json2labelImg.py be sure to change the highlighted path in the line "sys.path.append("**/Users/srimanthdhondy/Programs**/public-code/helpers/")" as per your download location.

Following commands are updated for the target labels of other domain adaptation tasks:

Expand Down
46 changes: 24 additions & 22 deletions preperation/createLabels.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,15 @@

# python imports
from __future__ import print_function
from functools import partial
import os
import glob
import sys
#from scipy.misc import imread, imsave
from imageio import imread, imsave
import numpy as np
from numpngw import write_png
import PIL

from json2labelImg import json2labelImg
from json2instanceImg import json2instanceImg
Expand All @@ -23,11 +25,28 @@
import pandas as pd
import shutil

global args
args = None

def get_args():
parser = ArgumentParser()

parser.add_argument('--datadir', default="")
parser.add_argument('--id-type', default='level3Id')
parser.add_argument('--color', type=bool, default=False)
parser.add_argument('--instance', type=bool, default=False)
parser.add_argument('--panoptic', type=bool, default=False)
parser.add_argument('--semisup_da', type=bool, default=False)
parser.add_argument('--unsup_da', type=bool, default=False)
parser.add_argument('--weaksup_da', type=bool, default=False)
parser.add_argument('--num-workers', type=int, default=10)

args = parser.parse_args()

return args

def process_folder(fn):
global args
def process_folder(fn,args):


dst = fn.replace("_polygons.json", "_label{}s.png".format(args.id_type))

Expand Down Expand Up @@ -57,29 +76,13 @@ def process_folder(fn):
try:
json2labelImg(fn, dst, 'color')
except:
tqdm.write("Failed to convert: {}".format(f))
tqdm.write("Failed to convert: {}".format(fn))
raise

# if args.panoptic and args.instance:
# panoptic_converter(f, out_folder, out_file)


def get_args():
parser = ArgumentParser()

parser.add_argument('--datadir', default="")
parser.add_argument('--id-type', default='level3Id')
parser.add_argument('--color', type=bool, default=False)
parser.add_argument('--instance', type=bool, default=False)
parser.add_argument('--panoptic', type=bool, default=False)
parser.add_argument('--semisup_da', type=bool, default=False)
parser.add_argument('--unsup_da', type=bool, default=False)
parser.add_argument('--weaksup_da', type=bool, default=False)
parser.add_argument('--num-workers', type=int, default=10)

args = parser.parse_args()

return args

# The main method

Expand Down Expand Up @@ -124,7 +127,7 @@ def main(args):

#print('args.semisup_da', args.semisup_da, len(files))
if not files:
tqdm.writeError(
tqdm.write(
"Did not find any files. Please consult the README.")

# a bit verbose
Expand All @@ -141,8 +144,7 @@ def main(args):

pool = Pool(args.num_workers)
# results = pool.map(process_pred_gt_pair, pairs)
results = list(
tqdm(pool.imap(process_folder, files), total=len(files)))
results = list(tqdm(pool.imap(partial(process_folder, args=args), files), total=len(files)))
pool.close()
pool.join()

Expand Down
15 changes: 8 additions & 7 deletions preperation/json2instanceImg.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,21 +33,22 @@
#

# python imports
import sys
sys.path.append("/Users/srimanthdhondy/Programs/public-code/helpers/")
from anue_labels import labels, name2label
from annotation import Annotation
import os
import sys
import getopt
from tqdm import tqdm

# Image processing
# Check if PIL is actually Pillow as expected
try:
from PIL import PILLOW_VERSION
except:
print("Please install the module 'Pillow' for image processing, e.g.")
print("pip install pillow")
sys.exit(-1)
#try:
#from PIL import PILLOW_VERSION
#except:
#print("Please install the module 'Pillow' for image processing, e.g.")
#print("pip install pillow")
#sys.exit(-1)

try:
import PIL.Image as Image
Expand Down
18 changes: 10 additions & 8 deletions preperation/json2labelImg.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,24 @@
#

# python imports
import sys
sys.path.append("/Users/srimanthdhondy/Programs/public-code/helpers/")
from anue_labels import name2label
from annotation import Annotation
import os
import sys
import getopt

import tqdm
import sys
import numpy

# Image processing
# Check if PIL is actually Pillow as expected
try:
from PIL import PILLOW_VERSION
except:
print("Please install the module 'Pillow' for image processing, e.g.")
print("pip install pillow")
sys.exit(-1)
#try:
#from PIL import PILLOW_VERSION
#except:
#print("Please install the module 'Pillow' for image processing, e.g.")
#print("pip install pillow")
#sys.exit(-1)

try:
import PIL.Image as Image
Expand Down
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@ tqdm
Pillow
scipy==1.1.0
imageio
numpngw