@@ -338,6 +338,75 @@ train_command \
338
338
task_name=my_m2_training
339
339
```
340
340
341
+ ## The Global Step Predictor (GSP)
342
+ ### How the GSP relates to the TCN Activity Classifier
343
+
344
+ The above TCN activity classifier in its current configuration takes in a second or
345
+ two of video artifacts (e.g. for the "Locs&Confs" version, pose joint pixel coordinates
346
+ and confidences, the user's hand detection locations and confidences, and other procedure-relevant
347
+ object pixel coordinates and confidences), and outputs confidences for each of a vector
348
+ of activities (examples: "labels" in config/activity_labels/medical), assuming up to
349
+ one activity is ocurring "presently."
350
+
351
+ Now, the GSP takes as input the confidence vector per frame window, and keeps track over time of which
352
+ activities ("steps" in the GSP context) have occurred, and which step a user is on.
353
+
354
+ Basically, if the "next step" at any point has been activated long enough, and with enough confidence,
355
+ the GSP progresses to that step as the latest "completed" step.
356
+
357
+ Assumptions:
358
+ - One activity or "background" (none of the listed activities) happens at a time.
359
+ - The activities must happen in a specific linear order.
360
+ - So, if an activity is detected with strong confidence way out of order (e.g. we're on step 3
361
+ and we detect step 8), the GSP does not mark step 8 as completed.
362
+ - A single "skipped step" is possible given some criteria. Skipping one step can be allowed unconditionally.
363
+ Skipping one step can also be allowed if the "skipped step" has been activated with some "easier" criteria
364
+ (a lower confidence threshold and/or fewer frames above that threshold). We can also configure to skip one step
365
+ simply given that a threshold number of frames have passed since we completed the most recent step.
366
+
367
+ ### Training the GSP
368
+
369
+ To "train" the GSP, we simply compute the average true positive output scores per class- that is, the
370
+ average confidence of each TCN activity classification in its output vector,
371
+ only when ground truth states that activity is happening. This includes the background class.
372
+
373
+ To do this, we must run inference on videos for which the TCN has never seen ground truth (and are hopefully
374
+ quite independent from the training videos). The validation or test splits of your dataset may suffice.
375
+ * Note:* If you have run training, test set prediction outputs should have been produced, in a
376
+ file named ` tcn_activity_predictions.kwcoco.json ` .
377
+
378
+ If you don't have that file, he TCN's training harness can be run with ` train=false ` to only run
379
+ inference and save the test data's output in the needed KWCOCO output format. Example:
380
+
381
+ ```
382
+ python train_command \
383
+ experiment=r18/feat_locsconfs \
384
+ paths.root_dir=/path/to/my/data/splits/ \ # See above TCN docs for training data structure
385
+ task_name=r18_my_TCN_i_just_trained \
386
+ train=false \
387
+ ckpt_path=model_files/activity_classifier/r18_tcn.ckpt \
388
+ ```
389
+
390
+ This should create a new predictions output file, e.g. ` tcn_activity_predictions.kwcoco.json ` .
391
+
392
+ Then, for each class, we filter the video outputs by those which the ground truth indicates that class
393
+ activity is occurring. Then we simply average the TCN output for that activity, for those frames.
394
+
395
+ Given the test dataset split ground truth you just gave as input to the ` train_command ` , and the predictions
396
+ output file your ` train_command ` produced, create the average TP activation numpy file as follows:
397
+
398
+ ```
399
+ python angel_system/global_step_prediction/run_expirement.py r18 \
400
+ path/to/TEST-activity_truth.coco.json \
401
+ path/to/tcn_activity_predictions.kwcoco.json \
402
+ path/to/tcn_activity_predictions.kwcoco.json
403
+
404
+ ```
405
+
406
+ That numpy file then can be provisioned to load to the default GSP ` model_files ` filepath, e.g. in the case
407
+ of the R18 task, ` model_files/task_monitor/global_step_predictor_act_avgs_r18.npy ` .
408
+
409
+
341
410
## Docker local testing
342
411
343
412
*** to start the service run:***
0 commit comments