Check if HTMLCanvasElement exists (i.e. we are not running in a webworker) (#22153)
This fixes #22152
### Description
Tensor.fromImage fails in a webworker context, because HTMLCanvasElement
does not exist:
> HTMLCanvasElement is not defined
### Motivation and Context
This fixes #22152
---------
Co-authored-by: Yulong Wang <7679871+fs-eire@users.noreply.github.com>