Hugging Face's logo Hugging Face
  • Models
  • Datasets
  • Spaces
  • Buckets
  • Docs
  • Enterprise
  • Pricing
    • Website
      • Tasks
      • HuggingChat
      • Collections
      • Languages
      • Organizations
    • Community
      • Blog
      • Posts
      • Daily Papers
      • Hardware
      • Learn
      • Discord
      • Forum
      • GitHub
    • Solutions
      • Team & Enterprise
      • Hugging Face PRO
      • Enterprise Support
      • Inference Providers
      • Inference Endpoints
      • Storage Buckets

  • Log In
  • Sign Up

Duplicated from  zai-org/GLM-OCR

randomguyforrealszzzzzzzz
/
GLM-OCR

Image-to-Text
Transformers
Safetensors
glm_ocr
image-text-to-text
conversational
Eval Results
Model card Files Files and versions
xet
Community

Instructions to use randomguyforrealszzzzzzzz/GLM-OCR with libraries, inference providers, notebooks, and local apps. Follow these links to get started.

  • Libraries
  • Transformers

    How to use randomguyforrealszzzzzzzz/GLM-OCR with Transformers:

    # Use a pipeline as a high-level helper
    # Warning: Pipeline type "image-to-text" is no longer supported in transformers v5.
    # You must load the model directly (see below) or downgrade to v4.x with:
    # pip install "transformers<5.0.0"
    from transformers import pipeline
    
    pipe = pipeline("image-to-text", model="randomguyforrealszzzzzzzz/GLM-OCR")
    messages = [
        {
            "role": "user",
            "content": [
                {"type": "image", "url": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/p-blog/candy.JPG"},
                {"type": "text", "text": "What animal is on the candy?"}
            ]
        },
    ]
    pipe(text=messages)
    # pip install -U transformers accelerate
    # Load model directly
    from transformers import AutoTokenizer, AutoModelForMultimodalLM
    
    tokenizer = AutoTokenizer.from_pretrained("randomguyforrealszzzzzzzz/GLM-OCR")
    model = AutoModelForMultimodalLM.from_pretrained("randomguyforrealszzzzzzzz/GLM-OCR", device_map="auto")
    messages = [
        {
            "role": "user",
            "content": [
                {"type": "image", "url": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/p-blog/candy.JPG"},
                {"type": "text", "text": "What animal is on the candy?"}
            ]
        },
    ]
    inputs = tokenizer.apply_chat_template(
    	messages,
    	add_generation_prompt=True,
    	tokenize=True,
    	return_dict=True,
    	return_tensors="pt",
    ).to(model.device)
    
    outputs = model.generate(**inputs, max_new_tokens=256)
    print(tokenizer.decode(outputs[0][inputs["input_ids"].shape[-1]:]))
  • Notebooks
  • Google Colab
  • Kaggle
GLM-OCR
2.66 GB
Ctrl+K
Ctrl+K
  • 2 contributors
History: 1 commit
randomguyforrealszzzzzzzz's picture
randomguyforrealszzzzzzzz
ZHANGYUXUAN-zR's picture
ZHANGYUXUAN-zR
Duplicate from zai-org/GLM-OCR
d9ef971 10 days ago
  • .eval_results
    Duplicate from zai-org/GLM-OCR 10 days ago
  • .gitattributes
    1.52 kB
    Duplicate from zai-org/GLM-OCR 10 days ago
  • README.md
    6.8 kB
    Duplicate from zai-org/GLM-OCR 10 days ago
  • chat_template.jinja
    4.61 kB
    Duplicate from zai-org/GLM-OCR 10 days ago
  • config.json
    1.74 kB
    Duplicate from zai-org/GLM-OCR 10 days ago
  • generation_config.json
    165 Bytes
    Duplicate from zai-org/GLM-OCR 10 days ago
  • model.safetensors
    2.65 GB
    xet
    Duplicate from zai-org/GLM-OCR 10 days ago
  • preprocessor_config.json
    367 Bytes
    Duplicate from zai-org/GLM-OCR 10 days ago
  • processor_config.json
    1.33 kB
    Duplicate from zai-org/GLM-OCR 10 days ago
  • tokenizer.json
    6.84 MB
    Duplicate from zai-org/GLM-OCR 10 days ago
  • tokenizer_config.json
    1.14 kB
    Duplicate from zai-org/GLM-OCR 10 days ago