Eval runs ok first time but then throw an "ZeroDivisionError: division by zero"
See original GitHub issuehi
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:
- Created 3 years ago
- Comments:23 (10 by maintainers)
Top 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 >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
add --force
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 thetest2014
.