Skip to content

Commit

Permalink
restore cpp compatibility
Browse files Browse the repository at this point in the history
restore cpp compatibility
  • Loading branch information
cenit committed Aug 28, 2023
1 parent d752890 commit 547b303
Show file tree
Hide file tree
Showing 9 changed files with 240 additions and 260 deletions.
10 changes: 0 additions & 10 deletions 3rdparty/stb/include/stb_image.h
Original file line number Diff line number Diff line change
Expand Up @@ -218,16 +218,6 @@ RECENT REVISION HISTORY:
//
// ===========================================================================
//
// UNICODE:
//
// If compiling for Windows and you wish to use Unicode filenames, compile
// with
// #define STBI_WINDOWS_UTF8
// and pass utf8-encoded filenames. Call stbiw_convert_wchar_to_utf8 to convert
// Windows wchar_t filenames to utf8.
//
// ===========================================================================
//
// Philosophy
//
// stb libraries are designed with the following priorities:
Expand Down
6 changes: 1 addition & 5 deletions 3rdparty/stb/include/stb_image_write.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,6 @@
Will probably not work correctly with strict-aliasing optimizations.
If using a modern Microsoft Compiler, non-safe versions of CRT calls may cause
compilation warnings or even errors. To avoid this, also before #including,
#define STBI_MSC_SECURE_CRT
ABOUT:
This header file is a library for writing images to C stdio or a callback.
Expand Down Expand Up @@ -1103,6 +1098,7 @@ static void stbiw__encode_png_line(unsigned char *pixels, int stride_bytes, int
int type = mymap[filter_type];
unsigned char *z = pixels + stride_bytes * (stbi__flip_vertically_on_write ? height-1-y : y);
int signed_stride = stbi__flip_vertically_on_write ? -stride_bytes : stride_bytes;

if (type==0) {
memcpy(line_buffer, z, width*n);
return;
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ LDFLAGS+= -L/usr/local/zed/lib -lsl_zed
endif
endif

OBJ=image_opencv.o http_stream.o gemm.o utils.o dark_cuda.o convolutional_layer.o list.o image.o activations.o im2col.o col2im.o blas.o crop_layer.o dropout_layer.o maxpool_layer.o softmax_layer.o data.o matrix.o network.o connected_layer.o cost_layer.o parser.o option_list.o darknet.o detection_layer.o captcha.o route_layer.o writing.o box.o nightmare.o normalization_layer.o avgpool_layer.o coco.o dice.o yolo.o detector.o layer.o compare.o classifier.o local_layer.o swag.o shortcut_layer.o representation_layer.o activation_layer.o rnn_layer.o gru_layer.o rnn.o rnn_vid.o crnn_layer.o demo.o tag.o cifar.o go.o batchnorm_layer.o art.o region_layer.o reorg_layer.o reorg_old_layer.o super.o voxel.o tree.o yolo_layer.o gaussian_yolo_layer.o upsample_layer.o lstm_layer.o conv_lstm_layer.o scale_channels_layer.o jWrite.o sam_layer.o
OBJ=image_opencv.o http_stream.o gemm.o utils.o dark_cuda.o convolutional_layer.o list.o image.o activations.o im2col.o col2im.o blas.o crop_layer.o dropout_layer.o maxpool_layer.o softmax_layer.o data.o matrix.o network.o connected_layer.o cost_layer.o parser.o option_list.o darknet.o detection_layer.o captcha.o route_layer.o writing.o box.o nightmare.o normalization_layer.o avgpool_layer.o coco.o dice.o yolo.o detector.o layer.o compare.o classifier.o local_layer.o swag.o shortcut_layer.o representation_layer.o activation_layer.o rnn_layer.o gru_layer.o rnn.o rnn_vid.o crnn_layer.o demo.o tag.o cifar.o go.o batchnorm_layer.o art.o region_layer.o reorg_layer.o reorg_old_layer.o super.o voxel.o tree.o yolo_layer.o gaussian_yolo_layer.o upsample_layer.o lstm_layer.o conv_lstm_layer.o scale_channels_layer.o sam_layer.o jWrite.o
ifeq ($(GPU), 1)
LDFLAGS+= -lstdc++
OBJ+=convolutional_kernels.o activation_kernels.o im2col_kernels.o col2im_kernels.o blas_kernels.o crop_layer_kernels.o dropout_layer_kernels.o maxpool_layer_kernels.o network_kernels.o avgpool_layer_kernels.o
Expand Down
28 changes: 6 additions & 22 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -821,24 +821,20 @@ public:
#endif
};
```
----
Fork description:
Bulk processing of an input file containing image paths into a json-formatted output file containing all darknet yolo predictions of all the input images.
Based on AlexeyAB's darknet fork:
## Json output
I created a new test phase: **test_headless** which takes a **names** file, **cfg** file and **weights** file, with an input file (with image paths) and output json file, like so:
New command within detector: **test_headless** which takes a **names** file, **cfg** file and **weights** file, with an input file (with image paths) and output json file:
`./darknet detector test_headless data/openimages.names cfg/yolov3-openimages.cfg ../yolov3-openimages.weights -in_filename input.txt -out_filename output.json`
`./darknet detector test_headless data/coco.names cfg/yolov3.cfg ../yolov3.weights -in_filename input.txt -out_filename output.json`
example output:
```javascript
```json
{
"darknet headless output": [
{
"fileName": "/Users/gpsmit/Downloads/marine.jpg",
"fileName": "/path/to/source/image.jpg",
"predictions": [
{
"height": 332,
Expand All @@ -863,18 +859,6 @@ example output:
"left_x": 13,
"top_y": 84,
"width": 471
},
{
"height": 216,
"labels": [
{
"label": "Weapon",
"score": 32.131096
}
],
"left_x": 237,
"top_y": 190,
"width": 652
}
]
}
Expand Down
1 change: 0 additions & 1 deletion bad.list

This file was deleted.

4 changes: 2 additions & 2 deletions src/detector.c
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ void train_detector(char *datacfg, char *cfgfile, char *weightfile, int *gpus, i
}

int save_after_iterations = option_find_int(options, "saveweights", (net.max_batches < 10000) ? 1000 : 10000 ); // configure when to write weights. Very useful for smaller datasets!
int save_last_weights_after = option_find_int(options, "savelast", 100);
int save_last_weights_after = option_find_int(options, "savelast", 100);
printf("Weights are saved after: %d iterations. Last weights (*_last.weight) are stored every %d iterations. \n", save_after_iterations, save_last_weights_after );


Expand Down Expand Up @@ -1858,7 +1858,7 @@ void test_headless(char *datacfg, char *cfgfile, char *weightfile, float thresh,
fclose(outputfile);
fclose(inputfile);

free_ptrs(names, net.layers[net.n - 1].classes);
free_ptrs((void**)names, net.layers[net.n - 1].classes);
free_network(net);

}
Expand Down
4 changes: 3 additions & 1 deletion src/image.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,9 @@
#endif

// specific to jWrite.c and jWrite.h
#define _CRT_SECURE_NO_WARNINGS // stop complaining about deprecated functions
#ifndef _CRT_SECURE_NO_WARNINGS
#define _CRT_SECURE_NO_WARNINGS
#endif
#include "jWrite.h"
// END specific to jWrite.c and jWrite.h

Expand Down
Loading

0 comments on commit 547b303

Please sign in to comment.