Spaces:
Sleeping
Sleeping
Update server.js
Browse files
server.js
CHANGED
|
@@ -193,6 +193,8 @@ async function runYOLOv5Detection(imagePath) {
|
|
| 193 |
const yolov5Path = path.join(__dirname, 'yolo_detect.py');
|
| 194 |
const weightsPath = path.join(__dirname, 'yolov5s.pt');
|
| 195 |
|
|
|
|
|
|
|
| 196 |
const pythonProcess = spawn('python', [
|
| 197 |
yolov5Path,
|
| 198 |
weightsPath,
|
|
@@ -204,15 +206,17 @@ async function runYOLOv5Detection(imagePath) {
|
|
| 204 |
|
| 205 |
pythonProcess.stdout.on('data', (data) => {
|
| 206 |
output += data.toString();
|
|
|
|
| 207 |
});
|
| 208 |
|
| 209 |
pythonProcess.stderr.on('data', (data) => {
|
| 210 |
errorOutput += data.toString();
|
|
|
|
| 211 |
});
|
| 212 |
|
| 213 |
pythonProcess.on('close', (code) => {
|
|
|
|
| 214 |
if (code === 0) {
|
| 215 |
-
// Output should be the path to the detected image
|
| 216 |
resolve({
|
| 217 |
success: true,
|
| 218 |
detectedImagePath: output.trim(),
|
|
|
|
| 193 |
const yolov5Path = path.join(__dirname, 'yolo_detect.py');
|
| 194 |
const weightsPath = path.join(__dirname, 'yolov5s.pt');
|
| 195 |
|
| 196 |
+
console.log('Calling yolo_detect.py with weights:', weightsPath, 'and image:', imagePath);
|
| 197 |
+
|
| 198 |
const pythonProcess = spawn('python', [
|
| 199 |
yolov5Path,
|
| 200 |
weightsPath,
|
|
|
|
| 206 |
|
| 207 |
pythonProcess.stdout.on('data', (data) => {
|
| 208 |
output += data.toString();
|
| 209 |
+
console.log('PYTHON STDOUT:', data.toString());
|
| 210 |
});
|
| 211 |
|
| 212 |
pythonProcess.stderr.on('data', (data) => {
|
| 213 |
errorOutput += data.toString();
|
| 214 |
+
console.error('PYTHON STDERR:', data.toString());
|
| 215 |
});
|
| 216 |
|
| 217 |
pythonProcess.on('close', (code) => {
|
| 218 |
+
console.log('Python process exited with code:', code);
|
| 219 |
if (code === 0) {
|
|
|
|
| 220 |
resolve({
|
| 221 |
success: true,
|
| 222 |
detectedImagePath: output.trim(),
|