Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updated the code that allows to save the cropped image in result_img directory #7282

Open
wants to merge 17 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 10 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -288,6 +288,8 @@ On Linux find executable file `./darknet` in the root directory, while on Window
* To calculate anchors: `darknet.exe detector calc_anchors data/obj.data -num_of_clusters 9 -width 416 -height 416`
* To check accuracy mAP@IoU=50: `darknet.exe detector map data/obj.data yolo-obj.cfg backup\yolo-obj_7000.weights`
* To check accuracy mAP@IoU=75: `darknet.exe detector map data/obj.data yolo-obj.cfg backup\yolo-obj_7000.weights -iou_thresh 0.75`
* To save the cropped image of the object detected: [`uncomment the following lines of code`](https://github.com/AlexeyAB/darknet/blob/master/src/image_opencv.cpp#L980-L996)
* To run inference on all the images in a folder: `./darknet detector test ./cfg/coco.data ./cfg/yolov4.cfg ./yolov4.weights -i 0 -thresh 0.25 --folder_inference ./result_img/` here `./result_img/` is the path of the folder in which the inference has to be done. the folder name can be anything, as long as it exists. After the inference the images will be moved to `./processed_files/`. To change the folder name or path, the changes cane be done [`here`](https://github.com/shubham-shahh/darknet/blob/ebc7b6f3d575402fbcd67cf214243d437f580fe1/src/detector.c#L1895).
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

updated the readme.md

Copy link
Collaborator

@cenit cenit Feb 7, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As always, please use links to alexeyab's repo, without any commit id reference but pointing to the latest master trunk

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

okay, sir, I'll do that

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sir, I've updated the link but it is broken until the PR is merged @cenit

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes of course link is broken until merged, but this is a requirement for being considered for merging!


##### For using network video-camera mjpeg-stream with any Android smartphone

Expand Down
2 changes: 1 addition & 1 deletion include/darknet.h
Original file line number Diff line number Diff line change
Expand Up @@ -1040,7 +1040,7 @@ LIB_API float *network_predict_image_letterbox(network *net, image im);
LIB_API float validate_detector_map(char *datacfg, char *cfgfile, char *weightfile, float thresh_calc_avg_iou, const float iou_thresh, const int map_points, int letter_box, network *existing_net);
LIB_API void train_detector(char *datacfg, char *cfgfile, char *weightfile, int *gpus, int ngpus, int clear, int dont_show, int calc_map, int mjpeg_port, int show_imgs, int benchmark_layers, char* chart_path);
LIB_API void test_detector(char *datacfg, char *cfgfile, char *weightfile, char *filename, float thresh,
float hier_thresh, int dont_show, int ext_output, int save_labels, char *outfile, int letter_box, int benchmark_layers);
float hier_thresh, int dont_show, int ext_output, int save_labels, char *outfile, int letter_box, int benchmark_layers, char *folder_inference);
cenit marked this conversation as resolved.
Show resolved Hide resolved
LIB_API int network_width(network *net);
LIB_API int network_height(network *net);
LIB_API void optimize_picture(network *net, image orig, int max_layer, float scale, float rate, float thresh, int norm);
Expand Down
3 changes: 2 additions & 1 deletion src/darknet.c
Original file line number Diff line number Diff line change
Expand Up @@ -495,7 +495,8 @@ int main(int argc, char **argv)
float thresh = find_float_arg(argc, argv, "-thresh", .24);
int ext_output = find_arg(argc, argv, "-ext_output");
char *filename = (argc > 4) ? argv[4]: 0;
test_detector("cfg/coco.data", argv[2], argv[3], filename, thresh, 0.5, 0, ext_output, 0, NULL, 0, 0);
char *folder_inference = find_char_arg(argc, argv, "-folder_inference", 0);
test_detector("cfg/coco.data", argv[2], argv[3], filename, thresh, 0.5, 0, ext_output, 0, NULL, 0, 0, folder_inference);
} else if (0 == strcmp(argv[1], "cifar")){
run_cifar(argc, argv);
} else if (0 == strcmp(argv[1], "go")){
Expand Down
Loading