Skip to content

Commit

Permalink
Updated comments
Browse files Browse the repository at this point in the history
  • Loading branch information
GabrielDeml committed Feb 27, 2021
1 parent d464c4a commit 09d7e2d
Showing 1 changed file with 6 additions and 14 deletions.
20 changes: 6 additions & 14 deletions src/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,31 +24,23 @@ class App extends Component {
this.setState({ msg: '' })
}

// TODO: Figure out why this isn't being deffined
async testML(imgRef) {


const mobilenet = require('@tensorflow-models/mobilenet');

// const mobilenet = require('@tensorflow-models/mobilenet');
// Get the image reference
const img = tf.browser.fromPixels(imgRef.current);

// Convert the image to a 4d tensor
const smallImg = tf.image.resizeBilinear(img, [224, 224]);
const resized = tf.cast(smallImg, 'float32');
const t4d = tf.tensor4d(Array.from(resized.dataSync()), [1, 224, 224, 3])
// img.reshape(1, 224, 224, 3)

// Load the model.
// const model = await mobilenet.load();
const model = await tf.loadLayersModel('https://gabrieldeml.github.io/Cancer-Client/models/model.json');


// Classify the image.
const predictions = model.predict(t4d);

// Get the output
const value = predictions.dataSync()
// TODO show user the output of the predcition
console.log('Predictions: ');
console.log(value);
// Display the output of the classification
if (value[0] == 0) {
this.setState({ msg: 'malignant' })
} else {
Expand All @@ -73,7 +65,7 @@ class App extends Component {
return (
<div className="App">
<header className="App-header">
<h1>This isn't medical advice it just is a test</h1>
<h1>This is not medical advice it just is a test</h1>
<input type="file" accept="image/*" onChange={handleImageUpload} ref={imgRef} multiple="false" />
<img src={cat} ref={imgRef} />
<button onClick={() => this.testML(imgRef)}>Run model</button>
Expand Down

0 comments on commit 09d7e2d

Please sign in to comment.