Skip to content

Commit

Permalink
Fixed labels order (#242)
Browse files Browse the repository at this point in the history
  • Loading branch information
bsekachev authored and nmanovic committed Dec 19, 2018
1 parent d9eac60 commit 02abd5a
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions cvat/apps/engine/task.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
from ffmpy import FFmpeg
from pyunpack import Archive
from distutils.dir_util import copy_tree
from collections import OrderedDict

from . import models
from .log import slogger
Expand Down Expand Up @@ -154,7 +155,7 @@ def get(tid):
"""Get the task as dictionary of attributes"""
db_task = models.Task.objects.get(pk=tid)
if db_task:
db_labels = db_task.label_set.prefetch_related('attributespec_set').all()
db_labels = db_task.label_set.prefetch_related('attributespec_set').order_by('-pk').all()
im_meta_data = get_image_meta_cache(db_task)
attributes = {}
for db_label in db_labels:
Expand All @@ -174,7 +175,7 @@ def get(tid):
response = {
"status": db_task.status,
"spec": {
"labels": { db_label.id:db_label.name for db_label in db_labels },
"labels": OrderedDict((db_label.id, db_label.name) for db_label in db_labels),
"attributes": attributes
},
"size": db_task.size,
Expand Down Expand Up @@ -228,7 +229,7 @@ def get_job(jid):
if db_task.mode == 'annotation':
im_meta_data['original_size'] = im_meta_data['original_size'][db_segment.start_frame:db_segment.stop_frame + 1]

db_labels = db_task.label_set.prefetch_related('attributespec_set').all()
db_labels = db_task.label_set.prefetch_related('attributespec_set').order_by('-pk').all()
attributes = {}
for db_label in db_labels:
attributes[db_label.id] = {}
Expand All @@ -237,7 +238,7 @@ def get_job(jid):

response = {
"status": db_job.status,
"labels": { db_label.id:db_label.name for db_label in db_labels },
"labels": OrderedDict((db_label.id, db_label.name) for db_label in db_labels),
"stop": db_segment.stop_frame,
"taskid": db_task.id,
"slug": db_task.name,
Expand Down Expand Up @@ -375,7 +376,7 @@ def _get_frame_path(frame, base_dir):
return path

def _parse_labels(labels):
parsed_labels = {}
parsed_labels = OrderedDict()

last_label = ""
for token in shlex.split(labels):
Expand Down

0 comments on commit 02abd5a

Please sign in to comment.