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

Fix two problems with the task segmentation algorithm #7681

Merged
merged 2 commits into from
Mar 26, 2024

Conversation

SpecLad
Copy link
Contributor

@SpecLad SpecLad commented Mar 26, 2024

Motivation and context

  1. When a task has non-zero overlap and exactly as many frames as needed to create 1 or more complete segments, the current algorithm generates a redundant segment at the end. For example, if size is 5, segment size is 3, and overlap is 1, it generates segments (0, 2), (2, 4), and (4, 4).

    The algorithm attempts to compensate for this, but it only works in the case where the segment size is unspecified (and defaults to the total size).

    Update the algorithm to handle this correctly in the general case.

  2. The algorithm selects a default overlap size of 5 if the media file is a video. However, this might not be a valid value if the task has a very small segment size. In this case, a range of undesirable behaviors may occur, depending on the segment size:

    • segments getting generated such that more than 2 segments cover a single frame;

    • task creation crashing with an exception;

    • a task being created with no segments at all.

    Fix this by clamping the default overlap size the same way as a user-specified one.

Fixes #7675.

How has this been tested?

Unit tests.

Checklist

  • I submit my changes into the develop branch
  • I have created a changelog fragment
  • [ ] I have updated the documentation accordingly
  • I have added tests to cover my changes
  • I have linked related issues (see GitHub docs)
  • [ ] I have increased versions of npm packages if it is necessary
    (cvat-canvas,
    cvat-core,
    cvat-data and
    cvat-ui)

License

  • I submit my code changes under the same MIT License that covers the project.
    Feel free to contact the maintainers if that's a concern.

1. When a task has non-zero overlap and exactly as many frames as needed
   to create 1 or more complete segments, the current algorithm generates a
   redundant segment at the end. For example, if size is 5, segment size is
   3, and overlap is 1, it generates segments (0, 2), (2, 4), and (4, 4).

   The algorithm attempts to compensate for this, but it only works in the
   case where the segment size is unspecified (and defaults to the total
   size).

   Update the algorithm to handle this correctly in the general case.

2. The algorithm selects a default overlap size of 5 if the media file is a
   video. However, this might not be a valid value if the task has a very
   small segment size. In this case, a range of undesirable behaviors may
   occur, depending on the segment size:

   * segments getting generated such that more than 2 segments cover a
     single frame;

   * task creation crashing with an exception;

   * a task being created with no segments at all.

   Fix this by clamping the default overlap size the same way as a
   user-specified one.
@SpecLad SpecLad marked this pull request as ready for review March 26, 2024 11:41
@SpecLad SpecLad force-pushed the segmentation-fix branch 2 times, most recently from 7b29a43 to 6676f99 Compare March 26, 2024 13:35
Copy link
Contributor

@nmanovic nmanovic left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copy link

codecov bot commented Mar 26, 2024

Codecov Report

Merging #7681 (c700dbc) into develop (eb5b612) will decrease coverage by 0.07%.
Report is 8 commits behind head on develop.
The diff coverage is 100.00%.

Additional details and impacted files
@@             Coverage Diff             @@
##           develop    #7681      +/-   ##
===========================================
- Coverage    83.46%   83.39%   -0.07%     
===========================================
  Files          373      373              
  Lines        39716    39716              
  Branches      3741     3741              
===========================================
- Hits         33150    33123      -27     
- Misses        6566     6593      +27     
Components Coverage Δ
cvat-ui 79.24% <ø> (-0.04%) ⬇️
cvat-server 87.24% <100.00%> (-0.10%) ⬇️

@SpecLad SpecLad merged commit aec333d into cvat-ai:develop Mar 26, 2024
34 checks passed
@SpecLad SpecLad deleted the segmentation-fix branch March 26, 2024 16:08
g-kartik pushed a commit to g-kartik/cvat that referenced this pull request Mar 29, 2024
1. When a task has non-zero overlap and exactly as many frames as needed
   to create 1 or more complete segments, the current algorithm generates a
   redundant segment at the end. For example, if size is 5, segment size is
   3, and overlap is 1, it generates segments (0, 2), (2, 4), and (4, 4).

   The algorithm attempts to compensate for this, but it only works in the
   case where the segment size is unspecified (and defaults to the total
   size).

   Update the algorithm to handle this correctly in the general case.

2. The algorithm selects a default overlap size of 5 if the media file
   is a video. However, this might not be a valid value if the task has a
   very small segment size. In this case, a range of undesirable behaviors
   may occur, depending on the segment size:

   * segments getting generated such that more than 2 segments cover a
     single frame;

   * task creation crashing with an exception;

   * a task being created with no segments at all.

   Fix this by clamping the default overlap size the same way as a
   user-specified one.

Fixes cvat-ai#7675.
@cvat-bot cvat-bot bot mentioned this pull request Apr 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Redundant jobs created in task when segment_size is explicitly set
2 participants