question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Eval runs ok first time but then throw an "ZeroDivisionError: division by zero"

See original GitHub issue

hi

I got the eval code to run ok the first time on an image, but then when I try to run it again on the same image or on any other image I get the following error message. Is there some buffer that I need to clean up somewhere between each inference run?

<font color="#729FCF">ImageCaptioning.pytorch</font>$ sudo python3 eval.py --model models/fc/model-best.pth --infos_path models/fc/infos_fc-best.pkl --image_folder images/ --num_images 1
Hugginface transformers not installed; please visit https://github.com/huggingface/transformers
meshed-memory-transformer not installed; please run `pip install git+https://github.com/ruotianluo/meshed-memory-transformer.git`
Warning: coco-caption not available
loading annotations into memory...
Done (t=0.78s)
creating index...
index created!
Traceback (most recent call last):
  File "eval.py", line 72, in <module>
    lang_stats = eval_utils.language_eval(opt.input_json, predictions, n_predictions, vars(opt), opt.split)
  File "/media/tetsfr/SSD/ImageCaptioning.pytorch/captioning/utils/eval_utils.py", line 79, in language_eval
    mean_perplexity = sum([_['perplexity'] for _ in preds_filt]) / len(preds_filt)
ZeroDivisionError: division by zero

Same pattern if I change the pre-trained model used for evaluation, it works the first time but then throws this division by zero error all the time. thanks for your help.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:23 (10 by maintainers)

github_iconTop GitHub Comments

3reactions
ruotianluocommented, Sep 25, 2020

add --force

0reactions
gfiamenicommented, Mar 17, 2021

Hi all, I am having the same problem. Tried the proposed fix without success. Which folder do you make the image_folder option point to? I suppose the test2014.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Error python : [ZeroDivisionError: division by zero]
we are dividing until correct data is given executed = False while not executed: try: a = float(input('first number --> ')) b =...
Read more >
ZeroDivisionError division by zero in Python error handling
In this tutorial, we'll reproduce the issue and then go over some solutions. Reproducing the error#. Let's write the following program, divide.
Read more >
How to Make Division by Zero to Zero in Python? - Finxter
Today we'll go over some ways to avoid the zero division error in Python and force it to return a zero. First, we'll...
Read more >
Detect division by zero - Rosetta Code
Task Write a function to detect a divide by zero error without checking if the denominator is zero.
Read more >
Python exception groups - LWN.net
In the first case, a divide-by-zero exception is generated and propagated out to the read-eval-print loop (REPL).
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found