Add support for model prediction in Video toolbar#271
Conversation
…r into wk9874/models/data_params
…model-prediction-untrained
…74/models/data_params
…redictions, imports, frame navigation, and propagation without refresh.
…r into wk9874/models/data_params
|
Model prediction boxes appear to not be selectable for some reason: toktagger_prediction_not_selectable.mp4 |
for some reason I cannot reproduce this model_predict_selection_bug.mp4 |
as discussed, this is actually working as expected based on how propagation is currently implemented. However now that model prediction is being integrated into toktagger I need to rethink how to only propagate hand drawn annotations and NOT propagate model predicted annotations. This will be tackled in a separate follow up PR / needs to be documented in an issue |
…l edits, and prevent Annotorious programmatic redraw events from being mistaken for user edits
|
Yep the instance numbering bug when importing looks fixed now :) other two I think are future work, have raised issues #275 #276 Found another bug, but I think this is probably a bug in my model Predict tooling implementation - if you ask for a model prediction on one frame, then go to the next frame and ask for a prediction on that one, itll remove the prediction from the first frame... suspect when I wrote the model predict tool only timeseries existed, and so it removes previous annotations from the given model before adding new ones (which ofc means that in the video case, it removes predictions from all frames before writing new predictions for the next requested frame). I'll look into fixing this today |
sounds good, let me know if I need to change anything on the ui side to fix the prediction bug you mentioned |
|
ready for code review @jblake42 |
jblake42
left a comment
There was a problem hiding this comment.
Mainly focussed on front end due to time constraints
| {" "} | ||
| <em>{schema.description}</em>{" "} | ||
| </Text> | ||
| // For some reason anything other than hard coding a size here |
There was a problem hiding this comment.
@wk9874 - was this fixed by setting the toolbar width. Can we remove the comment etc?
There was a problem hiding this comment.
Yep this is fixed, will remove the TODO
| updater: (annotations: Annotation[]) => Annotation[] | Annotation[], | ||
| ) => void; | ||
| setDataParams: (params: DataParams) => void; | ||
| setDataParams: React.Dispatch<React.SetStateAction<DataParams>>; |
There was a problem hiding this comment.
Is this typed like this for a reason or can we be consistent with the other instances below?
There was a problem hiding this comment.
Good spot, there wasn’t a good reason for it to be typed differently. I’ve changed setDataParams to match the other context setters and cleaned up the VideoView call site so the typing is simpler. fixed in commit ef902a8
| return prev; | ||
| } | ||
| return { | ||
| ...prev, |
There was a problem hiding this comment.
We should not need to expand the existing previous frame here as you are overwriting all existing data anyway:
return {
name: "image",
frame,
};
| ): ImageAnnotation { | ||
| return stampCreator(stampLabelAndTrack(a, className, trackId), createdBy); | ||
| } | ||
|
|
There was a problem hiding this comment.
The functions are a little messy here imo - you have split functionality into the different types of stamps and then combined them in higher level functions.
I personally think keep them all seperate and then chaining them at the point of use would improve the clarity rather than having multiple functions performing varying levels of stamping
| }; | ||
| } | ||
|
|
||
| /** Read backend creator metadata, falling back to manual at export time. */ |
There was a problem hiding this comment.
I think the comment is misleading - this function does not do any falling back as such, it just returns null. The logic that uses this does the falling back
There was a problem hiding this comment.
I think falling back to manual is valid, but in that case this function should return manual and then you don't have to repeat the line created_by: getAnnotationCreator(a) ?? "manual", you could just do created_by: getAnnotationCreator(a)
I don't mind either way but whichever you go for be clear in the comment
There was a problem hiding this comment.
I have gone with your second suggestion as I think a fall back to manual rather than null is more correct, so now the comment is actually correct. fixed in commit 2166214
| dbAnnotations={annotations ?? []} | ||
| setSampleAnnotations={setAnnotations} | ||
| propagate={videoPropagate} | ||
| setPropagate={setVideoPropagate} |
There was a problem hiding this comment.
There may be a good reason, but can the VideoSessionProvider not just grab the context itself rather than have the inner provider do it for it. It seems a bit redundant to me and bloats the props?
There was a problem hiding this comment.
I agree, there wasn’t a strong reason to pass those through as props since they all come from SampleContext. I’ve moved those context reads into VideoSessionProvider directly, so VideoProvidersInner now only passes the video-specific props it needs to. Fixed in commit d09152b
| continue; | ||
| } | ||
|
|
||
| entries.push( |
There was a problem hiding this comment.
Should we be more explicit here and check that the type is as we expect - this will catch if an additional type is added and the logic is not updated
| }); | ||
|
|
||
| const anno = | ||
| dbAnno.type === "video_bounding_box" |
There was a problem hiding this comment.
Same here with explicitly checking types
There was a problem hiding this comment.
There are other instances below - I won't comment them all
There was a problem hiding this comment.
There are other instances below - I won't comment them all
could you double check I got all the instances?
| setByFrame((prev) => mapSetFrame(prev, f, list)); | ||
| // Seeding should not mark the session dirty. | ||
| }, []); | ||
| useEffect(() => { |
There was a problem hiding this comment.
Keep useEffects grouped together
There was a problem hiding this comment.
done in commit 876420a
Could you double check this commit is what you wanted me to do?
| }, | ||
| [byFrame.size, dirty, projectId, sampleId], | ||
| ); | ||
| if (invalid > 0) { |
There was a problem hiding this comment.
Do duplicates frequently happen or is there any actions that need to be taken if duplicates happen - if they are frequent or there is no action to be taken we shouldn't flood the log
There was a problem hiding this comment.
Good point, this was just leftover debug-style logging for a handled cleanup path. I removed the warnings and kept the duplicate cleanup behavior unchanged so we do not flood the console. fixed in commit 0d18293
Prepare for 0.2.0 release
Fix Pages CI
…eContext setters.
…nd creator helper directly.
…FrameRef sync useEffect
…cleanup behavior
Removed comments about container width issue in schemaForm.
Description
Adds support for model predictions of single samples from the toolbar of the Video interface, to match what is available in time series.
Changes
/samples/{sample_id}/models/{type) for passing dataParams for the selected sample to the backend (so that, eg, the frame number is available to the model)To Test
Use
scripts.setupto create the local Frame Project, then go into there and 'train' a model with the button in the top right. Once trained, open the sample, and use the model prediction in the toolbar. Should be an option to either predict on only one frame, or all frames. Predictions will be a box of width 50, height 50 at (0,0) with the id 'test'.To clear previous predictions, press Clear at the top of the toolbar, then Save, then Clear again
To Dos
Noticed a formatting issue in the model schema form - checkbox and array element descriptions overfill the toolbar column when using the model predict sample tool, and no combination of widths / minWidth / maxWidth seemed to fix it. Currently have hardcoded the size to 2500, which makes it fit in the toolbar nicely, but means it looks odd in the predict modal. Need some help figuring out what is causing this issueFixed by Josh, setting max width of toolbarInside modelPredictSample there is now some video specific logic, which I would like to remove ideally. This is because theFixed by AbdullahdataParamsstored insidesampleContextare not guaranteed to be correct when in video mode, and you need to access the frame fromdatadirectly to reconstruct theeffectiveDataParams. Would prefer it to be that the dataParams in sampleContext is the single point of truth which both timeseries and video useUnlike timeseries, video doesn't seem to update annotations automatically based on whenFixed by abdullahsetAnnotationsis called from sampleContext. This means that once predictions are ready and returned from the backend,setAnnotationsis called, but you dont see any new boxes until you refresh. Would be good to have it work similarly to time series and auto update if possibleNote Do not merge until #255 is merged
Closes #240
Closes #246