AlexeyAB / darknet

YOLOv4 / Scaled-YOLOv4 / YOLO - Neural Networks for Object Detection (Windows and Linux version of Darknet )
http://pjreddie.com/darknet/
Other
21.68k stars 7.96k forks source link

Inference (`detector test`) broken when running from another directory #1514

Open vvolhejn opened 6 years ago

vvolhejn commented 6 years ago

When running detector test from a different directory than the project root (so something like darknet/darknet detector test [...]), there are a lot of errors of this sort:

STB Reason: can't fopen                   
Cannot load image "data/labels/123_7.png" 
STB Reason: can't fopen                   
Cannot load image "data/labels/124_7.png" 
STB Reason: can't fopen                   
Cannot load image "data/labels/125_7.png" 
STB Reason: can't fopen                   
Cannot load image "data/labels/126_7.png" 
STB Reason: can't fopen                   
[...omitted...]
STB Reason: can't fopen                   
Cannot load image "data/labels/123_7.png" 
STB Reason: can't fopen                   
Cannot load image "data/labels/124_7.png" 
STB Reason: can't fopen                   
Cannot load image "data/labels/125_7.png" 
STB Reason: can't fopen                   
Cannot load image "data/labels/126_7.png" 
STB Reason: can't fopen                   

after which the command performs predictions as expected, apart from the fact that the displayed prediction bounding boxes have no labels (they don't say which class is predicted).

I have tracked this down to the load_alphabet() function in image.c, which attempts to load images of characters from a fixed relative path, disregarding the fact that we may run the command from elsewhere.

PeterQuinn925 commented 6 years ago

Try putting absolute paths in your obj.data file?

On Thu, Aug 30, 2018 at 2:19 AM Václav Volhejn notifications@github.com wrote:

When running detector test from a different directory than the project root (so something like darknet/darknet detector test [...]), there are a lot of errors of this sort:

STB Reason: can't fopen Cannot load image "data/labels/123_7.png" STB Reason: can't fopen Cannot load image "data/labels/124_7.png" STB Reason: can't fopen Cannot load image "data/labels/125_7.png" STB Reason: can't fopen Cannot load image "data/labels/126_7.png" STB Reason: can't fopen [...omitted...] STB Reason: can't fopen Cannot load image "data/labels/123_7.png" STB Reason: can't fopen Cannot load image "data/labels/124_7.png" STB Reason: can't fopen Cannot load image "data/labels/125_7.png" STB Reason: can't fopen Cannot load image "data/labels/126_7.png" STB Reason: can't fopen

after which the command performs predictions as expected, apart from the fact that the displayed prediction bounding boxes have no labels (they don't say which class is predicted).

I have tracked this down to the load_alphabet() function in image.c https://github.com/AlexeyAB/darknet/blob/master/src/image.c#L217, which attempts to load images of characters from a fixed relative path, disregarding the fact that we may run the command from elsewhere.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/AlexeyAB/darknet/issues/1514, or mute the thread https://github.com/notifications/unsubscribe-auth/ARocJQfKZDm9AP0wSvFPIKl8RUIh1Hnnks5uV64qgaJpZM4WTF7Y .

-- Peter Quinn (415) 794-2264 (cell)

vvolhejn commented 6 years ago

The paths in my .data file are absolute; this is almost certainly not the source of the error. The paths in the error messages (data/labels/125_7.png etc) correspond to the load_alphabet() function trying to load pre-rendered images of ASCII characters.

Alireza-Pourreza commented 3 years ago

as @AlexeyAB mentioned here, you should change two lines (1602 and 1771) at darknet/src/detector.c including the following code: image **alphabet = load_alphabet(); to: image **alphabet = NULL;

Also, you should run makecommand in darknet folder