--- dataset_info: features: - name: image dtype: image - name: text dtype: string - name: language dtype: string - name: kind dtype: string - name: style dtype: string - name: font dtype: string - name: font_size dtype: int64 - name: line_numbers dtype: bool - name: repo dtype: string - name: file dtype: string splits: - name: train num_bytes: 2556789548 num_examples: 85634 - name: validation num_bytes: 322219563 num_examples: 10366 download_size: 3528351734 dataset_size: 2879009111 configs: - config_name: default data_files: - split: train path: data/train-* - split: validation path: data/validation-* pretty_name: Code Snippet Image to Text (8 languages) license: cc-by-4.0 task_categories: - image-to-text tags: - code - vlm - multimodal - ocr - syntax-highlighting - code-generation - image-to-text size_categories: - 10K` holding the **raw PNG bytes** (PNG signature `89 50 4E 47`), **not base64**. `datasets` decodes them to `PIL.Image` on access. To get the undecoded bytes: ```python from datasets import Image raw = load_dataset("anisiraj/code-image-to-text", split="train").cast_column("image", Image(decode=False)) raw[0]["image"]["bytes"][:8] # b'\x89PNG\r\n\x1a\n' ``` ## Fine-tune a VLM (image → text) ```python from datasets import load_dataset ds = load_dataset("anisiraj/code-image-to-text") PROMPT = "Transcribe the code shown in this image exactly, preserving indentation." def to_chat(ex): return {"image": ex["image"], "prompt": PROMPT, "target": ex["text"]} train = ds["train"].map(to_chat) # Feed `image` + `prompt` through your VLM's processor/chat template # (e.g. Qwen2-VL, Idefics3, Llava, MiniCPM-V) and train to produce `target`. ``` ## Rendering & augmentation Rendered with [Pygments](https://pygments.org/) `ImageFormatter`: **18 themes** (light & dark) × **3 monospace fonts** × **5 font sizes** (14–20) × **line-numbers on/off** × **3 paddings**. Balanced to an equal number of images per language. The line-number gutter, when present, is visual only and is **never** part of the `text` target. ## Sources & license - **CodeSearchNet** — [code-search-net/code_search_net](https://huggingface.co/datasets/code-search-net/code_search_net): Go, Java, JavaScript, PHP, Python, Ruby (complete functions from open-source GitHub repos). - **GitHub Code Snippets** by Bugout.dev / Simiotic — [kaggle](https://www.kaggle.com/datasets/simiotic/github-code-snippets) (CC BY 4.0): C, C++ blocks. Released under **CC BY 4.0**. The underlying code originates from public GitHub repositories under their respective open-source licenses; please retain attribution to the sources above. ## Citation ```bibtex @misc{code_image_to_text, title = {Code Snippet Image to Text}, author = {anisiraj}, year = {2026}, url = {https://huggingface.co/datasets/anisiraj/code-image-to-text} } ```