satyrid
satyrid copied to clipboard
Broken pipe issue with metrics.py
I used metrics.py in a folder on a path that has a space in it (../Error Analysis/
). When I ran python metrics.py ...
, I got the following error:
{'reflen': 295650, 'guess': [323012, 294012, 265012, 236014], 'testlen': 323012, 'correct': [133791, 40271, 11842, 3419]}
ratio: 1.09254862168
Traceback (most recent call last):
File "metrics.py", line 64, in <module>
pprint.pprint(score(ref, hypo), width=1)
File "metrics.py", line 51, in score
score, scores = scorer.compute_score(ref, hypo)
File "/Users/Emiel/surfdrive/Error Analysis/evaluate/pycocoevalcap/meteor/meteor.py", line 37, in compute_score
stat = self._stat(res[i][0], gts[i])
File "/Users/Emiel/surfdrive/Error Analysis/evaluate/pycocoevalcap/meteor/meteor.py", line 55, in _stat
self.meteor_p.stdin.write('{}\n'.format(score_line))
IOError: [Errno 32] Broken pipe
Replacing the space in the path by an underscore (../Error_analysis/
) fixed the issue. This means that somewhere in the code, spaces are not properly escaped. I'm submitting this issue to notify others of this error, and the solution that I found. It's not an urgent problem for me, because I could just change the folder name.
That looks like a bug in the pycocoevalcap package. It might be possible to add some code into metrics.py to properly escape paths with spaces in them.
I don't use the space in the path, but the problem still happened...
{'reflen': 42989, 'guess': [43141, 39089, 35037, 30985], 'testlen': 43141, 'correct': [24003, 7902, 2445, 759]}
ratio: 1.00353578822
Traceback (most recent call last):
File "train_new.py", line 59, in <module>
main()
File "train_new.py", line 37, in main
solver.train()
File "/home/thisray/Code/lab7/Lab7_run_HERE/core/solver.py", line 172, in train
scores = evaluate(data_path='./data', split='val', get_scores=True)
File "/home/thisray/Code/lab7/Lab7_run_HERE/core/bleu.py", line 55, in evaluate
final_scores = score(ref, hypo)
File "/home/thisray/Code/lab7/Lab7_run_HERE/core/bleu.py", line 20, in score
score,scores = scorer.compute_score(ref,hypo)
File "../coco_caption/pycocoevalcap/meteor/meteor.py", line 38, in compute_score
stat = self._stat(res[i][0], gts[i])
File "../coco_caption/pycocoevalcap/meteor/meteor.py", line 57, in _stat
self.meteor_p.stdin.write('{}\n'.format(score_line))
IOError: [Errno 32] Broken pipe
and if I don't add shell=True
in subprocess.Popen()
, it would show another error.
self.meteor_p = subprocess.Popen(self.meteor_cmd, \
cwd=os.path.dirname(os.path.abspath(__file__)), stdin=subprocess.PIPE, \
stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True)
@thisray did you manage to track down the problem with the broken pipe?
I have exactly same problem and finally find the reason. For my case, it simply because I process meteor.compute_score twice. After the first run meteor_p has been killed so the second run is fail. To solve this I just delete the line "self.meteor_p.kill()". This works for me. Or you may delete meteor scorer first and init a new one in second time.
That's an interesting problem. Is meteor.compute_score always executed twice or is that specific to your code?
On Wed, 28 Feb 2018 at 01:00 Li REN [email protected] wrote:
I have exactly same problem and finally find the reason. For my case, it simply because I process meteor.compute_score twice. After the first run meteor_p has been killed so the second run is fail. To solve this I just delete the line "self.meteor_p.kill()". This works for me. Or you may delete meteor scorer first and init a new one in second time.
— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/elliottd/satyrid/issues/2#issuecomment-369082912, or mute the thread https://github.com/notifications/unsubscribe-auth/ABWqf2PNajXU7UYf8skNRKLD3KM9vnI4ks5tZKURgaJpZM4L3K-w .