Skip to content

Commit 8486af6

Browse files
committedJan 8, 2023
Removed API
1 parent 5baf0ff commit 8486af6

File tree

4 files changed

+3
-79
lines changed

4 files changed

+3
-79
lines changed
 

‎components/ML.js

+1-6
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,8 @@
11
import React from "react";
2-
import { Readable } from "stream";
32
import * as tf from "@tensorflow/tfjs";
4-
import { model } from "@tensorflow/tfjs";
53

64
// Create a function to classify the image with a Readable stream
75
const classifyImage = async (image) => {
8-
//const readStream = Readable.from(image);
9-
//const tf = await loadTf(readStream);
10-
116
let Model;
127

138
function indexOfMax(arr) {
@@ -30,7 +25,7 @@ const classifyImage = async (image) => {
3025

3126
if (!Model) {
3227
console.log(tf);
33-
// Make sure to update the MODEL_URL environment variable on Vercel (or .env file) to point to the model.json on /public. Does not work on localhost or with a local file path.
28+
// Make sure to update the NEXT_PUBLIC_MODEL_URL environment variable on Vercel (or .env file) to point to the model.json file
3429
Model = await tf.loadGraphModel(process.env.NEXT_PUBLIC_MODEL_URL);
3530
}
3631

‎components/Viewer.js

+1-21
Original file line numberDiff line numberDiff line change
@@ -27,29 +27,9 @@ const Viewer = (props) => {
2727
setNext(false);
2828
};
2929

30-
const fetchData = async () => {
31-
/*
32-
try {
33-
const res = await fetch("/api/ml", {
34-
method: "POST",
35-
headers: {
36-
Accept: "application/json",
37-
"Content-Type": "application/json",
38-
},
39-
body: JSON.stringify({ image: image }),
40-
});
41-
const data = await res.json();
42-
return data;
43-
} catch (err) {
44-
console.log(err);
45-
}
46-
*/
47-
return classifyImage(image);
48-
};
49-
5030
useEffect(() => {
5131
const run = async () => {
52-
const data = await fetchData();
32+
const data = await classifyImage(image);
5333
props.setTensor(data.tensor);
5434
props.setPred(parseInt(data.number));
5535
setPlastic(data.number);

‎pages/api/ml.js

-51
This file was deleted.

‎public/sw.js.map

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)
Please sign in to comment.