Skip to content

Commit

Permalink
Added segment_size field to Task model.
Browse files Browse the repository at this point in the history
  • Loading branch information
Nikita Manovich committed Jan 25, 2019
1 parent e6bbe22 commit 8700940
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 0 deletions.
32 changes: 32 additions & 0 deletions cvat/apps/engine/migrations/0015_task_segment_size.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# Generated by Django 2.1.5 on 2019-01-25 08:35

from django.db import migrations, models

def set_segment_size(apps, schema_editor):
Task = apps.get_model('engine', 'Task')
for task in Task.objects.all():
segment = task.segment_set.first()
task.segment_size = segment.stop_frame - segment.start_frame + 1
task.save()

class Migration(migrations.Migration):

dependencies = [
('engine', '0014_job_max_shape_id'),
]

operations = [
migrations.AddField(
model_name='task',
name='segment_size',
field=models.PositiveIntegerField(null=True),
),
migrations.RunPython(code=set_segment_size,
reverse_code=migrations.RunPython.noop),

migrations.AlterField(
model_name='task',
name='segment_size',
field=models.PositiveIntegerField(),
),
]
1 change: 1 addition & 0 deletions cvat/apps/engine/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ class Task(models.Model):
created_date = models.DateTimeField(auto_now_add=True)
updated_date = models.DateTimeField(auto_now_add=True)
overlap = models.PositiveIntegerField(default=0)
segment_size = models.PositiveIntegerField()
z_order = models.BooleanField(default=False)
flipped = models.BooleanField(default=False)
source = SafeCharField(max_length=256, default="unknown")
Expand Down
1 change: 1 addition & 0 deletions cvat/apps/engine/task.py
Original file line number Diff line number Diff line change
Expand Up @@ -606,6 +606,7 @@ def _save_task_to_db(db_task, task_params):
db_task.z_order = task_params['z_order']
db_task.flipped = task_params['flip']
db_task.source = task_params['data']
db_task.segment_size = min(db_task.size, task_params['segment'])

segment_step = task_params['segment'] - db_task.overlap
for x in range(0, db_task.size, segment_step):
Expand Down

0 comments on commit 8700940

Please sign in to comment.