Added Salvi's backend folder from backend branch to allow ombase to continue testing.

This commit is contained in:
K
2025-02-23 09:05:16 +05:30
parent 3f9e6d3dee
commit 7da2809399
28 changed files with 6979 additions and 0 deletions
+31
View File
@@ -0,0 +1,31 @@
import { pipeline } from "@xenova/transformers";
import Jimp from "jimp";
async function main() {
const modelName = "Xenova/distilbert-base-uncased-finetuned-sst-2-english"; // Example model
// Load the model
const classifier = await pipeline("image-classification", modelName);
// Load the image
let image;
try {
image = await Jimp.read("/home/karan/Downloads/tomato.png");
image.rgba(true);
} catch (error) {
console.error("Error: Unable to open image. Check the file type or path.");
console.error(error);
return;
}
// Convert image to buffer
const buffer = await image.getBufferAsync(Jimp.MIME_PNG);
// Classify the image
const result = await classifier(buffer);
console.log("Predicted class:", result);
}
main().catch(console.error);