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
Create Dockerfile
Browse files- Dockerfile +22 -0
Dockerfile
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Use a modern PyTorch image that already has CUDA 12+
|
| 2 |
+
FROM pytorch/pytorch:2.4.0-cuda12.1-cudnn9-devel
|
| 3 |
+
|
| 4 |
+
# Install the exact versions we need
|
| 5 |
+
RUN pip install --no-cache-dir \
|
| 6 |
+
transformers>=5.1.0 \
|
| 7 |
+
accelerate \
|
| 8 |
+
fastapi \
|
| 9 |
+
uvicorn \
|
| 10 |
+
python-multipart \
|
| 11 |
+
pillow
|
| 12 |
+
|
| 13 |
+
# Copy your model files into the container
|
| 14 |
+
COPY . /repository
|
| 15 |
+
WORKDIR /repository
|
| 16 |
+
|
| 17 |
+
# Expose the port Hugging Face expects
|
| 18 |
+
EXPOSE 80
|
| 19 |
+
|
| 20 |
+
# Start a tiny web server that talks to your handler.py
|
| 21 |
+
# We use a helper script to bridge the gap
|
| 22 |
+
CMD ["uvicorn", "handler:app", "--host", "0.0.0.0", "--port", "80"]
|