CoolFace
Modelpublic

michealnaye/AmharicCLIP

sourceHugging Facecreativeml-openrail-mupdated 3mo agoView on Hugging Face
0likes
Model Card

AmharicCLIP

Stable Diffusion v1.5 extended to support Amharic (Ethiopic script) prompts.

This repository contains three components โ€” each with its own documentation:

ComponentFolderDescription
๐Ÿ”ค Text Encoder`text_encoder/`Fine-tuned CLIPTextModel with Amharic support
๐Ÿ“ Tokenizer`tokenizer/`Patched tokenizer with 512 Ethiopic atomic tokens
๐Ÿ–ผ๏ธ Full Pipeline`pipeline/`Complete SD v1.5 with Amharic text encoder

Quick Start

python
from diffusers import StableDiffusionPipeline
from huggingface_hub import snapshot_download
import torch

# Download pipeline from HuggingFace
path = snapshot_download(
    repo_id="michealnaye/AmharicCLIP",
    allow_patterns="pipeline/*",
)

# Load pipeline
pipe = StableDiffusionPipeline.from_pretrained(
    f"{path}/pipeline",
    torch_dtype=torch.float16,
    safety_checker=None,
)
pipe = pipe.to("cuda")

# Generate from Amharic prompt
image = pipe("แ‹จแ‹ตแˆ˜แ‰ต แŽแ‰ถ").images[0]  # photo of a cat
image.save("cat.png")

Example Results

Amharic PromptEnglishGenerated
แ‹จแ‹ตแˆ˜แ‰ต แŽแ‰ถphoto of a catโœ“
แ‹จแ‹แˆป แŽแ‰ถphoto of a dogโœ“
แ‹จแ‹แˆ†แŠ• แŽแ‰ถphoto of an elephantโœ“
แ‹จแˆแˆจแˆต แŽแ‰ถphoto of a horseโœ“
แ‹จแ‰ขแˆซแ‰ขแˆฎ แŽแ‰ถphoto of a butterflyโœ“

The Problem We Solved

OpenAI's CLIP tokenizer has no Amharic vocabulary. Each Ethiopic character fragments into 9 byte-level tokens, causing:

  • โ€”Severe context window waste (77-token limit hit quickly)
  • โ€”Meaningless embeddings โ†’ SD generates noise instead of images

Our fix reduces token count by 66% and achieves 100% round-trip fidelity.

Citation

bibtex
@misc{amharicclip2024,
  title={AmharicCLIP: Extending CLIP to Amharic via Atomic Tokenization and Knowledge Distillation},
  author={Micheal Naye},
  year={2024},
  publisher={HuggingFace},
  url={https://huggingface.co/michealnaye/AmharicCLIP}
}