Skip to content

Commit

Permalink
output filename changed | node controlled darknet script
Browse files Browse the repository at this point in the history
  • Loading branch information
CyberDuck79 committed Sep 17, 2022
1 parent 96f08de commit 55815a7
Show file tree
Hide file tree
Showing 7 changed files with 2,771 additions and 10 deletions.
6 changes: 3 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
GPU=0
CUDNN=0
GPU=1
CUDNN=1
CUDNN_HALF=0
OPENCV=0
OPENCV=1
AVX=0
OPENMP=0
LIBSO=0
Expand Down
28 changes: 28 additions & 0 deletions node-darknet.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
const { spawn } = require('child_process');

const darknet = spawn(
'./darknet',
[
'detector',
'test',
'cfg/coco.data',
'yolov4-csp.cfg',
'yolov4-csp.weights',
'-ext_output',
'-dont_show'
]
);

const images = ['dog.jpg', 'eagle.jpg', 'giraffe.jpg', 'horses.jpg', 'person.jpg', 'scream.jpg']

darknet.stdout.on('data', (data) => {
let output = data.toString();
console.log(output);
if (output.includes('Enter Image Path:')) {
const image = images.pop();
if (image === undefined) {
darknet.kill();
}
darknet.stdin.write(`data/${image}\n`);
}
});
6 changes: 4 additions & 2 deletions src/detector.c
Original file line number Diff line number Diff line change
Expand Up @@ -1711,9 +1711,11 @@ void test_detector(char *datacfg, char *cfgfile, char *weightfile, char *filenam
else diounms_sort(dets, nboxes, l.classes, nms, l.nms_kind, l.beta_nms);
}
draw_detections_v3(im, dets, nboxes, thresh, names, alphabet, l.classes, ext_output);
save_image(im, "predictions");
// remove the extension
input[strlen(input)-3] = 0;
save_image(im, input);
if (!dont_show) {
show_image(im, "predictions");
show_image(im, input);
}

if (json_file) {
Expand Down
10 changes: 5 additions & 5 deletions src/image.c
Original file line number Diff line number Diff line change
Expand Up @@ -731,11 +731,11 @@ void save_image_options(image im, const char *name, IMTYPE f, int quality)
{
char buff[256];
//sprintf(buff, "%s (%d)", name, windows);
if (f == PNG) sprintf(buff, "%s.png", name);
else if (f == BMP) sprintf(buff, "%s.bmp", name);
else if (f == TGA) sprintf(buff, "%s.tga", name);
else if (f == JPG) sprintf(buff, "%s.jpg", name);
else sprintf(buff, "%s.png", name);
if (f == PNG) sprintf(buff, "%sprediction.png", name);
else if (f == BMP) sprintf(buff, "%sprediction.bmp", name);
else if (f == TGA) sprintf(buff, "%sprediction.tga", name);
else if (f == JPG) sprintf(buff, "%sprediction.jpg", name);
else sprintf(buff, "%sprediction.png", name);
unsigned char* data = (unsigned char*)xcalloc(im.w * im.h * im.c, sizeof(unsigned char));
int i, k;
for (k = 0; k < im.c; ++k) {
Expand Down

0 comments on commit 55815a7

Please sign in to comment.