tfjs-react
Version:
Various React components for tensorflow.js
35 lines • 1.48 kB
JavaScript
var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
Object.defineProperty(exports, "__esModule", { value: true });
var React = require("react");
var tf = require("@tensorflow/tfjs");
var ImageTensor = /** @class */ (function (_super) {
__extends(ImageTensor, _super);
function ImageTensor(props) {
var _this = _super.call(this, props) || this;
_this._canvasElem = React.createRef();
return _this;
}
ImageTensor.prototype.componentDidMount = function () {
return tf.toPixels(this.props.tensor, this._canvasElem.current);
};
ImageTensor.prototype.render = function () {
return (React.createElement(React.Fragment, null,
React.createElement("canvas", { ref: this._canvasElem, width: this.props.width, height: this.props.height })));
};
return ImageTensor;
}(React.Component));
exports.ImageTensor = ImageTensor;
//# sourceMappingURL=image-tensor.js.map
;