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 included frames handling on UI #9155

Merged
merged 3 commits into from
Mar 3, 2025
Merged

Conversation

zhiltsov-max
Copy link
Contributor

@zhiltsov-max zhiltsov-max commented Feb 27, 2025

Motivation and context

Fixes #9097

  • Added a temporary emulation in UI for the upcoming server changes in /api/task|job/data/meta .frames
  • Updated related GT allocation table code
  • Fixed type for the included_frames field in the related meta API response class

How has this been tested?

data_with_related_images.zip
random_200.zip
random_video_10s.mp4

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)

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.

@zhiltsov-max zhiltsov-max marked this pull request as draft February 27, 2025 10:02
@zhiltsov-max zhiltsov-max force-pushed the zm/fix-included-frame-handling branch from 7a2e782 to 7a5dbdb Compare February 28, 2025 10:27
@zhiltsov-max zhiltsov-max marked this pull request as ready for review February 28, 2025 12:03
@codecov-commenter
Copy link

codecov-commenter commented Feb 28, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 73.32%. Comparing base (47e2ed1) to head (907392a).
Report is 6 commits behind head on develop.

Additional details and impacted files
@@             Coverage Diff             @@
##           develop    #9155      +/-   ##
===========================================
+ Coverage    73.24%   73.32%   +0.08%     
===========================================
  Files          447      448       +1     
  Lines        45837    45866      +29     
  Branches      3908     3915       +7     
===========================================
+ Hits         33573    33632      +59     
+ Misses       12264    12234      -30     
Components Coverage Δ
cvat-ui 77.09% <100.00%> (+<0.01%) ⬆️
cvat-server 70.31% <ø> (+0.14%) ⬆️

@zhiltsov-max zhiltsov-max marked this pull request as draft February 28, 2025 13:57
@zhiltsov-max zhiltsov-max marked this pull request as ready for review February 28, 2025 14:26
@@ -208,7 +208,23 @@ export class FramesMetaData {
// it may be a videofile or one image
framesInfo = frameNumbers.map(() => initialData.frames[0]);
} else {
framesInfo = initialData.frames;
framesInfo = (() => {
if (initialData.frames.length > 1 &&
Copy link
Member

Choose a reason for hiding this comment

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

there is condition initialData.frames.length === 1 above

Copy link
Member

Choose a reason for hiding this comment

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

The solution with frame names looks like a dirty hack
What to you think about this one?

            if (this.includedFrames?.length) {
                // only gt jobs have this.includedFrame, so this condition works only for them
                const framesIndexes = new Set(this.includedFrames.map((dataFrameNumber: number) => {
                    return Math.floor((dataFrameNumber - this.startFrame) / this.frameStep);
                }));
                framesInfo = initialData.frames.filter((_, idx) => framesIndexes.has(idx))
            } else {
                framesInfo = initialData.frames;
            }

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The solution with frame names looks like a dirty hack

Why it looks this way, if it's a constant defined by the server specifically for this?

What to you think about this one?

The formula part dataFrameNumber - this.startFrame is not correct in cases with nonzero start frame and frame step. In meta start_frame, stop_frame, and included_frames contain input data frame numbers (absolute ones). The correct way would be to obtain the original data frame number, then find the corresponding included_frames index.

Copy link
Member

Choose a reason for hiding this comment

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

Why it looks this way, if it's a constant defined by the server specifically for this?

Because as you mentioned, user may have files named placeholder.jpg, what potentially may lead to bugs
We should not consider such solutions

Copy link
Member

Choose a reason for hiding this comment

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

The formula part dataFrameNumber - this.startFrame is not correct in cases with nonzero start frame and frame step

I tested it in this case, and it seems to work in cases with non-zero start frame and frame step !== 1. Not really understand from your explanation why it should not.

In meta start_frame, stop_frame, and included_frames contain input data frame numbers (absolute ones)

Yes. We want to map absolute frame number to segment frame number, using the formula above.
Then, as for GT jobs meta returns info about all frames in the task, from 1st one, we do assumption, that frame number == frame index.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ok, looks good to me. Added some explanatory comments why it works.

@zhiltsov-max zhiltsov-max force-pushed the zm/fix-included-frame-handling branch from 11a3be6 to 10fca7c Compare March 3, 2025 09:41
Copy link

sonarqubecloud bot commented Mar 3, 2025

@bsekachev bsekachev merged commit a9f8e09 into develop Mar 3, 2025
34 checks passed
@zhiltsov-max zhiltsov-max deleted the zm/fix-included-frame-handling branch March 3, 2025 12:38
@cvat-bot cvat-bot bot mentioned this pull request Mar 3, 2025
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.

Incorrect data returned in frames meta request for a ground truth job
3 participants