Skip to content

Commit cf08abc

Browse files
JazzTapyining1023
authored andcommitted
patch style transfer for non-square and canvas-derived inputs (#311)
1 parent a5d597d commit cf08abc

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

src/StyleTransfer/index.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,9 @@ class StyleTransfer extends Video {
8989
let input;
9090
let callback = cb;
9191

92-
if (inputOrCallback instanceof HTMLVideoElement || inputOrCallback instanceof HTMLImageElement) {
92+
if (inputOrCallback instanceof HTMLVideoElement ||
93+
inputOrCallback instanceof HTMLImageElement ||
94+
inputOrCallback instanceof ImageData) {
9395
input = inputOrCallback;
9496
} else if (typeof inputOrCallback === 'object' && (inputOrCallback.elt instanceof HTMLVideoElement || inputOrCallback.elt instanceof HTMLImageElement)) {
9597
input = inputOrCallback.elt;

src/utils/imageUtilities.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ const processVideo = (input, size, callback = () => {}) => {
2424

2525
// Converts a tf to DOM img
2626
const array3DToImage = (tensor) => {
27-
const [imgWidth, imgHeight] = tensor.shape;
27+
const [imgHeight, imgWidth] = tensor.shape;
2828
const data = tensor.dataSync();
2929
const canvas = document.createElement('canvas');
3030
canvas.width = imgWidth;

0 commit comments

Comments
 (0)