Image-Text-to-Text
Transformers
Diffusers
Safetensors
qwen3_vl
vision-language-model
image-decomposition
conversational
Instructions to use SynLayers/Bbox-caption-8b with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use SynLayers/Bbox-caption-8b with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("image-text-to-text", model="SynLayers/Bbox-caption-8b") 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, AutoModelForImageTextToText processor = AutoProcessor.from_pretrained("SynLayers/Bbox-caption-8b") model = AutoModelForImageTextToText.from_pretrained("SynLayers/Bbox-caption-8b") 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
- vLLM
How to use SynLayers/Bbox-caption-8b with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "SynLayers/Bbox-caption-8b" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "SynLayers/Bbox-caption-8b", "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/SynLayers/Bbox-caption-8b
- SGLang
How to use SynLayers/Bbox-caption-8b 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 "SynLayers/Bbox-caption-8b" \ --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": "SynLayers/Bbox-caption-8b", "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 "SynLayers/Bbox-caption-8b" \ --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": "SynLayers/Bbox-caption-8b", "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" } } ] } ] }' - Docker Model Runner
How to use SynLayers/Bbox-caption-8b with Docker Model Runner:
docker model run hf.co/SynLayers/Bbox-caption-8b
Upload demo/publish_space.py with huggingface_hub
Browse files- demo/publish_space.py +83 -0
demo/publish_space.py
ADDED
|
@@ -0,0 +1,83 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from __future__ import annotations
|
| 2 |
+
|
| 3 |
+
import argparse
|
| 4 |
+
import os
|
| 5 |
+
from pathlib import Path
|
| 6 |
+
|
| 7 |
+
from huggingface_hub import HfApi
|
| 8 |
+
|
| 9 |
+
PROJECT_ROOT = Path(__file__).resolve().parents[1]
|
| 10 |
+
|
| 11 |
+
STATIC_FILE_MAP = {
|
| 12 |
+
PROJECT_ROOT / "demo" / "__init__.py": "demo/__init__.py",
|
| 13 |
+
PROJECT_ROOT / "demo" / "app.py": "app.py",
|
| 14 |
+
PROJECT_ROOT / "demo" / "hf_repo_assets.py": "demo/hf_repo_assets.py",
|
| 15 |
+
PROJECT_ROOT / "demo" / "README.md": "README.md",
|
| 16 |
+
PROJECT_ROOT / "demo" / "publish_space.py": "demo/publish_space.py",
|
| 17 |
+
PROJECT_ROOT / "demo" / "requirements-hf-space.txt": "requirements.txt",
|
| 18 |
+
PROJECT_ROOT / "demo" / "real_world_pipeline.py": "demo/real_world_pipeline.py",
|
| 19 |
+
PROJECT_ROOT / "demo" / "upload_used_bundle_to_hf.py": "demo/upload_used_bundle_to_hf.py",
|
| 20 |
+
PROJECT_ROOT / "demo" / "infer" / "__init__.py": "demo/infer/__init__.py",
|
| 21 |
+
PROJECT_ROOT / "demo" / "infer" / "run_caption_bbox_infer.py": "demo/infer/run_caption_bbox_infer.py",
|
| 22 |
+
PROJECT_ROOT / "demo" / "infer" / "vlm_bbox_inference.py": "demo/infer/vlm_bbox_inference.py",
|
| 23 |
+
PROJECT_ROOT / "infer" / "__init__.py": "infer/__init__.py",
|
| 24 |
+
PROJECT_ROOT / "infer" / "common_infer.py": "infer/common_infer.py",
|
| 25 |
+
PROJECT_ROOT / "infer" / "infer.py": "infer/infer.py",
|
| 26 |
+
PROJECT_ROOT / "infer" / "infer.yaml": "infer/infer.yaml",
|
| 27 |
+
}
|
| 28 |
+
|
| 29 |
+
DIRECTORIES_TO_UPLOAD = [
|
| 30 |
+
PROJECT_ROOT / "models",
|
| 31 |
+
PROJECT_ROOT / "tools",
|
| 32 |
+
]
|
| 33 |
+
|
| 34 |
+
|
| 35 |
+
def iter_uploads():
|
| 36 |
+
for local_path, remote_path in STATIC_FILE_MAP.items():
|
| 37 |
+
if local_path.exists():
|
| 38 |
+
yield local_path, remote_path
|
| 39 |
+
|
| 40 |
+
for directory in DIRECTORIES_TO_UPLOAD:
|
| 41 |
+
if not directory.exists():
|
| 42 |
+
continue
|
| 43 |
+
for local_path in directory.rglob("*.py"):
|
| 44 |
+
yield local_path, str(local_path.relative_to(PROJECT_ROOT))
|
| 45 |
+
|
| 46 |
+
|
| 47 |
+
def main():
|
| 48 |
+
parser = argparse.ArgumentParser(
|
| 49 |
+
description="Create or update a Hugging Face Space for the SynLayers demo."
|
| 50 |
+
)
|
| 51 |
+
parser.add_argument("--repo-id", type=str, required=True, help="Target Space repo id, e.g. SynLayers/synlayers-demo")
|
| 52 |
+
parser.add_argument("--token", type=str, default=os.environ.get("HF_TOKEN"))
|
| 53 |
+
parser.add_argument("--private", action="store_true", help="Create the Space as private")
|
| 54 |
+
args = parser.parse_args()
|
| 55 |
+
|
| 56 |
+
if not args.token:
|
| 57 |
+
raise ValueError("Missing Hugging Face token. Pass --token or set HF_TOKEN.")
|
| 58 |
+
|
| 59 |
+
api = HfApi(token=args.token)
|
| 60 |
+
api.create_repo(
|
| 61 |
+
repo_id=args.repo_id,
|
| 62 |
+
repo_type="space",
|
| 63 |
+
private=args.private,
|
| 64 |
+
space_sdk="gradio",
|
| 65 |
+
exist_ok=True,
|
| 66 |
+
)
|
| 67 |
+
|
| 68 |
+
for local_path, remote_path in iter_uploads():
|
| 69 |
+
print(f"Uploading {local_path} -> {remote_path}")
|
| 70 |
+
api.upload_file(
|
| 71 |
+
path_or_fileobj=str(local_path),
|
| 72 |
+
path_in_repo=remote_path,
|
| 73 |
+
repo_id=args.repo_id,
|
| 74 |
+
repo_type="space",
|
| 75 |
+
)
|
| 76 |
+
|
| 77 |
+
print("")
|
| 78 |
+
print(f"Space scaffold uploaded to https://huggingface.co/spaces/{args.repo_id}")
|
| 79 |
+
print("Model assets are not uploaded by this helper; configure them in Space storage or env vars before running.")
|
| 80 |
+
|
| 81 |
+
|
| 82 |
+
if __name__ == "__main__":
|
| 83 |
+
main()
|