Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Release 0.2.0 #64

Merged
merged 12 commits into from
Sep 19, 2018
Merged
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
44 changes: 37 additions & 7 deletions cvat/apps/engine/annotation.py
Original file line number Diff line number Diff line change
Expand Up @@ -761,14 +761,29 @@ def init_from_client(self, data):
label = _Label(self.db_labels[int(path['label_id'])])
boxes = []
frame = -1

has_boxes_on_prev_segm = False
last_box_on_prev_segm = None
has_box_on_start_frame = False
for box in path['shapes']:
if int(box['frame']) < self.start_frame:
has_boxes_on_prev_segm = True
if last_box_on_prev_segm is None or int(last_box_on_prev_segm["frame"]) < int(box["frame"]):
last_box_on_prev_segm = box
elif int(box['frame']) == self.start_frame:
has_box_on_start_frame = True
break
if has_boxes_on_prev_segm and not has_box_on_start_frame:
last_box_on_prev_segm["frame"] = self.start_frame

for box in path['shapes']:
if int(box['frame']) <= self.stop_frame:
if int(box['frame']) <= self.stop_frame and int(box['frame']) >= self.start_frame:
frame_idx = int(box['frame']) if db_task.mode == 'annotation' else 0
xtl, ytl, xbr, ybr = self._clamp_box(float(box['xtl']), float(box['ytl']),
float(box['xbr']), float(box['ybr']), image_meta['original_size'][frame_idx])
tracked_box = _TrackedBox(xtl, ytl, xbr, ybr, int(box['frame']), strtobool(str(box['occluded'])),
int(box['z_order']), strtobool(str(box['outside'])))
assert tracked_box.frame > frame
assert tracked_box.frame > frame
frame = tracked_box.frame

for attr in box['attributes']:
Expand All @@ -780,7 +795,7 @@ def init_from_client(self, data):
boxes.append(tracked_box)
else:
self.logger.error("init_from_client: ignore frame #%d " +
"because stop_frame is %d", int(box['frame']), self.stop_frame)
"because it out of segment range [%d-%d]", int(box['frame']), self.start_frame, self.stop_frame)

attributes = []
for attr in path['attributes']:
Expand All @@ -790,7 +805,7 @@ def init_from_client(self, data):
attributes.append(attr)

assert frame <= self.stop_frame
box_path = _BoxPath(label, int(path['frame']), self.stop_frame,
box_path = _BoxPath(label, min(list(map(lambda box: box.frame, boxes))), self.stop_frame,
int(path['group_id']), boxes, attributes)
self.box_paths.append(box_path)

Expand All @@ -799,8 +814,23 @@ def init_from_client(self, data):
label = _Label(self.db_labels[int(path['label_id'])])
poly_shapes = []
frame = -1

has_shapes_on_prev_segm = False
last_shape_on_prev_segm = None
has_shape_on_start_frame = False
for poly_shape in path['shapes']:
if int(poly_shape['frame']) < self.start_frame:
has_shapes_on_prev_segm = True
if last_shape_on_prev_segm is None or int(last_shape_on_prev_segm["frame"]) < (poly_shape["frame"]):
last_shape_on_prev_segm = box
elif int(poly_shape['frame']) == self.start_frame:
has_shape_on_start_frame = True
break
if has_shapes_on_prev_segm and not has_shape_on_start_frame:
last_shape_on_prev_segm["frame"] = self.start_frame

for poly_shape in path['shapes']:
if int(poly_shape['frame']) <= self.stop_frame:
if int(poly_shape['frame']) <= self.stop_frame and int(poly_shape['frame']) >= self.start_frame:
frame_idx = int(poly_shape['frame']) if db_task.mode == 'annotation' else 0
points = self._clamp_poly(poly_shape['points'], image_meta['original_size'][frame_idx])
tracked_poly_shape = _TrackedPolyShape(points, int(poly_shape['frame']), strtobool(str(poly_shape['occluded'])),
Expand All @@ -817,7 +847,7 @@ def init_from_client(self, data):
poly_shapes.append(tracked_poly_shape)
else:
self.logger.error("init_from_client: ignore frame #%d " +
"because stop_frame is %d", int(poly_shape['frame']), self.stop_frame)
"because it out of segment range [%d-%d]", int(poly_shape['frame']), self.start_frame, self.stop_frame)

attributes = []
for attr in path['attributes']:
Expand All @@ -826,7 +856,7 @@ def init_from_client(self, data):
attr = _Attribute(spec, str(attr['value']))
attributes.append(attr)

poly_path = _PolyPath(label, int(path['frame']), self.stop_frame + 1,
poly_path = _PolyPath(label, min(list(map(lambda shape: shape.frame, poly_shapes))), self.stop_frame + 1,
int(path['group_id']), poly_shapes, attributes)

getattr(self, poly_path_type).append(poly_path)
Expand Down
20 changes: 20 additions & 0 deletions cvat/apps/engine/migrations/0008_auto_20180917_1424.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Generated by Django 2.0.3 on 2018-09-17 11:24

from django.conf import settings
from django.db import migrations, models
import django.db.models.deletion


class Migration(migrations.Migration):

dependencies = [
('engine', '0007_task_flipped'),
]

operations = [
migrations.AlterField(
model_name='task',
name='owner',
field=models.ForeignKey(null=True, on_delete=django.db.models.deletion.SET_NULL, to=settings.AUTH_USER_MODEL),
),
]
170 changes: 170 additions & 0 deletions cvat/apps/engine/migrations/0009_auto_20180917_1424.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,170 @@
# Generated by Django 2.0.3 on 2018-09-17 11:24

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('engine', '0008_auto_20180917_1424'),
]



operations = [
migrations.AlterField(
model_name='labeledbox',
name='id',
field=models.BigAutoField(primary_key=True, serialize=False),
),
migrations.AlterField(
model_name='labeledboxattributeval',
name='id',
field=models.BigAutoField(primary_key=True, serialize=False),
),
migrations.AlterField(
model_name='labeledpoints',
name='id',
field=models.BigAutoField(primary_key=True, serialize=False),
),
migrations.AlterField(
model_name='labeledpointsattributeval',
name='id',
field=models.BigAutoField(primary_key=True, serialize=False),
),
migrations.AlterField(
model_name='labeledpolygon',
name='id',
field=models.BigAutoField(primary_key=True, serialize=False),
),
migrations.AlterField(
model_name='labeledpolygonattributeval',
name='id',
field=models.BigAutoField(primary_key=True, serialize=False),
),
migrations.AlterField(
model_name='labeledpolyline',
name='id',
field=models.BigAutoField(primary_key=True, serialize=False),
),
migrations.AlterField(
model_name='labeledpolylineattributeval',
name='id',
field=models.BigAutoField(primary_key=True, serialize=False),
),
migrations.AlterField(
model_name='objectpath',
name='id',
field=models.BigAutoField(primary_key=True, serialize=False),
),
migrations.AlterField(
model_name='objectpathattributeval',
name='id',
field=models.BigAutoField(primary_key=True, serialize=False),
),
migrations.AlterField(
model_name='trackedbox',
name='id',
field=models.BigAutoField(primary_key=True, serialize=False),
),
migrations.AlterField(
model_name='trackedboxattributeval',
name='id',
field=models.BigAutoField(primary_key=True, serialize=False),
),
migrations.AlterField(
model_name='trackedpoints',
name='id',
field=models.BigAutoField(primary_key=True, serialize=False),
),
migrations.AlterField(
model_name='trackedpointsattributeval',
name='id',
field=models.BigAutoField(primary_key=True, serialize=False),
),
migrations.AlterField(
model_name='trackedpolygon',
name='id',
field=models.BigAutoField(primary_key=True, serialize=False),
),
migrations.AlterField(
model_name='trackedpolygonattributeval',
name='id',
field=models.BigAutoField(primary_key=True, serialize=False),
),
migrations.AlterField(
model_name='trackedpolyline',
name='id',
field=models.BigAutoField(primary_key=True, serialize=False),
),
migrations.AlterField(
model_name='trackedpolylineattributeval',
name='id',
field=models.BigAutoField(primary_key=True, serialize=False),
),
migrations.AlterField(
model_name='objectpathattributeval',
name='track_id',
field=models.BigIntegerField(),
),
migrations.AlterField(
model_name='objectpathattributeval',
name='track_id',
field=models.BigIntegerField(),
),
migrations.AlterField(
model_name='trackedpoints',
name='track_id',
field=models.BigIntegerField(),
),
migrations.AlterField(
model_name='trackedpolygon',
name='track_id',
field=models.BigIntegerField(),
),
migrations.AlterField(
model_name='trackedpolyline',
name='track_id',
field=models.BigIntegerField(),
),
migrations.AlterField(
model_name='trackedboxattributeval',
name='box_id',
field=models.BigIntegerField(),
),
migrations.AlterField(
model_name='trackedpointsattributeval',
name='points_id',
field=models.BigIntegerField(),
),
migrations.AlterField(
model_name='trackedpolygonattributeval',
name='polygon_id',
field=models.BigIntegerField(),
),
migrations.AlterField(
model_name='trackedpolylineattributeval',
name='polyline_id',
field=models.BigIntegerField(),
),
migrations.AlterField(
model_name='labeledboxattributeval',
name='box_id',
field=models.BigIntegerField(),
),
migrations.AlterField(
model_name='labeledpointsattributeval',
name='points_id',
field=models.BigIntegerField(),
),
migrations.AlterField(
model_name='labeledpolygonattributeval',
name='polygon_id',
field=models.BigIntegerField(),
),
migrations.AlterField(
model_name='labeledpolylineattributeval',
name='polyline_id',
field=models.BigIntegerField(),
),
]
4 changes: 4 additions & 0 deletions cvat/apps/engine/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ def __str__(self):

class AttributeVal(models.Model):
# TODO: add a validator here to be sure that it corresponds to self.label
id = models.BigAutoField(primary_key=True)
spec = models.ForeignKey(AttributeSpec, on_delete=models.CASCADE)
value = models.CharField(max_length=64)
class Meta:
Expand All @@ -148,6 +149,7 @@ class Meta:
abstract = True

class BoundingBox(Shape):
id = models.BigAutoField(primary_key=True)
xtl = models.FloatField()
ytl = models.FloatField()
xbr = models.FloatField()
Expand All @@ -156,6 +158,7 @@ class Meta:
abstract = True

class PolyShape(Shape):
id = models.BigAutoField(primary_key=True)
points = models.TextField()
class Meta:
abstract = True
Expand Down Expand Up @@ -185,6 +188,7 @@ class LabeledPointsAttributeVal(AttributeVal):
points = models.ForeignKey(LabeledPoints, on_delete=models.CASCADE)

class ObjectPath(Annotation):
id = models.BigAutoField(primary_key=True)
shapes = models.CharField(max_length=10, default='boxes')

class ObjectPathAttributeVal(AttributeVal):
Expand Down
3 changes: 2 additions & 1 deletion cvat/apps/engine/static/engine/base.css
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,9 @@ html {
border: none;
outline: none;
cursor: pointer;
padding: 14px 16px;
padding: 3px 0px;
transition: 0.3s;

}

.tab button:hover {
Expand Down
Loading