Instructions to use xiaoyu1104/InstanceControl_canny with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use xiaoyu1104/InstanceControl_canny with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("image-text-to-text", model="xiaoyu1104/InstanceControl_canny")# Load model directly from transformers import AutoModel model = AutoModel.from_pretrained("xiaoyu1104/InstanceControl_canny", dtype="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use xiaoyu1104/InstanceControl_canny with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "xiaoyu1104/InstanceControl_canny" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "xiaoyu1104/InstanceControl_canny", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/xiaoyu1104/InstanceControl_canny
- SGLang
How to use xiaoyu1104/InstanceControl_canny 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 "xiaoyu1104/InstanceControl_canny" \ --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": "xiaoyu1104/InstanceControl_canny", "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 "xiaoyu1104/InstanceControl_canny" \ --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": "xiaoyu1104/InstanceControl_canny", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use xiaoyu1104/InstanceControl_canny with Docker Model Runner:
docker model run hf.co/xiaoyu1104/InstanceControl_canny
Add model card for Sa2va-Instance-4B (Stage 1 of InstanceControl)
#1
by nielsr HF Staff - opened
README.md
ADDED
|
@@ -0,0 +1,63 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
license: apache-2.0
|
| 3 |
+
library_name: transformers
|
| 4 |
+
pipeline_tag: image-text-to-text
|
| 5 |
+
---
|
| 6 |
+
|
| 7 |
+
# Sa2va-Instance-4B (Stage 1 of InstanceControl)
|
| 8 |
+
|
| 9 |
+
This repository contains the **Sa2va-Instance-4B** model checkpoint, which serves as the Stage 1 (instance parsing/mask prediction) model of **InstanceControl**, presented in the paper [InstanceControl: Controllable Complex Image Generation without Instance Labeling](https://huggingface.co/papers/2606.31924).
|
| 10 |
+
|
| 11 |
+
* **Project Page:** [InstanceControl Homepage](https://instancecontrol.github.io/InstanceControl/)
|
| 12 |
+
* **Repository:** [GitHub - liuxiaoyu1104/InstanceControl](https://github.com/liuxiaoyu1104/InstanceControl)
|
| 13 |
+
* **Dataset (MIG-Train):** [MIG_train](https://huggingface.co/datasets/xiaoyu1104/MIG_train)
|
| 14 |
+
* **Evaluation Benchmark:** [MIG-Eval](https://huggingface.co/datasets/xiaoyu1104/MIG-Eval)
|
| 15 |
+
|
| 16 |
+
---
|
| 17 |
+
|
| 18 |
+
## Model Description
|
| 19 |
+
|
| 20 |
+
InstanceControl is a multi-instance controllable generation method that eliminates the need for manual instance labeling.
|
| 21 |
+
|
| 22 |
+
**Sa2va-Instance-4B** is a Vision-Language Model (VLM) designed to establish instance-level correspondences between text prompts and visual conditions (such as Canny edge maps, depth maps, or HED boundary maps). It automatically parses instance descriptions from the text prompts and predicts instance masks based on the visual conditions. These predicted masks are then dynamically refined during the Stage 2 generation process using a modified FLUX ControlNet.
|
| 23 |
+
|
| 24 |
+
---
|
| 25 |
+
|
| 26 |
+
## Installation
|
| 27 |
+
|
| 28 |
+
To set up the environment for running Sa2va-Instance-4B, follow these steps:
|
| 29 |
+
|
| 30 |
+
```bash
|
| 31 |
+
conda create -n instancecontrol python=3.10
|
| 32 |
+
conda activate instancecontrol
|
| 33 |
+
|
| 34 |
+
pip install torch==2.4.0 torchvision==0.19.0 torchaudio==2.4.0 --index-url https://download.pytorch.org/whl/cu121
|
| 35 |
+
pip install -r requirements.txt
|
| 36 |
+
```
|
| 37 |
+
|
| 38 |
+
## Quick Start (Stage 1 Inference)
|
| 39 |
+
|
| 40 |
+
To predict instance masks from your visual conditions and prompt JSON files, place the model checkpoint under `pretrain_model/InstanceControl_canny/Sa2va-Instance-4B` and run:
|
| 41 |
+
|
| 42 |
+
```bash
|
| 43 |
+
python stage1_Sa2VA/projects/llava_sam2/evaluation/gcg_eval_our_folders.py \
|
| 44 |
+
--model_path ./pretrain_model/InstanceControl_canny/Sa2va-Instance-4B \
|
| 45 |
+
--image_dir ./example/canny \
|
| 46 |
+
--json_dir ./example/json \
|
| 47 |
+
--save_dir ./results/json_pred_canny
|
| 48 |
+
```
|
| 49 |
+
|
| 50 |
+
For more details on training, dataset formatting, and generating final images using the Stage 2 FLUX ControlNet, please refer to the [GitHub Repository](https://github.com/liuxiaoyu1104/InstanceControl).
|
| 51 |
+
|
| 52 |
+
## Citation
|
| 53 |
+
|
| 54 |
+
If you find this model or the project useful, please cite:
|
| 55 |
+
|
| 56 |
+
```bibtex
|
| 57 |
+
@article{instancecontrol,
|
| 58 |
+
title = {InstanceControl: Controllable Complex Image Generation without Instance Labeling},
|
| 59 |
+
author = {Xiaoyu Liu and Huan Wang and Fan Li and Zhixin Wang and Jiaqi Xu and Ming Liu and Wangmeng Zuo},
|
| 60 |
+
journal = {arXiv preprint arXiv:2606.31924},
|
| 61 |
+
year = {2026}
|
| 62 |
+
}
|
| 63 |
+
```
|