<!DOCTYPE article PUBLIC "-//NLM//DTD JATS (Z39.96) Journal Archiving and Interchange DTD v1.0 20120330//EN" "JATS-archivearticle1.dtd">
<article xmlns:xlink="http://www.w3.org/1999/xlink">
  <front>
    <journal-meta />
    <article-meta>
      <title-group>
        <article-title>Few-shot Keypose Detection for Learning of Psychomotor Skills</article-title>
      </title-group>
      <contrib-group>
        <contrib contrib-type="author">
          <string-name>Benjamin Paaßen</string-name>
        </contrib>
        <contrib contrib-type="author">
          <string-name>Tobias Baumgartner</string-name>
        </contrib>
        <contrib contrib-type="author">
          <string-name>Mai Geisen</string-name>
        </contrib>
        <contrib contrib-type="author">
          <string-name>Nina Riedl</string-name>
        </contrib>
        <contrib contrib-type="author">
          <string-name>Miloš Kravčík</string-name>
        </contrib>
      </contrib-group>
      <abstract>
        <p>Some psychomotor tasks require students to perform a specific sequence of poses and motions. A natural teaching scheme for such tasks is to contrast a student's execution to a teacher demonstration. However, this requires strategies to match the teacher demonstration of each motion to the student's attempts and to identify diferences between demonstration and attempt. In this paper, we investigate methods to automatically detect student attempts for poses with only a single correct teacher demonstration. We investigate relevance learning, prototype networks, and attention mechanisms to achieve a robust few-shot approach which generalizes across students. In an experiment with one teacher and 27 students performing a sequence of motion elements from the field of fitness and dance, we show that prototype networks combined with an attention mechanism perform best.s</p>
      </abstract>
      <kwd-group>
        <kwd>eol&gt;psychomotor training</kwd>
        <kwd>few-shot learning</kwd>
        <kwd>metric learning</kwd>
        <kwd>prototype networks</kwd>
        <kwd>convolutional neural networks</kwd>
      </kwd-group>
    </article-meta>
  </front>
  <body>
    <sec id="sec-1">
      <title>1. Introduction</title>
      <p>
        Some psychomotor skills require us to execute a specific sequence of poses, such as in dance
choreographies, as well as during the repetitive execution of fitness moves, e.g. squats. While
research has emphasized the need for holistic teaching beyond mere imitation [
        <xref ref-type="bibr" rid="ref1">1</xref>
        ], at least part
of beginner’s training is concerned with getting the basic set of poses correctly executed [
        <xref ref-type="bibr" rid="ref2">2</xref>
        ].
Our aim is to automate some of this basic teaching by contrasting a student’s current motion
with a teacher demonstration and highlighting diferences [
        <xref ref-type="bibr" rid="ref3">3</xref>
        ]. However, to correctly compare
student and teacher motion, we need to establish a matching between both sequences of poses.
Typically, matchings between sequences are performed via alignment distances such as dynamic
time warping [
        <xref ref-type="bibr" rid="ref2 ref4">4, 2</xref>
        ]. However, such techniques are ill-suited to our scenario, where correct
execution only depends on poses, not on the transition motion between poses. Our goal is to
recognize the few points in time where the student’s attempted a certain pose and contrast the
student’s execution to the teacher’s demonstration of the same pose.
      </p>
      <p>
        An additional challenge is posed by the scarcity of training data. For any specific pose,
we expect only a single (correct) demonstration by a teacher and only few annotated student
sequences. In other words, we are confronted with a few-shot learning setting, where we need
to share as much information across poses as possible to learn a viable model. In particular, we
draw upon prior work on prototype networks [
        <xref ref-type="bibr" rid="ref5">5</xref>
        ] and metric learning [
        <xref ref-type="bibr" rid="ref6">6</xref>
        ]. Prototype networks
would map each frame of student motion  at time  and each teacher demonstration  for
pose  to auxiliary representations  () and  (), and detect pose  at time  if the distance
between  () and  () is low.
      </p>
      <p>
        By contrast, metric learning is concerned with finding a distance function  such that the
distance (, ) is low if  and  should be close and large if  and  should not be close [
        <xref ref-type="bibr" rid="ref6">6</xref>
        ]. In
our setting, we wish to learn a distance such that (, ) is small if the student attempted
pose  in frame  and large, otherwise. A special kind of metric learning is to learn weights  
for each dimension . If these weights are non-negative, such a weighting becomes equivalent
to an attention mechanism, where we interpret a large   as paying attention to dimension ,
whereas small   means that dimension  is unimportant for the current decision [
        <xref ref-type="bibr" rid="ref7">7</xref>
        ].
      </p>
      <p>Our contribution in this work is that we combine prototypical networks with an attention
mechanism for the purpose of keypose recognition, where such techniques have not yet been
applied, to the best of our knowledge.</p>
    </sec>
    <sec id="sec-2">
      <title>2. Method</title>
      <p>Our task is to recognize times  when a student tried to execute a certain pose . More specifically,
we record the motion of a student with a Kinect camera, yielding a time series 1, 2, . . . ,  ,
where each  is a 26 × 3 matrix, storing the 3D position of 26 joints of the human body at frame
. We wish to compare the student’s frames to expert demonstrations 1, . . . ,  for each of
the  poses and recognize frames where the student attempted a pose. Our basic approach
is to compute some distance (, ) between student frames and teacher demonstrations
and recognize pose  at time , whenever (, ) &lt;  for some threshold  . However, the
Euclidean distance on the raw 3D positions is not suitable because it would be disturbed by
diferences in body size and orientation, as well as deviances in joints that are irrelevant for the
specific pose (Fig. 1, a).</p>
      <p>To account for body size and orientation diferences, we first translate the time series to
angular space, in particular the azimuth and elevation of a joint compared to its parent joint in
the human skeleton (Fig. 1, b). Further, we apply learnable weights  , for each pose  and
each joint , resulting in the distance (, )2 = ∑︀2=61  , · ‖ , − ,‖2 (Fig. 1, c).</p>
      <p>To learn the weights  ,, we require training data where the correct matching between
student and teacher is known. In particular, assume that we have one time series 1 , . . . , 

per student . For each of these time series, assume that experts provided a label sequence
1 ,, . . . , , for each pose , where , = 1 if pose  should be recognized at time , , = 0
if pose  should not be recognized at time , and 
, = − 1 if we consider it irrelevant whether
pose  is recognized at time  or not.
a) Euclidean distance
b) angular distance
c) weighted ang. distance d) embedding distance</p>
      <p>yt,k = 1</p>
      <p>Given this kind of training data, we learn the weights  , by minimizing the contrastive loss

ℓ = ∑︁ ∑︁
∑︁
(, )2 +
∑︁ [︀ 1 − (, )2]︀ +,
(1)
 =1 :,=1
:,=0
where [1 − ]+ = max{0, 1 − }. This loss punishes large distances (, ) if 
, = 1 and
distances below 1 if</p>
      <p>
        , = 0 (Fig. 2). In other words, this loss tries to ensure that we can
recognize pose  correctly by checking if (, ) is smaller than  = 1. We can optimize this
loss by standard, gradient-based non-linear techniques, such as L-BFGS. We call this approach
relevance learning, in line with [
        <xref ref-type="bibr" rid="ref8">8</xref>
        ].
      </p>
      <p>
        Note that this scheme is, essentially, a simple metric learning scheme [
        <xref ref-type="bibr" rid="ref6 ref8">6, 8</xref>
        ]. It is also nicely
intepretable because we can inspect the learned weights  , and check whether they make
sense to a domain expert. Further, we can provide feedback by highlighting joints  to students
where the weighted deviation  , · ‖ , − ,‖2 is large. For example, imagine a virtual mirror
with an avatar of the student where the avatar’s joint  is color-coded as red, similar to the
scheme of [
        <xref ref-type="bibr" rid="ref2">2</xref>
        ].
      </p>
      <p>
        Unfortunately, relevance learning is limited to situations where the set of poses is fully known.
For every new pose , we need to record new training data to train new weights  ,, which
may be infeasible. Instead, we would prefer an approach which can be applied to new poses
without any re-training. To that end, we apply a two-layer feedforward neural network  which
receives the expert demonstration  of a pose as input and maps it to weights  , = ().
By applying a sigmoid nonlinearity, we ensure that the weights remain in the range [
        <xref ref-type="bibr" rid="ref1">0, 1</xref>
        ]. This
is, essentially, an attention mechanism, which have become popular for speech processing [
        <xref ref-type="bibr" rid="ref7">7</xref>
        ].
We call this approach attention net and train it with the same contrastive loss (1) as before.
      </p>
      <p>
        In addition to the attention mechanism, we also test the efect of a refined motion
representation. In particular, we use a 1D convolution with kernel length 31 and 32 filters, followed
by a sigmoid nonlinearity and a linear layer which reduces the 32 filter dimensions to a
single number1. Finally, we apply another sigmoid nonlinearity and a linear layer from the 26
joints to  latent dimensions which integrates information across joints. Overall, we obtain
an -dimensional representation  () of each motion frame . We compare to the correct
demonstration  () via the distance (, )2 = ∑︀=1 () · (︀ () − ()︀) 2 (Fig. 1,
d). We learn all neural network parameters by minimizing loss (1), but we add a regularization
term  · ∑︀=− 11‖ () −  (− 1)‖2 to ensure that the learned motion representation is smooth
over time. We call this approach prototype attention net because it integrates the concept of the
attention net with the representation approach of prototypical networks [
        <xref ref-type="bibr" rid="ref5">5</xref>
        ].
      </p>
      <p>As a final model, we also consider a prototype net where we omit the attention net and set
the weights () to 1, instead.</p>
    </sec>
    <sec id="sec-3">
      <title>3. Experiments</title>
      <p>We compare relevance learning, attention net, prototype net, and prototype attention net on
a dataset of 27 students and one teacher, all executing a series of 25 fitness and dance motion
elements (namely squat, raise arms (2x), tree squat, “pirate” (6x), elbow to knee (3x), crossover
(2x), airplane, airplane squat, standing, lunge (4x), T-pose, clock (2x)) while being recorded with
a Kinect camera. We had 15 female and 12 male participants with mean age 27 (std. 4.49 years).
Table 1 displays the self-reported prior experience of the participants with sports in general
and video tutorials in particular.</p>
      <p>We note that the annotators only annotated the first frame where the students attempted a
certain pose. To arrive at complete labels ,, we used a heuristic scheme where we automatically
labeled 30 frames after the actual annotation with 
, = 1 and extended the annotation further
as long as the 3D marker positions did not change beyond 5 times the average distance between
adjacent frames. We further set</p>
      <p>, = − 1 for the 30 frames before and after the annotated
132 was chosen as the next power of 2 above the number of keyposes, which was 25. However, future work
could investigate more hyperparameter combinations.
region to ignore cases where the students was already/still close to the target pose but not close
enough to count as training data.</p>
      <p>Even after this preprocessing, though, our dataset is highly imbalanced: 
, = 1 is relatively
rare, whereas</p>
      <p>, = 0 is common. Accordingly, we do not report accuracy but recall, precision,
and F1 score, as well as the area under the precision-recall curve (AUC).</p>
      <p>Table 2 shows the results. As we can see, the prototype attention net performs best, according
to all measures. A Wilcoxon signed-rank test revealed that the AUC for relevance learning
and the attention net were both significantly lower (  &lt; 10− 3) but the AUC of prototype
net and prototype attention net was statistically indistinguishable. This finding indicates that
representation learning is more crucial than joint weighting in achieving good keypose detection
results, at least on this particular dataset.</p>
    </sec>
    <sec id="sec-4">
      <title>4. Conclusion</title>
      <p>We considered the problem of keypose detection for a sequence fitness and dance motion
elements in a few-shot setting, where only a single teacher demonstration and few student
demonstrations per pose exist. To detect keyposes, we evaluated methods which compute a
distance between teacher demonstrations and student frames and detect a keypose if the distance
is below 1. We compared several schemes to arrive at a distance, namely (1) relevance learning,
which optimized joint weights for each keypose, (2) an attention neural net which inferred
the joint weights from the respective teacher demonstration, (3) a prototype network which
represented both teacher and student motion in a latent space before computing distance, and
(4) a combination of prototype and attention network. As expected, the prototype attention net
(4) performed best but we found that the prototype net (3) performed nearly as well. Therefore,
we conclude that representation learning is more crucial compared to attention, at least for our
example.</p>
      <p>In future work, it should be investigated how well a prototype network generalizes to
new keyposes it was not trained on and how far performance can be improved with refined
architectures. Beyond keypose detection, future work should investigate the ability to recognize
entire motion, in addition to purely static poses. For all these future research opportunities, we
believe that our proposed loss function and training scheme can contribute to robust detection
approaches, which in turn can become a crucial component for new feedback methods in
psychomotor learning.</p>
    </sec>
    <sec id="sec-5">
      <title>Acknowledgments</title>
      <p>Funding by the German Federal Ministry for Research and Education (BMBF) for the project
MILKI-PSY (grant no. 16DHB4014) is gratefully acknowledged.</p>
    </sec>
  </body>
  <back>
    <ref-list>
      <ref id="ref1">
        <mixed-citation>
          [1]
          <string-name>
            <given-names>S.</given-names>
            <surname>Anu</surname>
          </string-name>
          ,
          <string-name>
            <given-names>V.</given-names>
            <surname>Ele</surname>
          </string-name>
          ,
          <article-title>Teaching dance in the 21st century: A literature review</article-title>
          ,
          <source>The European Journal of Social &amp; Behavioural Sciences</source>
          <volume>7</volume>
          (
          <year>2013</year>
          )
          <fpage>624</fpage>
          -
          <lpage>640</lpage>
          . doi:
          <volume>10</volume>
          .15405/ejsbs.
          <year>2013</year>
          .
          <article-title>7</article-title>
          . issue-4.
        </mixed-citation>
      </ref>
      <ref id="ref2">
        <mixed-citation>
          [2]
          <string-name>
            <given-names>F.</given-names>
            <surname>Hülsmann</surname>
          </string-name>
          ,
          <string-name>
            <given-names>C.</given-names>
            <surname>Frank</surname>
          </string-name>
          , I. Senna,
          <string-name>
            <given-names>M. O.</given-names>
            <surname>Ernst</surname>
          </string-name>
          ,
          <string-name>
            <given-names>T.</given-names>
            <surname>Schack</surname>
          </string-name>
          ,
          <string-name>
            <given-names>M.</given-names>
            <surname>Botsch</surname>
          </string-name>
          ,
          <article-title>Superimposed skilled performance in a virtual mirror improves motor performance and cognitive representation of a full body motor action</article-title>
          ,
          <source>Frontiers in Robotics and AI</source>
          <volume>6</volume>
          (
          <year>2019</year>
          )
          <article-title>43</article-title>
          . doi:
          <volume>10</volume>
          .3389/frobt.
          <year>2019</year>
          .
          <volume>00043</volume>
          .
        </mixed-citation>
      </ref>
      <ref id="ref3">
        <mixed-citation>
          [3]
          <string-name>
            <given-names>B.</given-names>
            <surname>Paaßen</surname>
          </string-name>
          ,
          <string-name>
            <given-names>M.</given-names>
            <surname>Kravčík</surname>
          </string-name>
          ,
          <article-title>Teaching psychomotor skills using machine learning for error detection</article-title>
          , in: R.
          <string-name>
            <surname>Klemke</surname>
            ,
            <given-names>K.</given-names>
          </string-name>
          <string-name>
            <surname>Asyraaf Mat Sanusi</surname>
          </string-name>
          , et al. (Eds.),
          <source>Proceedings of the 1st International Workshop on Multimodal Immersive Learning Systems (MILeS</source>
          <year>2021</year>
          ),
          <year>2021</year>
          , p.
          <fpage>8</fpage>
          -
          <lpage>14</lpage>
          . URL: http://ceur-ws.
          <source>org/</source>
          Vol-
          <volume>2979</volume>
          /paper1.pdf.
        </mixed-citation>
      </ref>
      <ref id="ref4">
        <mixed-citation>
          [4]
          <string-name>
            <given-names>T. K.</given-names>
            <surname>Vintsyuk</surname>
          </string-name>
          ,
          <article-title>Speech discrimination by dynamic programming</article-title>
          ,
          <source>Cybernetics</source>
          <volume>4</volume>
          (
          <year>1968</year>
          )
          <fpage>52</fpage>
          -
          <lpage>57</lpage>
          . doi:
          <volume>10</volume>
          .1007/BF01074755.
        </mixed-citation>
      </ref>
      <ref id="ref5">
        <mixed-citation>
          [5]
          <string-name>
            <given-names>J.</given-names>
            <surname>Snell</surname>
          </string-name>
          ,
          <string-name>
            <given-names>K.</given-names>
            <surname>Swersky</surname>
          </string-name>
          ,
          <string-name>
            <given-names>R.</given-names>
            <surname>Zemel</surname>
          </string-name>
          ,
          <article-title>Prototypical networks for few-shot learning</article-title>
          , in: I. Guyon,
          <string-name>
            <given-names>U. V.</given-names>
            <surname>Luxburg</surname>
          </string-name>
          ,
          <string-name>
            <given-names>S.</given-names>
            <surname>Bengio</surname>
          </string-name>
          , et al. (Eds.),
          <source>Proc. NeurIPS</source>
          ,
          <year>2017</year>
          , pp.
          <fpage>4077</fpage>
          -
          <lpage>4087</lpage>
          .
        </mixed-citation>
      </ref>
      <ref id="ref6">
        <mixed-citation>
          [6]
          <string-name>
            <given-names>A.</given-names>
            <surname>Bellet</surname>
          </string-name>
          ,
          <string-name>
            <given-names>A.</given-names>
            <surname>Habrard</surname>
          </string-name>
          ,
          <string-name>
            <given-names>M.</given-names>
            <surname>Sebban</surname>
          </string-name>
          ,
          <article-title>A survey on metric learning for feature vectors and structured data</article-title>
          ,
          <source>arXiv 1306.6709</source>
          (
          <year>2014</year>
          ).
        </mixed-citation>
      </ref>
      <ref id="ref7">
        <mixed-citation>
          [7]
          <string-name>
            <given-names>A.</given-names>
            <surname>Vaswani</surname>
          </string-name>
          ,
          <string-name>
            <given-names>N.</given-names>
            <surname>Shazeer</surname>
          </string-name>
          ,
          <string-name>
            <given-names>N.</given-names>
            <surname>Parmar</surname>
          </string-name>
          ,
          <string-name>
            <given-names>J.</given-names>
            <surname>Uszkoreit</surname>
          </string-name>
          ,
          <string-name>
            <given-names>L.</given-names>
            <surname>Jones</surname>
          </string-name>
          ,
          <string-name>
            <given-names>A. N.</given-names>
            <surname>Gomez</surname>
          </string-name>
          , L. u. Kaiser,
          <string-name>
            <surname>I. Polosukhin</surname>
          </string-name>
          ,
          <article-title>Attention is all you need</article-title>
          , in: I. Guyon,
          <string-name>
            <given-names>U. V.</given-names>
            <surname>Luxburg</surname>
          </string-name>
          ,
          <string-name>
            <given-names>S.</given-names>
            <surname>Bengio</surname>
          </string-name>
          , et al. (Eds.),
          <source>Proc. NeurIPS</source>
          ,
          <year>2017</year>
          , pp.
          <fpage>5998</fpage>
          -
          <lpage>6008</lpage>
          .
        </mixed-citation>
      </ref>
      <ref id="ref8">
        <mixed-citation>
          [8]
          <string-name>
            <given-names>B.</given-names>
            <surname>Hammer</surname>
          </string-name>
          , T. Villmann,
          <article-title>Generalized relevance learning vector quantization</article-title>
          ,
          <source>Neural Networks</source>
          <volume>15</volume>
          (
          <year>2002</year>
          )
          <fpage>1059</fpage>
          -
          <lpage>1068</lpage>
          . doi:
          <volume>10</volume>
          .1016/S0893-
          <volume>6080</volume>
          (
          <issue>02</issue>
          )
          <fpage>00079</fpage>
          -
          <lpage>5</lpage>
          .
        </mixed-citation>
      </ref>
    </ref-list>
  </back>
</article>