Image-Text-to-Text
Transformers
Safetensors
qwen2_5_vl
qwen3_vl
vision-language
visual-token-pruning
visionzip
scopd
Instructions to use enmingzhangzz/SCOPD with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use enmingzhangzz/SCOPD with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("image-text-to-text", model="enmingzhangzz/SCOPD")# pip install -U transformers accelerate # Load model directly from transformers import AutoModel model = AutoModel.from_pretrained("enmingzhangzz/SCOPD", device_map="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use enmingzhangzz/SCOPD with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "enmingzhangzz/SCOPD" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "enmingzhangzz/SCOPD", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/enmingzhangzz/SCOPD
- SGLang
How to use enmingzhangzz/SCOPD 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 "enmingzhangzz/SCOPD" \ --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": "enmingzhangzz/SCOPD", "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 "enmingzhangzz/SCOPD" \ --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": "enmingzhangzz/SCOPD", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use enmingzhangzz/SCOPD with Docker Model Runner:
docker model run hf.co/enmingzhangzz/SCOPD
File size: 2,450 Bytes
ab18ce0 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 | """Existing evaluator fixes, applied to pinned functions in this process only."""
import ast
import inspect
import textwrap
def patch_wrapper_source(source, video_timing=False):
tree = ast.parse(textwrap.dedent(source))
tree.body[0].decorator_list = []
counts = {'fps_return': 0, 'fps_forward': 0, 'counters': 0}
for node in ast.walk(tree):
if (video_timing and isinstance(node, ast.Assign) and isinstance(node.value, ast.Call)
and isinstance(node.value.func, ast.Name) and node.value.func.id == 'process_vision_info'):
assert ast.unparse(node.targets[0]) == '(images, videos)'
node.targets[0].elts.append(ast.Name(id='video_kwargs', ctx=ast.Store()))
node.value.keywords.append(ast.keyword(arg='return_video_kwargs', value=ast.Constant(True)))
counts['fps_return'] += 1
if (video_timing and isinstance(node, ast.Call) and ast.unparse(node.func) == 'self.processor'
and {kw.arg for kw in node.keywords} == {'text', 'images', 'videos', 'padding', 'return_tensors'}):
node.keywords.append(ast.keyword(arg=None, value=ast.parse(
'video_kwargs if videos is not None else {}', mode='eval').body))
counts['fps_forward'] += 1
if isinstance(node, ast.Assign) and ast.unparse(node.targets[0]) == 'sample_initial_visual_tokens':
for grid in ('image_grid_thw', 'video_grid_thw'):
if ast.unparse(node.value) == f'inputs.{grid}.prod().item() // 4':
node.value = ast.parse(f'inputs.{grid}.prod(dim=-1).sum().item() // 4', mode='eval').body
counts['counters'] += 1
assert counts == {'fps_return': int(video_timing), 'fps_forward': int(video_timing), 'counters': 2}, counts
return ast.fix_missing_locations(tree)
def install_wrapper(video_timing=False):
from vlmeval.vlm.qwen2_vl.model import Qwen2VLChat
if getattr(Qwen2VLChat, '_portable_runtime_fixes', False):
return
function = Qwen2VLChat.generate_inner_transformers
if function.__code__.co_freevars:
raise RuntimeError('Unexpected closure in patched wrapper')
tree = patch_wrapper_source(inspect.getsource(function), video_timing)
namespace = {}
exec(compile(tree, __file__, 'exec'), function.__globals__, namespace)
function.__code__ = namespace[function.__name__].__code__
Qwen2VLChat._portable_runtime_fixes = True
|