Tobias Cornille commited on
Commit
37f9596
1 Parent(s): 938273e

Fix task attributes json

Browse files
Files changed (1) hide show
  1. app.py +8 -4
app.py CHANGED
@@ -293,9 +293,9 @@ def generate_panoptic_mask(
293
  segmentation_background_threshold=0.1,
294
  shrink_kernel_size=20,
295
  num_samples_factor=1000,
296
- task_attributes_json=None,
297
  ):
298
- if task_attributes_json is not None:
299
  task_attributes = json.loads(task_attributes_json)
300
  categories = task_attributes["categories"]
301
  category_name_to_id = {
@@ -304,10 +304,14 @@ def generate_panoptic_mask(
304
  # split the categories into "stuff" categories (regions w/o instances)
305
  # and "thing" categories (objects/instances)
306
  stuff_categories = [
307
- category for category in categories if not category["has_instances"]
 
 
308
  ]
309
  thing_categories = [
310
- category for category in categories if category["has_instances"]
 
 
311
  ]
312
  stuff_category_names = [category["name"] for category in stuff_categories]
313
  thing_category_names = [category["name"] for category in thing_categories]
 
293
  segmentation_background_threshold=0.1,
294
  shrink_kernel_size=20,
295
  num_samples_factor=1000,
296
+ task_attributes_json="",
297
  ):
298
+ if task_attributes_json is not "":
299
  task_attributes = json.loads(task_attributes_json)
300
  categories = task_attributes["categories"]
301
  category_name_to_id = {
 
304
  # split the categories into "stuff" categories (regions w/o instances)
305
  # and "thing" categories (objects/instances)
306
  stuff_categories = [
307
+ category
308
+ for category in categories
309
+ if "has_instances" not in category or not category["has_instances"]
310
  ]
311
  thing_categories = [
312
+ category
313
+ for category in categories
314
+ if "has_instances" in category and category["has_instances"]
315
  ]
316
  stuff_category_names = [category["name"] for category in stuff_categories]
317
  thing_category_names = [category["name"] for category in thing_categories]