diff --git a/src/components/Bai.js b/src/components/Bai.js index de52368..b8b44da 100644 --- a/src/components/Bai.js +++ b/src/components/Bai.js @@ -7,7 +7,7 @@ import './css/Bai.css'; class Bai extends React.Component { /** - * + * Blank AI - Artificial Intelligence designed to distinguish photos of blank vs. non-blank paper scans */ classes = {0: "Blank", 1: "Not Blank"} @@ -16,23 +16,22 @@ class Bai extends React.Component { document.title = "Blank AI"; } - async fileUpload ({target}) { - console.log(target); + async fileUpload (target, predict) { + const [file] = target.files; + let image = document.getElementById("preview") if (file) { - image.src = await URL.createObjectURL(file); - } - } - async imagePredict (model) { - let image = document.getElementById("preview"); - console.log(image.src); - if (image.src !== "") { - let prediction = await this.props.predict(image); - console.log(prediction[0]); + let imageBM = await createImageBitmap(file); + + let prediction = await predict(imageBM); + console.log(this.declassify(prediction[0])); + + image.src = await URL.createObjectURL(file); + image.classList.add('show'); } } @@ -58,14 +57,15 @@ class Bai extends React.Component { :(
{this.props.last_prediction ? this.declassify(this.props.last_prediction[0]):"Waiting for Prediction"}
+ +{this.props.last_prediction ? this.declassify(this.props.last_prediction[0]):"Waiting for Prediction"}