Merge branch 'main' into frontend-multilingual up to commit 0aa8a3842c
This commit is contained in:
@@ -0,0 +1,2 @@
|
|||||||
|
package-lock.json
|
||||||
|
node_modules/
|
||||||
@@ -2,7 +2,7 @@ const multer = require("multer");
|
|||||||
|
|
||||||
const storage = multer.diskStorage({
|
const storage = multer.diskStorage({
|
||||||
destination: function (req, file, cb) {
|
destination: function (req, file, cb) {
|
||||||
cb(null, "./public/images");
|
cb(null, "./uploads");
|
||||||
},
|
},
|
||||||
|
|
||||||
filename: function (req, file, cb) {
|
filename: function (req, file, cb) {
|
||||||
|
|||||||
Generated
+733
-3494
File diff suppressed because it is too large
Load Diff
+11
-14
@@ -10,23 +10,20 @@
|
|||||||
"license": "ISC",
|
"license": "ISC",
|
||||||
"description": "",
|
"description": "",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@google/generative-ai": "^0.22.0",
|
"@google/generative-ai": "^0.24.1",
|
||||||
"@huggingface/transformers": "^3.3.3",
|
"bcrypt": "^6.0.0",
|
||||||
"@xenova/transformers": "^2.17.2",
|
"cloudinary": "^2.7.0",
|
||||||
"bcrypt": "^5.1.1",
|
"cookie-parser": "^1.4.7",
|
||||||
"cloudinary": "^2.5.1",
|
|
||||||
"cookie-parser": "^1.4.6",
|
|
||||||
"cors": "^2.8.5",
|
"cors": "^2.8.5",
|
||||||
"dotenv": "^16.4.5",
|
"dotenv": "^16.5.0",
|
||||||
"express": "^4.19.2",
|
"express": "^5.1.0",
|
||||||
"jimp": "^1.6.0",
|
|
||||||
"jsonwebtoken": "^9.0.2",
|
"jsonwebtoken": "^9.0.2",
|
||||||
"mongoose": "^8.6.1",
|
"mongoose": "^8.16.0",
|
||||||
"multer": "^1.4.5-lts.1",
|
"multer": "^2.0.1",
|
||||||
"nodemailer": "^6.9.15",
|
"nodemailer": "^7.0.3",
|
||||||
"socket.io": "^4.7.5"
|
"socket.io": "^4.8.1"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"nodemon": "^3.1.4"
|
"nodemon": "^3.1.10"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -45,32 +45,34 @@ const Ai = () => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="max-w-md mx-auto p-6 bg-white shadow rounded-lg">
|
<div className="min-h-screen w-full flex items-center justify-center max-h-screen">
|
||||||
<h2 className="text-2xl font-bold mb-4 text-center">
|
<div className="max-w-md mx-auto p-6 bg-white shadow rounded-lg">
|
||||||
Plant disease prediction
|
<h2 className="text-2xl font-bold mb-4 text-center">
|
||||||
</h2>
|
Plant disease prediction
|
||||||
<form onSubmit={handleSubmit} className="space-y-4">
|
</h2>
|
||||||
<input
|
<form onSubmit={handleSubmit} className="space-y-4">
|
||||||
type="file"
|
<input
|
||||||
accept="image/*"
|
type="file"
|
||||||
onChange={handleFileChange}
|
accept="image/*"
|
||||||
className="block w-full text-sm text-gray-900 border border-gray-300 rounded-lg cursor-pointer bg-gray-50 p-2"
|
onChange={handleFileChange}
|
||||||
/>
|
className="block w-full text-sm text-gray-900 border border-gray-300 rounded-lg cursor-pointer bg-gray-50 p-2"
|
||||||
<button
|
/>
|
||||||
type="submit"
|
<button
|
||||||
disabled={loading || !selectedFile}
|
type="submit"
|
||||||
className="w-full bg-blue-600 hover:bg-blue-700 text-white py-2 px-4 rounded focus:outline-none focus:ring-2 focus:ring-blue-500"
|
disabled={loading || !selectedFile}
|
||||||
>
|
className="w-full bg-blue-600 hover:bg-blue-700 text-white py-2 px-4 rounded focus:outline-none focus:ring-2 focus:ring-blue-500"
|
||||||
{loading ? "Predicting..." : "Predict"}
|
>
|
||||||
</button>
|
{loading ? "Predicting..." : "Predict"}
|
||||||
</form>
|
</button>
|
||||||
{error && <p className="mt-4 text-center text-red-600">{error}</p>}
|
</form>
|
||||||
{prediction && (
|
{error && <p className="mt-4 text-center text-red-600">{error}</p>}
|
||||||
<div className="mt-4 p-4 bg-green-100 border border-green-300 rounded">
|
{prediction && (
|
||||||
<h3 className="text-lg font-semibold">Prediction:</h3>
|
<div className="mt-4 p-4 bg-green-100 border border-green-300 rounded">
|
||||||
<p>{prediction}</p>
|
<h3 className="text-lg font-semibold">Prediction:</h3>
|
||||||
</div>
|
<p>{prediction}</p>
|
||||||
)}
|
</div>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -37,7 +37,6 @@ const AddFarm = () => {
|
|||||||
setSuccess(true);
|
setSuccess(true);
|
||||||
setError(null);
|
setError(null);
|
||||||
setIsModalOpen(false);
|
setIsModalOpen(false);
|
||||||
window.location.reload();
|
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
setError(err.message);
|
setError(err.message);
|
||||||
setSuccess(false);
|
setSuccess(false);
|
||||||
|
|||||||
+16
-1
@@ -3,10 +3,19 @@ const express = require("express");
|
|||||||
const { spawn } = require("child_process");
|
const { spawn } = require("child_process");
|
||||||
const path = require("path");
|
const path = require("path");
|
||||||
const upload = require("./Middleware/multer");
|
const upload = require("./Middleware/multer");
|
||||||
|
const cors = require("cors");
|
||||||
|
|
||||||
const app = express();
|
const app = express();
|
||||||
const PORT = 3000;
|
const PORT = 3000;
|
||||||
|
|
||||||
|
const corsOptions = {
|
||||||
|
origin: "http://localhost:5173",
|
||||||
|
methods: "GET,HEAD,PUT,PATCH,POST,DELETE",
|
||||||
|
credentials: true,
|
||||||
|
};
|
||||||
|
|
||||||
|
app.use(cors(corsOptions));
|
||||||
|
|
||||||
// Endpoint to run the Python script
|
// Endpoint to run the Python script
|
||||||
app.post("/predict", upload.single("image"), (req, res) => {
|
app.post("/predict", upload.single("image"), (req, res) => {
|
||||||
console.log("File is uploaded successfully" + req.file?.path);
|
console.log("File is uploaded successfully" + req.file?.path);
|
||||||
@@ -22,7 +31,13 @@ app.post("/predict", upload.single("image"), (req, res) => {
|
|||||||
// Collect data from the script
|
// Collect data from the script
|
||||||
pythonProcess.stdout.on("data", (data) => {
|
pythonProcess.stdout.on("data", (data) => {
|
||||||
console.log(`Output: ${data}`);
|
console.log(`Output: ${data}`);
|
||||||
res.send(data.toString()); // Send the output back to the client
|
|
||||||
|
res.status(200).json({
|
||||||
|
success: true,
|
||||||
|
message: "Image uploaded successfully",
|
||||||
|
data: data.toString(),
|
||||||
|
});
|
||||||
|
//res.send(data.toString()); // Send the output back to the client
|
||||||
});
|
});
|
||||||
|
|
||||||
// Handle errors
|
// Handle errors
|
||||||
|
|||||||
@@ -1,5 +0,0 @@
|
|||||||
{
|
|
||||||
"dependencies": {
|
|
||||||
"apexcharts": "^3.46.0"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Reference in New Issue
Block a user