Skip to content

Commit

Permalink
patch style transfer for non-square and canvas-derived inputs (#311)
Browse files Browse the repository at this point in the history
  • Loading branch information
JazzTap authored and yining1023 committed Mar 15, 2019
1 parent 7d7600e commit fc311e3
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
4 changes: 3 additions & 1 deletion src/StyleTransfer/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,9 @@ class StyleTransfer extends Video {
let input;
let callback = cb;

if (inputOrCallback instanceof HTMLVideoElement || inputOrCallback instanceof HTMLImageElement) {
if (inputOrCallback instanceof HTMLVideoElement ||
inputOrCallback instanceof HTMLImageElement ||
inputOrCallback instanceof ImageData) {
input = inputOrCallback;
} else if (typeof inputOrCallback === 'object' && (inputOrCallback.elt instanceof HTMLVideoElement || inputOrCallback.elt instanceof HTMLImageElement)) {
input = inputOrCallback.elt;
Expand Down
2 changes: 1 addition & 1 deletion src/utils/imageUtilities.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ const processVideo = (input, size, callback = () => {}) => {

// Converts a tf to DOM img
const array3DToImage = (tensor) => {
const [imgWidth, imgHeight] = tensor.shape;
const [imgHeight, imgWidth] = tensor.shape;
const data = tensor.dataSync();
const canvas = document.createElement('canvas');
canvas.width = imgWidth;
Expand Down

0 comments on commit fc311e3

Please sign in to comment.