Image-to-Image
Diffusers
Safetensors
flux
semantic-segmentation
instance-segmentation
referring-segmentation
depth-estimation
surface-normal-estimation
image-editing
text-to-image
Instructions to use FunAILab/Open-Vision-Banana with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Diffusers
How to use FunAILab/Open-Vision-Banana with Diffusers:
pip install -U diffusers transformers accelerate
import torch from diffusers import DiffusionPipeline from diffusers.utils import load_image # switch to "mps" for apple devices pipe = DiffusionPipeline.from_pretrained("FunAILab/Open-Vision-Banana", dtype=torch.bfloat16, device_map="cuda") prompt = "Turn this cat into a dog" input_image = load_image("https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/diffusers/cat.png") image = pipe(image=input_image, prompt=prompt).images[0] - Notebooks
- Google Colab
- Kaggle
Model card: task collage, editing and generation prompts, LoRA adapters
Browse files- .gitattributes +1 -0
- README.md +67 -0
- assets/ovb_collage.jpg +3 -0
- assets/ovb_logo.png +0 -0
.gitattributes
CHANGED
|
@@ -33,3 +33,4 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
|
| 33 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
| 34 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
| 35 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
|
|
|
|
|
| 33 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
| 34 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
| 35 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
| 36 |
+
assets/ovb_collage.jpg filter=lfs diff=lfs merge=lfs -text
|
README.md
CHANGED
|
@@ -11,8 +11,24 @@ tags:
|
|
| 11 |
- referring-segmentation
|
| 12 |
- depth-estimation
|
| 13 |
- surface-normal-estimation
|
|
|
|
|
|
|
| 14 |
---
|
| 15 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 16 |
## Quickstart
|
| 17 |
|
| 18 |
Install PyTorch with CUDA support first, then:
|
|
@@ -119,9 +135,60 @@ prompt = (
|
|
| 119 |
)
|
| 120 |
```
|
| 121 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 122 |
These are quickstart prompts, one per task. The model was trained on many phrasings of each task, so you can adapt them:
|
| 123 |
|
| 124 |
- **Semantic segmentation:** list any classes with an RGB colour each. Distinct, saturated colours work best. Pixels outside the listed classes come out black.
|
| 125 |
- **Referring segmentation:** replace the description and the paint colour.
|
| 126 |
- **Instance segmentation:** prompt one class at a time; replace every `car` in the prompt with any noun phrase. The left-to-right color ordering helps maintain greater separation between assigned colors. The model may not follow it exactly, which is fine: each instance only needs its own distinct colour.
|
| 127 |
- **Depth and surface normals:** use the prompts as they are. Depth is relative inverse depth, with closer points brighter. Normals follow the encoding stated in the prompt.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 11 |
- referring-segmentation
|
| 12 |
- depth-estimation
|
| 13 |
- surface-normal-estimation
|
| 14 |
+
- image-editing
|
| 15 |
+
- text-to-image
|
| 16 |
---
|
| 17 |
|
| 18 |
+
<h1 align="center">Open Vision Banana <img src="assets/ovb_logo.png" height="40" alt="">: A Fully Open Recipe for Generative Visual Perception</h1>
|
| 19 |
+
|
| 20 |
+
<p align="center">
|
| 21 |
+
<a href="https://openvisionbanana.github.io/"><img src="https://img.shields.io/badge/Project-Page-1f72b8.svg" alt="Project Page"></a>
|
| 22 |
+
<a href="https://github.com/OpenVisionBanana/OpenVisionBanana"><img src="https://img.shields.io/badge/GitHub-Code-181717.svg?logo=github" alt="Code"></a>
|
| 23 |
+
<a href="https://huggingface.co/black-forest-labs/FLUX.2-klein-base-9B"><img src="https://img.shields.io/badge/Base-FLUX.2%20%5Bklein%5D-8a2be2.svg" alt="Base model"></a>
|
| 24 |
+
</p>
|
| 25 |
+
|
| 26 |
+
<p align="center">
|
| 27 |
+
<img src="assets/ovb_collage.jpg" width="100%" alt="Zero-shot OVB outputs on an in-the-wild photo: semantic, instance and referring segmentation, depth, surface normals, image editing and text-to-image generation, with the prompt below each output">
|
| 28 |
+
</p>
|
| 29 |
+
|
| 30 |
+
Outputs of the zero-shot 9B model on an in-the-wild photo, with the prompt below each output.
|
| 31 |
+
|
| 32 |
## Quickstart
|
| 33 |
|
| 34 |
Install PyTorch with CUDA support first, then:
|
|
|
|
| 135 |
)
|
| 136 |
```
|
| 137 |
|
| 138 |
+
**Image editing**
|
| 139 |
+
|
| 140 |
+
```python
|
| 141 |
+
prompt = (
|
| 142 |
+
"[TASK: IMAGE_EDITING] Change the beach and ocean environment in the picture to a snowy mountain."
|
| 143 |
+
)
|
| 144 |
+
```
|
| 145 |
+
|
| 146 |
+
**Text-to-image generation**
|
| 147 |
+
|
| 148 |
+
Call the pipeline without `image` and give it a size:
|
| 149 |
+
|
| 150 |
+
```python
|
| 151 |
+
prompt = "an empty tram at a cobblestone stop on a rainy night"
|
| 152 |
+
output = pipe(
|
| 153 |
+
prompt=prompt,
|
| 154 |
+
height=1024,
|
| 155 |
+
width=1024,
|
| 156 |
+
guidance_scale=3.5,
|
| 157 |
+
num_inference_steps=28,
|
| 158 |
+
generator=torch.Generator(device=device).manual_seed(0),
|
| 159 |
+
).images[0]
|
| 160 |
+
```
|
| 161 |
+
|
| 162 |
These are quickstart prompts, one per task. The model was trained on many phrasings of each task, so you can adapt them:
|
| 163 |
|
| 164 |
- **Semantic segmentation:** list any classes with an RGB colour each. Distinct, saturated colours work best. Pixels outside the listed classes come out black.
|
| 165 |
- **Referring segmentation:** replace the description and the paint colour.
|
| 166 |
- **Instance segmentation:** prompt one class at a time; replace every `car` in the prompt with any noun phrase. The left-to-right color ordering helps maintain greater separation between assigned colors. The model may not follow it exactly, which is fine: each instance only needs its own distinct colour.
|
| 167 |
- **Depth and surface normals:** use the prompts as they are. Depth is relative inverse depth, with closer points brighter. Normals follow the encoding stated in the prompt.
|
| 168 |
+
- **Image editing:** keep the `[TASK: IMAGE_EDITING]` tag and write the edit as a plain instruction.
|
| 169 |
+
- **Generation:** a plain description without a tag and without an input image.
|
| 170 |
+
|
| 171 |
+
## Model layout
|
| 172 |
+
|
| 173 |
+
- `final_models/{4B,9B}/{zeroshot,nonzeroshot}/checkpoint-*/transformer`: fine-tuned transformers for both base sizes, loaded as in the quickstart with the matching base pipeline (`FLUX.2-klein-base-4B` or `-9B`).
|
| 174 |
+
- `ablation_models/`: one checkpoint per ablation setting from the paper.
|
| 175 |
+
|
| 176 |
+
## LoRA adapters
|
| 177 |
+
|
| 178 |
+
`ablation_models/f2kbase4b_lora_zeroshot_ablations/` contains the LoRA adapters of the paper's LoRA table, trained on FLUX.2 [klein] base 4B over the zero-shot data: ranks 64, 128 and 256 at 25K, 37.5K, 50K, 75K and 100K steps, and ranks 512 and 1024 at 37.5K steps. `manifest.md` lists every adapter. Each adapter loads into the unmodified 4B base pipeline:
|
| 179 |
+
|
| 180 |
+
```python
|
| 181 |
+
import torch
|
| 182 |
+
from diffusers import Flux2KleinPipeline
|
| 183 |
+
|
| 184 |
+
pipe = Flux2KleinPipeline.from_pretrained(
|
| 185 |
+
"black-forest-labs/FLUX.2-klein-base-4B", torch_dtype=torch.bfloat16
|
| 186 |
+
)
|
| 187 |
+
pipe.load_lora_weights(
|
| 188 |
+
"FunAILab/Open-Vision-Banana",
|
| 189 |
+
subfolder="ablation_models/f2kbase4b_lora_zeroshot_ablations/r64/checkpoint-75000",
|
| 190 |
+
weight_name="pytorch_lora_weights.safetensors",
|
| 191 |
+
)
|
| 192 |
+
```
|
| 193 |
+
|
| 194 |
+
Prompts and sampling settings are the same as above.
|
assets/ovb_collage.jpg
ADDED
|
Git LFS Details
|
assets/ovb_logo.png
ADDED
|