Instructions to use NYUAD-ComNets/Gemma4_meme_classification with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use NYUAD-ComNets/Gemma4_meme_classification with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("image-text-to-text", model="NYUAD-ComNets/Gemma4_meme_classification") 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)# Load model directly from transformers import AutoProcessor, AutoModelForMultimodalLM processor = AutoProcessor.from_pretrained("NYUAD-ComNets/Gemma4_meme_classification") model = AutoModelForMultimodalLM.from_pretrained("NYUAD-ComNets/Gemma4_meme_classification", 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 = processor.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=40) print(processor.decode(outputs[0][inputs["input_ids"].shape[-1]:])) - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use NYUAD-ComNets/Gemma4_meme_classification with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "NYUAD-ComNets/Gemma4_meme_classification" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "NYUAD-ComNets/Gemma4_meme_classification", "messages": [ { "role": "user", "content": [ { "type": "text", "text": "Describe this image in one sentence." }, { "type": "image_url", "image_url": { "url": "https://cdn.britannica.com/61/93061-050-99147DCE/Statue-of-Liberty-Island-New-York-Bay.jpg" } } ] } ] }'Use Docker
docker model run hf.co/NYUAD-ComNets/Gemma4_meme_classification
- SGLang
How to use NYUAD-ComNets/Gemma4_meme_classification 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 "NYUAD-ComNets/Gemma4_meme_classification" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "NYUAD-ComNets/Gemma4_meme_classification", "messages": [ { "role": "user", "content": [ { "type": "text", "text": "Describe this image in one sentence." }, { "type": "image_url", "image_url": { "url": "https://cdn.britannica.com/61/93061-050-99147DCE/Statue-of-Liberty-Island-New-York-Bay.jpg" } } ] } ] }'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 "NYUAD-ComNets/Gemma4_meme_classification" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "NYUAD-ComNets/Gemma4_meme_classification", "messages": [ { "role": "user", "content": [ { "type": "text", "text": "Describe this image in one sentence." }, { "type": "image_url", "image_url": { "url": "https://cdn.britannica.com/61/93061-050-99147DCE/Statue-of-Liberty-Island-New-York-Bay.jpg" } } ] } ] }' - Unsloth Desktop
- Docker Model Runner
How to use NYUAD-ComNets/Gemma4_meme_classification with Docker Model Runner:
docker model run hf.co/NYUAD-ComNets/Gemma4_meme_classification
Update README.md
Browse files
README.md
CHANGED
|
@@ -34,6 +34,27 @@ The proposed solutions offer a more nuanced understanding of memes for accurate
|
|
| 34 |
|
| 35 |
``` python
|
| 36 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 37 |
import numpy as np
|
| 38 |
import torch
|
| 39 |
import torch._dynamo
|
|
|
|
| 34 |
|
| 35 |
``` python
|
| 36 |
|
| 37 |
+
|
| 38 |
+
import os
|
| 39 |
+
import torch
|
| 40 |
+
|
| 41 |
+
# 1. Create a dummy pass-through decorator to replace torch.compile
|
| 42 |
+
def dummy_compile(fn=None, *args, **kwargs):
|
| 43 |
+
if fn is None:
|
| 44 |
+
return lambda x: x
|
| 45 |
+
return fn
|
| 46 |
+
|
| 47 |
+
# 2. Patch torch.compile BEFORE unsloth imports
|
| 48 |
+
torch.compile = dummy_compile
|
| 49 |
+
os.environ["UNSLOTH_FUSED_FORWARD"] = "0"
|
| 50 |
+
os.environ["UNSLOTH_DISABLE_AUTO_UPDATES"] = "1"
|
| 51 |
+
|
| 52 |
+
# 3. Import Unsloth safely now
|
| 53 |
+
from unsloth import FastVisionModel
|
| 54 |
+
|
| 55 |
+
print("SUCCESS: Unsloth loaded smoothly without compiler errors!")
|
| 56 |
+
|
| 57 |
+
|
| 58 |
import numpy as np
|
| 59 |
import torch
|
| 60 |
import torch._dynamo
|