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/README.md with huggingface_hub
Browse files- demo/README.md +98 -0
demo/README.md
ADDED
|
@@ -0,0 +1,98 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# SynLayers Demo
|
| 2 |
+
|
| 3 |
+
This folder now contains a unified real-world inference demo:
|
| 4 |
+
|
| 5 |
+
1. `demo/infer` runs the fixed-prompt VLM caption + bbox detector.
|
| 6 |
+
2. `infer/infer.py` runs SynLayers decomposition with `infer/infer.yaml`.
|
| 7 |
+
3. `demo/real_world_pipeline.py` stitches the two stages together for one uploaded image.
|
| 8 |
+
4. `demo/app.py` provides a Gradio interface that can be used locally or adapted for a Hugging Face Space.
|
| 9 |
+
5. `demo/upload_used_bundle_to_hf.py` uploads only the Python/config files actually used by the demo, plus the selected runtime assets.
|
| 10 |
+
|
| 11 |
+
## Local Run
|
| 12 |
+
|
| 13 |
+
From the `SynLayers` root:
|
| 14 |
+
|
| 15 |
+
```bash
|
| 16 |
+
python demo/app.py
|
| 17 |
+
```
|
| 18 |
+
|
| 19 |
+
Or run the unified CLI directly:
|
| 20 |
+
|
| 21 |
+
```bash
|
| 22 |
+
python demo/real_world_pipeline.py \
|
| 23 |
+
--image "/path/to/your/image.png"
|
| 24 |
+
```
|
| 25 |
+
|
| 26 |
+
## Default Models
|
| 27 |
+
|
| 28 |
+
The current local defaults are:
|
| 29 |
+
|
| 30 |
+
- bbox-caption model:
|
| 31 |
+
`/project/llmsvgen/share/data/kmw_layered_checkpoint/Bbox-caption-8b`
|
| 32 |
+
- SynLayers base checkpoints:
|
| 33 |
+
`/project/llmsvgen/share/data/kmw_layered_checkpoint/SynLayers_checkpoints`
|
| 34 |
+
- SynLayers decomposition checkpoint:
|
| 35 |
+
`/project/llmsvgen/share/data/kmw_layered_checkpoint/SynLayers_ckpt/step_120000`
|
| 36 |
+
- base config:
|
| 37 |
+
`infer/infer.yaml`
|
| 38 |
+
|
| 39 |
+
## Hugging Face Space Notes
|
| 40 |
+
|
| 41 |
+
The Gradio app is ready, but the current default model paths are cluster-local absolute paths.
|
| 42 |
+
That means an online Hugging Face Space will only run after the model assets are made available
|
| 43 |
+
inside the Space runtime.
|
| 44 |
+
|
| 45 |
+
The app supports overriding the local defaults with environment variables:
|
| 46 |
+
|
| 47 |
+
- `SYNLAYERS_BBOX_MODEL`
|
| 48 |
+
- `SYNLAYERS_BASE_MODEL`
|
| 49 |
+
- `SYNLAYERS_ADAPTER_MODEL`
|
| 50 |
+
- `SYNLAYERS_TRANSP_VAE`
|
| 51 |
+
- `SYNLAYERS_PRETRAINED_LORA`
|
| 52 |
+
- `SYNLAYERS_ARTPLUS_LORA`
|
| 53 |
+
- `SYNLAYERS_DECOMP_CKPT_ROOT`
|
| 54 |
+
- `SYNLAYERS_REAL_CONFIG`
|
| 55 |
+
- `SYNLAYERS_DEMO_WORK_DIR`
|
| 56 |
+
- `SYNLAYERS_EXAMPLE_DIR`
|
| 57 |
+
|
| 58 |
+
In practice, for a real Hugging Face Space deployment you will want to:
|
| 59 |
+
|
| 60 |
+
1. upload or mirror the required model assets to Hugging Face-accessible storage
|
| 61 |
+
2. set the environment variables above in the Space settings
|
| 62 |
+
3. launch `demo/app.py` as the Space entrypoint
|
| 63 |
+
|
| 64 |
+
## Upload Bundle
|
| 65 |
+
|
| 66 |
+
To upload the minimal used demo bundle to a Hugging Face repo:
|
| 67 |
+
|
| 68 |
+
```bash
|
| 69 |
+
python demo/upload_used_bundle_to_hf.py \
|
| 70 |
+
--repo-id SynLayers/Bbox-caption-8b
|
| 71 |
+
```
|
| 72 |
+
|
| 73 |
+
This uploads:
|
| 74 |
+
|
| 75 |
+
- the used `demo`, `infer`, `models`, and `tools` Python files
|
| 76 |
+
- `infer/infer.yaml`
|
| 77 |
+
- `environment.yml`
|
| 78 |
+
- `ckpt/trans_vae/0008000.pt`
|
| 79 |
+
- `ckpt/pre_trained_LoRA/pytorch_lora_weights.safetensors`
|
| 80 |
+
- `ckpt/prism_ft_LoRA/pytorch_lora_weights.safetensors`
|
| 81 |
+
- `SynLayers_ckpt/step_120000`
|
| 82 |
+
- `SynLayers_checkpoints/FLUX.1-dev-Controlnet-Inpainting-Alpha`
|
| 83 |
+
|
| 84 |
+
If you also want to upload the large base checkpoints, add:
|
| 85 |
+
|
| 86 |
+
```bash
|
| 87 |
+
python demo/upload_used_bundle_to_hf.py \
|
| 88 |
+
--repo-id SynLayers/Bbox-caption-8b \
|
| 89 |
+
--include-base-checkpoints
|
| 90 |
+
```
|
| 91 |
+
|
| 92 |
+
## Fixed Prompt
|
| 93 |
+
|
| 94 |
+
The bbox detector always uses the fixed prompt defined in:
|
| 95 |
+
|
| 96 |
+
- `demo/infer/run_caption_bbox_infer.py`
|
| 97 |
+
|
| 98 |
+
No extra user text prompt is required.
|