Resetting animation

Hello, I am new to p5.js. I am trying to reset the animation based on an event. Running into an issue where every tie my label value is 2, it just shows the same animation.

function draw() {
  background(255, 120, 120);
  // Draw the video
  image(flippedVideo, 0, 0);

  // Draw the label
  fill(255);
  textSize(16);
  textAlign(CENTER);
  text(label, width / 2, height - 4);
  var row = 0;
  var col = 0;
  var squareSize = 0;
  var speed = 0.03;
  phase = frameCount*speed;

  for(col = 0; col<numCols; col+=1) {
      for (row = 0; row < numRows; row += 1) {
        var pos_y = height / 3.5 + row * 20;
        var pos_x = width / 3.5 + col * 20;

        var sizeOffset = sin(col / (phase*row));

        // This label is from a class label generated in tensorflow
        if(label == "Class 2"){
          squareSize = sizeOffset * maxSquareSize;
        }else{
          squareSize = maxSquareSize;
        }
        square(pos_x, pos_y, squareSize);
      }
  }
}

Hello and welcome to the forum!

Great to have you here!

I don’t think == works well with String

instead try

label.equals( "Class 2" )

Chrisir