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 +1 -102
demo/README.md
CHANGED
|
@@ -6,7 +6,7 @@ colorTo: purple
|
|
| 6 |
sdk: gradio
|
| 7 |
python_version: "3.10"
|
| 8 |
app_file: app.py
|
| 9 |
-
suggested_hardware:
|
| 10 |
models:
|
| 11 |
- SynLayers/Bbox-caption-8b
|
| 12 |
pinned: false
|
|
@@ -20,7 +20,6 @@ This folder now contains a unified real-world inference demo:
|
|
| 20 |
2. `infer/infer.py` runs SynLayers decomposition with `infer/infer.yaml`.
|
| 21 |
3. `demo/real_world_pipeline.py` stitches the two stages together for one uploaded image.
|
| 22 |
4. `demo/app.py` provides a Gradio interface that can be used locally or adapted for a Hugging Face Space.
|
| 23 |
-
5. `demo/upload_used_bundle_to_hf.py` uploads only the Python/config files actually used by the demo, plus the selected runtime assets.
|
| 24 |
|
| 25 |
## Local Run
|
| 26 |
|
|
@@ -37,104 +36,4 @@ python demo/real_world_pipeline.py \
|
|
| 37 |
--image "/path/to/your/image.png"
|
| 38 |
```
|
| 39 |
|
| 40 |
-
## Default Models
|
| 41 |
|
| 42 |
-
The current local defaults are:
|
| 43 |
-
|
| 44 |
-
- bbox-caption model:
|
| 45 |
-
`/project/llmsvgen/share/data/kmw_layered_checkpoint/Bbox-caption-8b`
|
| 46 |
-
- SynLayers base checkpoints:
|
| 47 |
-
`/project/llmsvgen/share/data/kmw_layered_checkpoint/SynLayers_checkpoints`
|
| 48 |
-
- SynLayers decomposition checkpoint:
|
| 49 |
-
`/project/llmsvgen/share/data/kmw_layered_checkpoint/SynLayers_ckpt/step_120000`
|
| 50 |
-
- base config:
|
| 51 |
-
`infer/infer.yaml`
|
| 52 |
-
|
| 53 |
-
## Hugging Face Space Notes
|
| 54 |
-
|
| 55 |
-
The Gradio app is ready for a Hugging Face Space.
|
| 56 |
-
After you upload the model/runtime bundle to `SynLayers/Bbox-caption-8b`, the Space can download
|
| 57 |
-
those uploaded assets automatically and use them directly.
|
| 58 |
-
|
| 59 |
-
The app supports overriding the local defaults with environment variables:
|
| 60 |
-
|
| 61 |
-
- `SYNLAYERS_MODEL_REPO`
|
| 62 |
-
- `SYNLAYERS_BBOX_MODEL`
|
| 63 |
-
- `SYNLAYERS_BASE_MODEL`
|
| 64 |
-
- `SYNLAYERS_ADAPTER_MODEL`
|
| 65 |
-
- `SYNLAYERS_TRANSP_VAE`
|
| 66 |
-
- `SYNLAYERS_PRETRAINED_LORA`
|
| 67 |
-
- `SYNLAYERS_ARTPLUS_LORA`
|
| 68 |
-
- `SYNLAYERS_DECOMP_CKPT_ROOT`
|
| 69 |
-
- `SYNLAYERS_REAL_CONFIG`
|
| 70 |
-
- `SYNLAYERS_DEMO_WORK_DIR`
|
| 71 |
-
- `SYNLAYERS_EXAMPLE_DIR`
|
| 72 |
-
|
| 73 |
-
In practice, for a real Hugging Face Space deployment you will want to:
|
| 74 |
-
|
| 75 |
-
1. upload the required model/runtime assets to `SynLayers/Bbox-caption-8b`
|
| 76 |
-
2. create a Gradio Space repo, for example `SynLayers/synlayers-real-world-demo`
|
| 77 |
-
3. upload the Space scaffold with `demo/publish_space.py`
|
| 78 |
-
4. set `SYNLAYERS_MODEL_REPO=SynLayers/Bbox-caption-8b` in the Space settings
|
| 79 |
-
5. launch `app.py` as the Space entrypoint
|
| 80 |
-
|
| 81 |
-
### Public interface flow
|
| 82 |
-
|
| 83 |
-
1. Upload the model/runtime bundle:
|
| 84 |
-
|
| 85 |
-
```bash
|
| 86 |
-
python demo/upload_used_bundle_to_hf.py \
|
| 87 |
-
--repo-id SynLayers/Bbox-caption-8b
|
| 88 |
-
```
|
| 89 |
-
|
| 90 |
-
2. Create and upload the Space scaffold:
|
| 91 |
-
|
| 92 |
-
```bash
|
| 93 |
-
python demo/publish_space.py \
|
| 94 |
-
--repo-id SynLayers/synlayers-real-world-demo
|
| 95 |
-
```
|
| 96 |
-
|
| 97 |
-
3. In the Hugging Face Space settings, add:
|
| 98 |
-
|
| 99 |
-
```text
|
| 100 |
-
SYNLAYERS_MODEL_REPO=SynLayers/Bbox-caption-8b
|
| 101 |
-
```
|
| 102 |
-
|
| 103 |
-
Then the public Space interface will:
|
| 104 |
-
|
| 105 |
-
- accept a user image upload
|
| 106 |
-
- load the bbox-caption model from the uploaded model repo
|
| 107 |
-
- download the SynLayers decomposition assets from that same repo
|
| 108 |
-
- run the one-step decomposition pipeline
|
| 109 |
-
- return the bbox visualization, merged output, per-layer outputs, and a downloadable archive
|
| 110 |
-
|
| 111 |
-
## Upload Bundle
|
| 112 |
-
|
| 113 |
-
To upload the minimal used demo bundle to a Hugging Face repo:
|
| 114 |
-
|
| 115 |
-
```bash
|
| 116 |
-
python demo/upload_used_bundle_to_hf.py \
|
| 117 |
-
--repo-id SynLayers/Bbox-caption-8b
|
| 118 |
-
```
|
| 119 |
-
|
| 120 |
-
This uploads:
|
| 121 |
-
|
| 122 |
-
- the used `demo`, `infer`, `models`, and `tools` Python files
|
| 123 |
-
- `demo/upload_used_bundle_to_hf.py`
|
| 124 |
-
- `demo/publish_space.py`
|
| 125 |
-
- `infer/infer.yaml`
|
| 126 |
-
- `environment.yml`
|
| 127 |
-
- `ckpt/trans_vae/0008000.pt`
|
| 128 |
-
- `ckpt/pre_trained_LoRA/pytorch_lora_weights.safetensors`
|
| 129 |
-
- `ckpt/prism_ft_LoRA/pytorch_lora_weights.safetensors`
|
| 130 |
-
- `SynLayers_ckpt/step_120000`
|
| 131 |
-
- `SynLayers_checkpoints/FLUX.1-dev`
|
| 132 |
-
- `SynLayers_checkpoints/FLUX.1-dev-Controlnet-Inpainting-Alpha`
|
| 133 |
-
|
| 134 |
-
## Fixed Prompt
|
| 135 |
-
|
| 136 |
-
The bbox detector always uses the fixed prompt defined in:
|
| 137 |
-
|
| 138 |
-
- `demo/infer/run_caption_bbox_infer.py`
|
| 139 |
-
|
| 140 |
-
No extra user text prompt is required.
|
|
|
|
| 6 |
sdk: gradio
|
| 7 |
python_version: "3.10"
|
| 8 |
app_file: app.py
|
| 9 |
+
suggested_hardware: a100-large
|
| 10 |
models:
|
| 11 |
- SynLayers/Bbox-caption-8b
|
| 12 |
pinned: false
|
|
|
|
| 20 |
2. `infer/infer.py` runs SynLayers decomposition with `infer/infer.yaml`.
|
| 21 |
3. `demo/real_world_pipeline.py` stitches the two stages together for one uploaded image.
|
| 22 |
4. `demo/app.py` provides a Gradio interface that can be used locally or adapted for a Hugging Face Space.
|
|
|
|
| 23 |
|
| 24 |
## Local Run
|
| 25 |
|
|
|
|
| 36 |
--image "/path/to/your/image.png"
|
| 37 |
```
|
| 38 |
|
|
|
|
| 39 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|