Instructions to use momergul/git_test with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use momergul/git_test with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("image-text-to-text", model="momergul/git_test", trust_remote_code=True)# Load model directly from transformers import AutoProcessor, AutoModelForImageTextToText processor = AutoProcessor.from_pretrained("momergul/git_test", trust_remote_code=True) model = AutoModelForImageTextToText.from_pretrained("momergul/git_test", trust_remote_code=True) - Notebooks
- Google Colab
- Kaggle
- Local Apps
- vLLM
How to use momergul/git_test with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "momergul/git_test" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "momergul/git_test", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/momergul/git_test
- SGLang
How to use momergul/git_test with SGLang:
Install from pip and serve model
# Install SGLang from pip: pip install sglang # Start the SGLang server: python3 -m sglang.launch_server \ --model-path "momergul/git_test" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "momergul/git_test", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker images
docker run --gpus all \ --shm-size 32g \ -p 30000:30000 \ -v ~/.cache/huggingface:/root/.cache/huggingface \ --env "HF_TOKEN=<secret>" \ --ipc=host \ lmsysorg/sglang:latest \ python3 -m sglang.launch_server \ --model-path "momergul/git_test" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "momergul/git_test", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use momergul/git_test with Docker Model Runner:
docker model run hf.co/momergul/git_test
Upload processor_git.py with huggingface_hub
Browse files- processor_git.py +61 -0
processor_git.py
ADDED
|
@@ -0,0 +1,61 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from transformers import ProcessorMixin, AutoProcessor
|
| 2 |
+
from transformers.models.auto.processing_auto import AutoProcessor
|
| 3 |
+
from transformers.processing_utils import ProcessorMixin
|
| 4 |
+
import json
|
| 5 |
+
import os
|
| 6 |
+
|
| 7 |
+
class GITProcessor(ProcessorMixin):
|
| 8 |
+
"""
|
| 9 |
+
Custom processor that combines a tokenizer and feature extractor.
|
| 10 |
+
"""
|
| 11 |
+
attributes = ["feature_extractor", "tokenizer"]
|
| 12 |
+
feature_extractor_class = "AutoImageProcessor"
|
| 13 |
+
tokenizer_class = "AutoTokenizer"
|
| 14 |
+
|
| 15 |
+
def __init__(self, feature_extractor, tokenizer):
|
| 16 |
+
super().__init__(feature_extractor, tokenizer)
|
| 17 |
+
|
| 18 |
+
def __call__(self, text=None, images=None, **kwargs):
|
| 19 |
+
"""
|
| 20 |
+
Main processing method that handles both text and images.
|
| 21 |
+
|
| 22 |
+
Args:
|
| 23 |
+
text: Text input(s) to tokenize
|
| 24 |
+
images: Image input(s) to process
|
| 25 |
+
**kwargs: Additional arguments passed to tokenizer/feature_extractor
|
| 26 |
+
|
| 27 |
+
Returns:
|
| 28 |
+
Dictionary with processed inputs
|
| 29 |
+
"""
|
| 30 |
+
if text is None and images is None:
|
| 31 |
+
raise ValueError("You need to specify either text or images")
|
| 32 |
+
|
| 33 |
+
encoding = {}
|
| 34 |
+
|
| 35 |
+
# Process text if provided
|
| 36 |
+
if text is not None:
|
| 37 |
+
text_encoding = self.tokenizer(text, **kwargs)
|
| 38 |
+
encoding.update(text_encoding)
|
| 39 |
+
|
| 40 |
+
# Process images if provided
|
| 41 |
+
if images is not None:
|
| 42 |
+
image_encoding = self.feature_extractor(images, **kwargs)
|
| 43 |
+
# Add prefix to avoid key conflicts
|
| 44 |
+
for key, value in image_encoding.items():
|
| 45 |
+
encoding[f"pixel_values" if key == "pixel_values" else f"image_{key}"] = value
|
| 46 |
+
|
| 47 |
+
return encoding
|
| 48 |
+
|
| 49 |
+
def batch_decode(self, *args, **kwargs):
|
| 50 |
+
"""
|
| 51 |
+
Delegate batch decoding to the tokenizer.
|
| 52 |
+
"""
|
| 53 |
+
return self.tokenizer.batch_decode(*args, **kwargs)
|
| 54 |
+
|
| 55 |
+
def decode(self, *args, **kwargs):
|
| 56 |
+
"""
|
| 57 |
+
Delegate decoding to the tokenizer.
|
| 58 |
+
"""
|
| 59 |
+
return self.tokenizer.decode(*args, **kwargs)
|
| 60 |
+
|
| 61 |
+
|