Darknet: Loss graph during training

Created on 1 Apr 2018  路  31Comments  路  Source: pjreddie/darknet

Is there a way to show loss graph during training like tensorflow?

Most helpful comment

How to save the loss graph on drive because i run the code on colab .

All 31 comments

Hi @abeyang00
Here! https://github.com/AlexeyAB/darknet.
He made loss plot for training.

@springkim can you tell me where the plot is located in his folder? is it in .c file in src??

https://github.com/AlexeyAB/darknet/issues/504#issuecomment-377500006
your answer is at the bottom

can someone tell me how to show loss graph during training when i use pjreddie's darknet

Any update on this thread?

I found one solution here : https://github.com/Jumabek/darknet_scripts/#how-to-plot-yolo-loss

You basically need to save the output of ./darknet detector train <> into a log file and then python plot_yolo_log.py log_file.log

Note that the plot does not show in a jupyter-notebook even with %matplotlib inline. A work around is to copy all plot related code from https://github.com/Jumabek/darknet_scripts/blob/master/plot_yolo_log.py into a new function.

You can use repo https://github.com/AlexeyAB/darknet that shows Loss & mAP chart during Training:
chart_full_occlusion

@AlexeyAB is this plot of the training loss or validation loss? If training loss, do you have a way of viewing the validation loss?

@groszste
It is Training loss and Validation mAP.
For me it isn't necessary to see Validation loss, it is much better to see Validation mAP.

@AlexeyAB
What commands do you use to display validation mAP during training?

@JakupGuven

From README: https://github.com/AlexeyAB/darknet/blob/master/README.md

"Or just train with -map flag:

darknet.exe detector train data/obj.data yolo-obj.cfg darknet53.conv.74 -map

So you will see mAP-chart (red-line) in the Loss-chart Window. mAP will be calculated for each 4 Epochs using valid=valid.txt file that is specified in obj.data file (1 Epoch = images_in_train_txt / batch iterations)"

I have followed the steps given by Mr. @AlexeyAB and got the red line but my problem is how to plot a mAP after every 100 iteration. In your documentation until 1000 iteration, but i want in every 100 iteration.

@yjdeveloper have you figured out how to downscale the mAP calculation to a shorter interval?

@yjdeveloper @snphnolt use this version with -map 0.02 for map calculation at every 0.02 epoch (starts after warmup iterations)

https://github.com/fcakyon/darknet

mAP-chart

Where this map graph has seen?

I have followed the steps given by Mr. @AlexeyAB and got the red line but my problem is how to plot a mAP after every 100 iteration. In your documentation until 1000 iteration, but i want in every 100 iteration.

How do you got the red line?

@AlexeyAB

I am using your repo to detect a custom objects using yolov3. however I have get in to trouble. The predictions.jpg image do not draw the confidence score but it draws the class id.

i traced the image.c code and I have found that in the function definition

void draw_detections_v3(image im, detection dets, int num, float thresh, char *names, image **alphabet, int classes, int ext_output)

how to resolev e the issue?

please, anyone, help. which function I have to use in AlexeyAB yolo repository in order to get confidence score drawings on the predictions.jpg image file???? I have get only class Id using this

!./darknet detector test data/trainer.data cfg/yolov3.cfg backup/yolov3_last.weights -thresh 0.1 -iou_thresh 0.3 data/img/tb500.jpg

predictions

You can use repo https://github.com/AlexeyAB/darknet that shows Loss & mAP chart during Training:
chart_full_occlusion

The command ./darknet detector demo ... -json_port 8070 -mjpeg_port 8090 works very well, but is there any way to save the image in vectorial format like eg. *pdf, *svg, *ps?

I found one solution here : https://github.com/Jumabek/darknet_scripts/#how-to-plot-yolo-loss

You basically need to save the output of ./darknet detector train <> into a log file and then python plot_yolo_log.py log_file.log

Note that the plot does not show in a jupyter-notebook even with %matplotlib inline. A work around is to copy all plot related code from https://github.com/Jumabek/darknet_scripts/blob/master/plot_yolo_log.py into a new function.

@rbarman in the log.txt output what's the information about mAP?

How to save the loss graph on drive because i run the code on colab .

I'm training Yolov3-tiny on colab using the following command-
!./darknet detector train /content/obj.data /content/yolov3-tiny-obj.cfg backup/yolov3-tiny-obj_last.weights -dont_show -mjpeg_port 8090 -map

It shows MJPEG-stream sent in the output after every iteration and i know we have to use http://ip-address:8090 format to access the chart, but I'm unable to find the ip-address of my colab notebook. I tried using addresses from !ifconfig and !curl ipecho.net/plain but still no result.
Any help would be appreciated.

@harshkc03 I found this quote in StackOverflow. I still not found a way to propagate the json and graph at same time, but you can try something like this to train and see your graph updating. It prints a url that you can access your loss graph with the follow commands:

!wget https://bin.equinox.io/c/4VmDzA7iaHb/ngrok-stable-linux-amd64.zip
!unzip ngrok-stable-linux-amd64.zip

get_ipython().system_raw('./ngrok http 8090 &')

!curl -s http://localhost:4040/api/tunnels | python3 -c \
 "import sys, json; print(json.load(sys.stdin)['tunnels'][0]['public_url'])"

After this, start your training:

!./darknet detector train /content/obj.data /content/yolov3-tiny-obj.cfg backup/yolov3-tiny-obj_last.weights -dont_show -mjpeg_port 8090 -map

Is there a way to produce the loss curve and mAP from an existing weight?

@francismontalbo you can obtain mAP of the existing weight using the command-
./darknet detector map data/obj.data yolo-obj.cfg backup\yolo-obj_last.weights
but you cannot generate the loss curve of an existing weight. Loss curve generates only during training.

@francismontalbo you can obtain mAP of the existing weight using the command-

./darknet detector map data/obj.data yolo-obj.cfg backup\yolo-obj_last.weights

but you cannot generate the loss curve of an existing weight. Loss curve generates only during training.

Yes, I've been using that. I see, thank you for the response good sir.

You can use pyngrok python package to display loss graph

!pip install pyngrok
from pyngrok import ngrok# Open a HTTP tunnel on port 8090
public_url = ngrok.connect(port = '8090')

public_url

Then run your training with flags

-mjpeg_port 8090 -map

You can use pyngrok python package to display loss graph

!pip install pyngrok
from pyngrok import ngrok# Open a HTTP tunnel on port 8090
public_url = ngrok.connect(port = '8090')

public_url

Then run your training with flags

-mjpeg_port 8090 -map

Thankyou sir, it works as expected.

You can use pyngrok python package to display loss graph

!pip install pyngrok
from pyngrok import ngrok# Open a HTTP tunnel on port 8090
public_url = ngrok.connect(port = '8090')

public_url

Then run your training with flags

-mjpeg_port 8090 -map

Seems much more elegant than my response, ty auhdsuahsduahs

Hello , I am getting the following error while using the command "!./darknet detector train data/obj.data cfg/yolov3_custom.cfg darknet53.conv.74 -dont_show -mjpeg_port 8090 -map".I am using google colab.

The connection to http://d80c91c46410.ngrok.io was successfully tunneled to your ngrok client, but the client failed to establish a connection to the local address localhost:8090.

Make sure that a web service is running on localhost:8090 and that it is a valid address.

The error encountered was: dial tcp 127.0.0.1:8090: connect: connection refused

I have followed the steps given by Mr. @AlexeyAB and got the red line but my problem is how to plot a mAP after every 100 iteration. In your documentation until 1000 iteration, but i want in every 100 iteration.

Did you find a solution? Thanks in advance.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

spaul13 picture spaul13  路  3Comments

sayanmutd picture sayanmutd  路  3Comments

ghost picture ghost  路  4Comments

ryuzakinho picture ryuzakinho  路  4Comments

Vikalp-Reorder picture Vikalp-Reorder  路  3Comments