{"id":17099027,"url":"https://github.com/dinhanhx/imgcap","last_synced_at":"2026-04-28T20:38:17.160Z","repository":{"id":112393223,"uuid":"366258465","full_name":"dinhanhx/imgcap","owner":"dinhanhx","description":"Image captioning with Visual Attention","archived":false,"fork":false,"pushed_at":"2021-06-08T01:01:23.000Z","size":972,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-23T18:12:41.731Z","etag":null,"topics":["cli","computer-vision","hateful-memes-challenge","image-captioning","inference","natural-language-processing","python-3","python3","tensorflow2","visual-attention"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/dinhanhx.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","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":"2021-05-11T04:49:45.000Z","updated_at":"2023-02-21T03:49:37.000Z","dependencies_parsed_at":"2023-04-20T11:05:46.615Z","dependency_job_id":null,"html_url":"https://github.com/dinhanhx/imgcap","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"purl":"pkg:github/dinhanhx/imgcap","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dinhanhx%2Fimgcap","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dinhanhx%2Fimgcap/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dinhanhx%2Fimgcap/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dinhanhx%2Fimgcap/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dinhanhx","download_url":"https://codeload.github.com/dinhanhx/imgcap/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dinhanhx%2Fimgcap/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32399002,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-28T19:38:08.556Z","status":"ssl_error","status_checked_at":"2026-04-28T19:37:55.688Z","response_time":56,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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":["cli","computer-vision","hateful-memes-challenge","image-captioning","inference","natural-language-processing","python-3","python3","tensorflow2","visual-attention"],"created_at":"2024-10-14T15:08:49.752Z","updated_at":"2026-04-28T20:38:17.143Z","avatar_url":"https://github.com/dinhanhx.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Image captioning with Visual Attention\n\n[![forthebadge](https://forthebadge.com/images/badges/made-with-python.svg)](https://forthebadge.com)\n\n[![forthebadge](https://forthebadge.com/images/badges/works-on-my-machine.svg)](https://forthebadge.com)\n\nThis project follows this Tensorflow 2 [tutorial](https://www.tensorflow.org/tutorials/text/image_captioning). Instead of training on small dataset like in the tutorial, I train on whole [MS-COCO-2014 dataset](http://images.cocodataset.org/zips/train2014.zip).\n\n## Setup\n\nEnvironment tool: [conda](https://docs.conda.io/en/latest/)\n\nIn file `environment.yml`:\n- Remember to change `/home/anhvd/miniconda3/envs/imgcap` corresponding to your OS and username. \n- Check YOUR gpu's cudatoolkit and cudnn. You might need to change these:\n    - `cudatoolkit=10.1.243=h6bb024c_0`\n    - `cudnn=7.6.5=cuda10.1_0`\n\nCmds:\n```\nconda env create -f environment.yml\n```\n\nOr you can just create new environment with this cmd:\n```\nconda create -n imgcap python=3.6 tensorflow-gpu cudatoolkit=\u003cversion\u003e cudnn=\u003cversion\u003e\n```\n\n## Training\n\nThis model is trained on a single [Tesla K80](https://www.nvidia.com/en-gb/data-center/tesla-k80/) 12 GiB about 10 hours.\n\n**Step 1:** run this `python download_extract.py`. It will download, prepare [MS-COCO-2014 dataset](http://images.cocodataset.org/zips/train2014.zip); then tokenize, extract feature.\n\n**Step 2:** run this `python train.py`. It will train model and save it.\n\n## Inference\n\nDownload pretrained_models.zip from this repos' **latest** release section. This file zip provides:\n- `annotations/captions_train2014.json` from [MS-COCO-2014 dataset](http://images.cocodataset.org/zips/train2014.zip)\n- my checkpoints folder ~ pretrained models\n\nOpen file `inf.py` then scroll down to this block of code, then edit `image_file`, possibly `annotation_file` and `checkpoint_path`. Then run with `python inf.py`\n```python\nif '__main__' == __name__:\n    image_file = 'surf.jpg'\n\n    annotation_file='./annotations/captions_train2014.json' \n    checkpoint_path='./checkpoints/train/'\n\n    ts = time.time()\n    feature_extractor = FeatureExtraction.build_model_InceptionV3()\n    tokenizer, max_length = load_tokenizer(annotation_file)\n    encoder, decoder = load_latest_imgcap(checkpoint_path)\n    te = time.time()\n\n    load_model_time = te - ts\n\n    models = [feature_extractor, \n                tokenizer, max_length, \n                encoder, decoder]\n\n    ts = time.time()\n    print(inference(image_file, models))\n    te = time.time()\n\n    inference_time = te - ts\n    print(f'Loading models takes {load_model_time} seconds')\n    print(f'Inference takes {inference_time} seconds')\n```\n\n__CPU__ that I used:\n```\nArchitecture:        x86_64\nCPU op-mode(s):      32-bit, 64-bit\nByte Order:          Little Endian\nAddress sizes:       46 bits physical, 48 bits virtual\nCPU(s):              24\nOn-line CPU(s) list: 0-23\nThread(s) per core:  2\nCore(s) per socket:  6\nSocket(s):           2\nNUMA node(s):        2\nVendor ID:           GenuineIntel\nCPU family:          6\nModel:               63\nModel name:          Intel(R) Xeon(R) CPU E5-2620 v3 @ 2.40GHz\nStepping:            2\nCPU MHz:             1197.334\nCPU max MHz:         3200.0000\nCPU min MHz:         1200.0000\nBogoMIPS:            4788.94\nVirtualization:      VT-x\nL1d cache:           32K\nL1i cache:           32K\nL2 cache:            256K\nL3 cache:            15360K\nNUMA node0 CPU(s):   0-5,12-17\nNUMA node1 CPU(s):   6-11,18-23\nFlags:               fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx pdpe1gb rdtscp lm constant_tsc arch_perfmon pebs bts rep_good nopl xtopology nonstop_tsc cpuid aperfmperf pni pclmulqdq dtes64 monitor ds_cpl vmx smx est tm2 ssse3 sdbg fma cx16 xtpr pdcm pcid dca sse4_1 sse4_2 x2apic movbe popcnt aes xsave avx f16c rdrand lahf_lm abm cpuid_fault epb invpcid_single pti intel_ppin tpr_shadow vnmi flexpriority ept vpid ept_ad fsgsbase tsc_adjust bmi1 avx2 smep bmi2 erms invpcid cqm xsaveopt cqm_llc cqm_occup_llc dtherm ida arat pln pts\n```\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdinhanhx%2Fimgcap","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdinhanhx%2Fimgcap","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdinhanhx%2Fimgcap/lists"}