Instructions to use defford/GLM-OCR with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use defford/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="defford/GLM-OCR")# Load model directly from transformers import AutoTokenizer, AutoModelForMultimodalLM tokenizer = AutoTokenizer.from_pretrained("defford/GLM-OCR") model = AutoModelForMultimodalLM.from_pretrained("defford/GLM-OCR", device_map="auto") - Notebooks
- Google Colab
- Kaggle
| # Use a modern PyTorch image that already has CUDA 12+ | |
| FROM pytorch/pytorch:2.4.0-cuda12.1-cudnn9-devel | |
| # Install the exact versions we need | |
| RUN pip install --no-cache-dir \ | |
| transformers>=5.1.0 \ | |
| accelerate \ | |
| fastapi \ | |
| uvicorn \ | |
| python-multipart \ | |
| pillow | |
| # Copy your model files into the container | |
| COPY . /repository | |
| WORKDIR /repository | |
| # Expose the port Hugging Face expects | |
| EXPOSE 80 | |
| # Start a tiny web server that talks to your handler.py | |
| # We use a helper script to bridge the gap | |
| CMD ["uvicorn", "handler:app", "--host", "0.0.0.0", "--port", "80"] |