{"id":20063277,"url":"https://github.com/markdtw/soft-attention-image-captioning","last_synced_at":"2025-10-04T22:09:32.953Z","repository":{"id":93067261,"uuid":"78819674","full_name":"markdtw/soft-attention-image-captioning","owner":"markdtw","description":"tensorflow implementation of show, attend and tell (ICML'15)","archived":false,"fork":false,"pushed_at":"2017-06-22T06:04:21.000Z","size":654,"stargazers_count":19,"open_issues_count":2,"forks_count":11,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-05-05T17:32:39.093Z","etag":null,"topics":["image-captioning","tensorflow"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/markdtw.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-01-13T05:52:02.000Z","updated_at":"2025-01-23T05:56:37.000Z","dependencies_parsed_at":"2023-06-04T15:15:09.303Z","dependency_job_id":null,"html_url":"https://github.com/markdtw/soft-attention-image-captioning","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/markdtw/soft-attention-image-captioning","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/markdtw%2Fsoft-attention-image-captioning","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/markdtw%2Fsoft-attention-image-captioning/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/markdtw%2Fsoft-attention-image-captioning/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/markdtw%2Fsoft-attention-image-captioning/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/markdtw","download_url":"https://codeload.github.com/markdtw/soft-attention-image-captioning/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/markdtw%2Fsoft-attention-image-captioning/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":278381049,"owners_count":25977334,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-10-04T02:00:05.491Z","response_time":63,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["image-captioning","tensorflow"],"created_at":"2024-11-13T13:41:29.092Z","updated_at":"2025-10-04T22:09:32.947Z","avatar_url":"https://github.com/markdtw.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Soft Attention Image Captioning\nTensorflow implementation of [Show, Attend and Tell](https://arxiv.org/abs/1502.03044) presented in ICML'15.\n\nHuge re-factor from last update, compatible with tensorflow \u003e= r1.0\n\n\n## Prerequisites\n- Python 2.7+\n- [NumPy](http://www.numpy.org/)\n- [Tensorflow r1.0+](https://www.tensorflow.org/install/)\n- [Scikit-image](http://scikit-image.org/)\n- [tqdm](https://pypi.python.org/pypi/tqdm)\n\n\n## Data\n- Training: [Microsoft COCO: Common Objects in Context](http://mscoco.org/dataset/#download) training and validation set\n\n\n## Preparation\n1. Clone this repo, create `data/` and `log/` folders:\n    ```bash\n    git clone https://github.com/markdtw/soft-attention-image-captioning.git\n    cd soft-attention-image-captioning\n    mkdir data\n    mkdir log\n    ```\n2. Download and extract pre-trained `Inception V4` and `VGG 19` [from tf.slim](https://github.com/tensorflow/models/tree/master/slim#pre-trained-models) for feature extraction.  \n   Save the ckpt files in `cnns/` as `inception_v4_imagenet.ckpt` and `vgg_19_imagenet.ckpt`.\n\n3. We need the following files in our `data/` folder:\n    - `coco_raw.json`\n    - `coco_processed.json`\n    - `coco_dictionary.pkl`\n    - `coco_final.json`\n    - `train2014_vgg(inception).npy` and `val2014_vgg(inception).npy`\n    \n    These files can be generated through `utils.py`, please refer to it before executing.\n   \n4. If you are not able to extract the features yourself, [here](https://drive.google.com/open?id=0B5j6QKJb0ztbRXRQWW12ME9uSGs) is the features download link:\n    - It may take a long time to download.\n\n\n## Train\nTrain from scratch with default settings:\n```bash\npython main.py --train\n```\nTrain from a pre-trained model from epoch X:\n```bash\npython main.py --train --model_path=log/model.ckpt-X\n```\nCheck out tunable arguments:\n```bash\npython main.py\n```\n\n## Generate a caption\nUsing default(latest) model:\n```bash\npython main.py --generate --img_path=/path/to/image.jpg\n```\nUsing model from epoch X:\n```bash\npython main.py --generate --img_path=/path/to/image.jpg --model_path=log/model.ckpt-X\n```\n\n## Others\n- Features extracted are around 16 + 8 GB. Make sure you have enough CPU memory when loading the data.\n- GPU memory usage for batch_size 128 is around 8GB.\n- Utilize `tf.while_loop` for rnn implementation, `tf.slim` for feature extraction from their [github page](https://github.com/tensorflow/models/tree/master/slim).\n- GRU cell is implemented, use it by setting `--use_gru=True` when training.\n- Features can be extracted through [inceptionV4](https://arxiv.org/abs/1602.07261), if so, model.ctx_dim in `model.py` needs to be set to (64, 1536). (other modifications are needed)\n- Issues are welcome!\n\n\n## Resources\n- [Show, attend and tell slides](http://www.slideshare.net/eunjileee/show-attend-and-tell-neural-image-caption-generation-with-visual-attention)\n- [Attention Mechanism Blog Post](https://blog.heuritech.com/2016/01/20/attention-mechanism/)\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmarkdtw%2Fsoft-attention-image-captioning","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmarkdtw%2Fsoft-attention-image-captioning","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmarkdtw%2Fsoft-attention-image-captioning/lists"}