{"id":13412008,"url":"https://github.com/openai/image-gpt","last_synced_at":"2025-05-15T17:08:50.839Z","repository":{"id":41498206,"uuid":"262168687","full_name":"openai/image-gpt","owner":"openai","description":null,"archived":false,"fork":false,"pushed_at":"2022-04-29T00:03:56.000Z","size":33,"stargazers_count":2059,"open_issues_count":12,"forks_count":389,"subscribers_count":82,"default_branch":"master","last_synced_at":"2025-04-07T22:09:42.564Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/openai.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}},"created_at":"2020-05-07T22:07:34.000Z","updated_at":"2025-04-07T01:09:31.000Z","dependencies_parsed_at":"2022-08-10T02:35:06.124Z","dependency_job_id":null,"html_url":"https://github.com/openai/image-gpt","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/openai%2Fimage-gpt","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/openai%2Fimage-gpt/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/openai%2Fimage-gpt/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/openai%2Fimage-gpt/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/openai","download_url":"https://codeload.github.com/openai/image-gpt/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254384989,"owners_count":22062422,"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","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":[],"created_at":"2024-07-30T20:01:20.068Z","updated_at":"2025-05-15T17:08:45.811Z","avatar_url":"https://github.com/openai.png","language":"Python","funding_links":[],"categories":["Python","5. Generation of synthetic content","Fundamental MIM Methods"],"sub_categories":["5.3 Generation Images","MIM for Transformers"],"readme":"**Status:** Archive (code is provided as-is, no updates expected)\n\n# image-gpt\n\nCode and models from the paper [\"Generative Pretraining from Pixels\"](https://cdn.openai.com/papers/Generative_Pretraining_from_Pixels_V2.pdf).\n\nSupported Platforms:\n\n- Ubuntu 16.04\n\n## Install\n\nYou can get miniconda from https://docs.conda.io/en/latest/miniconda.html, or install the dependencies shown below manually.\n\n```\nconda create --name image-gpt python=3.7.3\nconda activate image-gpt\n\nconda install numpy=1.16.3\nconda install tensorflow-gpu=1.13.1\n\nconda install imageio=2.8.0\nconda install requests=2.21.0\nconda install tqdm=4.46.0\n```\n\n## Usage\n\nThis repository is meant to be a starting point for researchers and engineers to experiment with image GPT (iGPT). Our code forks GPT-2 to highlight that it can be easily applied across domains. The diff from `gpt-2/src/model.py` to `image-gpt/src/model.py` includes a new activation function, renaming of several variables, and the introduction of a start-of-sequence token, none of which change the model architecture.\n\n### Downloading Pre-trained Models\n\nTo download a model checkpoint, run `download.py`. The `--model` argument should be one of \"s\", \"m\", or \"l\", and the `--ckpt` argument should be one of \"131000\", \"262000\", \"524000\", or \"1000000\".\n\n```\npython download.py --model s --ckpt 1000000\n```\n\nThis command downloads the iGPT-S checkpoint at 1M training iterations. The default download directory is set to `/root/downloads/`, and can be changed using the `--download_dir` argument.\n\n### Downloading Datasets\n\nTo download datasets, run `download.py` with the `--dataset` argument set to \"imagenet\" or \"cifar10\".\n\n```\npython download.py --model s --ckpt 1000000 --dataset imagenet\n```\n\nThis command additionally downloads 32x32 ImageNet encoded with the 9-bit color palette described in the paper. The datasets we provide are center-cropped images intended for evaluation; random cropped images are required to faithfully replicate training.\n\n### Downloading Color Clusters\n\nTo download the color cluster file defining our 9-bit color palette, run `download.py` with the `--clusters` flag set.\n\n```\npython download.py --model s --ckpt 1000000 --dataset imagenet --clusters\n```\n\nThis command additionally downloads the color cluster file. `src/run.py:sample` shows how to decode from 9-bit color to RGB and `src/utils.py:color_quantize` shows how to go the other way around.\n\n### Sampling\n\nOnce the desired checkpoint and color cluster file are downloaded, we can run the script in sampling mode. The following commands sample from iGPT-S, iGPT-M, and iGPT-L respectively:\n\n```\npython src/run.py --sample --n_embd 512  --n_head 8  --n_layer 24\npython src/run.py --sample --n_embd 1024 --n_head 8  --n_layer 36\npython src/run.py --sample --n_embd 1536 --n_head 16 --n_layer 48\n```\n\nIf your data is not in `/root/downloads/`, set `--ckpt_path` and `--color_cluster_path` manually. To run on fewer than 8 GPUs, use a command of the following form:\n\n```\nCUDA_VISIBLE_DEVICES=0,1 python src/run.py --sample --n_embd 512  --n_head 8  --n_layer 24 --n_gpu 2\n```\n\n### Evaluating\n\nOnce the desired checkpoint and evaluation dataset are downloaded, we can run the script in evaluation mode. The following commands evaluate iGPT-S, iGPT-M, and iGPT-L on ImageNet respectively:\n\n```\npython src/run.py --eval --n_embd 512  --n_head 8  --n_layer 24\npython src/run.py --eval --n_embd 1024 --n_head 8  --n_layer 36\npython src/run.py --eval --n_embd 1536 --n_head 16 --n_layer 48\n```\n\nIf your data is not in `/root/downloads/`, set `--ckpt_path` and `--data_path` manually. You should see that the test generative losses are 2.0895, 2.0614, and 2.0466, matching Figure 3 in the paper.\n\n### Citation\n\nPlease use the following bibtex entry:\n```\n@article{chen2020generative,\n  title={Generative Pretraining from Pixels},\n  author={Chen, Mark and Radford, Alec and Child, Rewon and Wu, Jeff and Jun, Heewoo and Dhariwal, Prafulla and Luan, David and Sutskever, Ilya},\n  year={2020}\n}\n```\n\n## License\n\n[Modified MIT](./LICENSE)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fopenai%2Fimage-gpt","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fopenai%2Fimage-gpt","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fopenai%2Fimage-gpt/lists"}