ImageCaptioning.pytorch icon indicating copy to clipboard operation
ImageCaptioning.pytorch copied to clipboard

Python-3 support

Open kmario23 opened this issue 7 years ago • 9 comments

Hi @ruotianluo , I looked at the coco-caption codebase. It seems that we need some modifications like xrange -> range etc., to port the code to Python-3.

So, I'd like to know if you have any plans to port the pycoco tools to Python-3 so that we can use this current codebase for training models in Python-3?

kmario23 avatar Jan 19 '18 17:01 kmario23

It's harder than that. I tried and failed for some metric.

ruotianluo avatar Jan 19 '18 18:01 ruotianluo

I see. Let me try to do that and issue a PR if I manage to do it successfully!

kmario23 avatar Jan 19 '18 19:01 kmario23

I have implemented Python 3 support for the coco caption metrics: https://github.com/salaniz/pycocoevalcap

I decided against a PR and in favor of a fork of my own because the pycocotools that come with the original repository have diverged with the newest version present in the coco API repository here: https://github.com/cocodataset/cocoapi

Therefore, I am using the pycocotools from the API repository together with my updated caption evaluation code.

You can have a look at the changes. They are all pretty obvious, except maybe the Meteor one which took me a while to debug. If you have any problems, let me know. Also feel free to make a PR with my changes. I have not tested if my code is backward compatible with Python 2.7.

salaniz avatar Feb 06 '18 14:02 salaniz

cool, I'll take a look.

ruotianluo avatar Feb 06 '18 14:02 ruotianluo

I have implemented Python 3 support for the coco caption metrics: https://github.com/salaniz/pycocoevalcap

I decided against a PR and in favor of a fork of my own because the pycocotools that come with the original repository have diverged with the newest version present in the coco API repository here: https://github.com/cocodataset/cocoapi

Therefore, I am using the pycocotools from the API repository together with my updated caption evaluation code.

You can have a look at the changes. They are all pretty obvious, except maybe the Meteor one which took me a while to debug. If you have any problems, let me know. Also feel free to make a PR with my changes. I have not tested if my code is backward compatible with Python 2.7.

hi, thank you for your work! Does your new repo support Chinese language evaluation?

sdsy888 avatar Feb 06 '19 18:02 sdsy888

My repository simply adds Python 3 support, but leaves everything else unchanged. So it is really up to how well the metrics and the tokenizer from the original coco-caption repo generalize to the Chinese language. I do not know if that's the case.

salaniz avatar Feb 07 '19 12:02 salaniz

I added py3 support here https://github.com/ruotianluo/self-critical.pytorch/tree/py3 .

ruotianluo avatar Feb 15 '19 03:02 ruotianluo

@ruotianluo thanks a lot! It seems the doc is still to be updated, right?

kmario23 avatar Feb 15 '19 05:02 kmario23

@kmario23 I'm not yet 100% percent sure if it's correct. It seems working well on my side now.

ruotianluo avatar Feb 15 '19 06:02 ruotianluo