Skip to content

Commit 27b1759

Browse files
committed
update StyleTransfer
1 parent 0a2bec8 commit 27b1759

File tree

2 files changed

+16
-10
lines changed

2 files changed

+16
-10
lines changed

src/StyleTransfer/index.js

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,20 +16,15 @@ import { array3DToImage } from '../utils/imageUtilities';
1616
const IMAGE_SIZE = 200;
1717

1818
class StyleTransfer extends Video {
19-
constructor(model, videoOrCallback, cb = () => {}) {
20-
super(videoOrCallback, IMAGE_SIZE);
19+
constructor(model, video, callback) {
20+
super(video, IMAGE_SIZE);
2121
this.ready = false;
2222
this.variableDictionary = {};
2323
this.timesScalar = tf.scalar(150);
2424
this.plusScalar = tf.scalar(255.0 / 2);
2525
this.epsilonScalar = tf.scalar(1e-3);
2626
this.video = null;
2727

28-
let callback = cb;
29-
if (typeof videoOrCallback === 'function') {
30-
callback = videoOrCallback;
31-
}
32-
3328
if (this.videoElt) {
3429
this.loadVideo().then(() => {
3530
this.videoReady = true;
@@ -140,4 +135,15 @@ class StyleTransfer extends Video {
140135
}
141136
}
142137

143-
export default StyleTransfer;
138+
const styleTransfer = (model, videoOrCallback, cb = () => {}) => {
139+
const video = videoOrCallback;
140+
let callback = cb;
141+
142+
if (typeof videoOrCallback === 'function') {
143+
callback = videoOrCallback;
144+
}
145+
146+
return new StyleTransfer(model, video, callback);
147+
};
148+
149+
export default styleTransfer;

src/index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import Word2Vec from './Word2vec/';
1111
import YOLO from './YOLO';
1212
import poseNet from './PoseNet';
1313
import * as imageUtils from './utils/imageUtilities';
14-
import StyleTransfer from './StyleTransfer/';
14+
import styleTransfer from './StyleTransfer/';
1515
import LSTMGenerator from './LSTM/';
1616

1717
module.exports = {
@@ -20,7 +20,7 @@ module.exports = {
2020
pitchDetection,
2121
YOLO,
2222
Word2Vec,
23-
StyleTransfer,
23+
styleTransfer,
2424
poseNet,
2525
LSTMGenerator,
2626
...imageUtils,

0 commit comments

Comments
 (0)