Run this model with HF Jobs
Run StonyBrook-CVLab/PixCell-256-Cell-ControlNet on Hugging Face's managed compute, monitor its progress, and retrieve the results when it's done.
Paste one of these prompts into your coding agent:
Fine-tune on my dataset
Use HF Jobs to fine-tune https://huggingface.co/StonyBrook-CVLab/PixCell-256-Cell-ControlNet. Ask me which dataset to train on, then push the fine-tuned model to a new model repo. Run `hf jobs --help` first to learn the CLI.
Run batch inference
Use HF Jobs to run batch inference with https://huggingface.co/StonyBrook-CVLab/PixCell-256-Cell-ControlNet on the inputs in a mounted HF Bucket. Ask me which Bucket to use, then write the outputs back to it and keep each input ID. Run `hf jobs --help` first to learn the CLI.
Instructions to use StonyBrook-CVLab/PixCell-256-Cell-ControlNet with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Diffusers
How to use StonyBrook-CVLab/PixCell-256-Cell-ControlNet with Diffusers:
pip install -U diffusers transformers accelerate
import torch from diffusers import DiffusionPipeline # switch to "mps" for apple devices pipe = DiffusionPipeline.from_pretrained("StonyBrook-CVLab/PixCell-256-Cell-ControlNet", dtype=torch.bfloat16, device_map="cuda") prompt = "Astronaut in a jungle, cold color palette, muted colors, detailed, 8k" image = pipe(prompt).images[0] - Notebooks
- Google Colab
- Kaggle
Create README.md
Browse files12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182---license: apache-2.0---
### Load PixCell-256-Cell-ControlNet model
```pythonimport torch
from diffusers import DiffusionPipelinefrom diffusers import AutoencoderKL
device = torch.device('cuda')
# We do not host the weights of the SD3 VAE -- load it from StabilityAIsd3_vae = AutoencoderKL.from_pretrained("stabilityai/stable-diffusion-3.5-large", subfolder="vae")
pipeline = DiffusionPipeline.from_pretrained( "StonyBrook-CVLab/PixCell-256-Cell-ControlNet", vae=sd3_vae, custom_pipeline="StonyBrook-CVLab/PixCell-pipeline-ControlNet", trust_remote_code=True,)
pipeline.to(device);```
### Load [[UNI-2h]](https://huggingface.co/MahmoodLab/UNI2-h) for conditioning```pythonimport timmfrom timm.data import resolve_data_configfrom timm.data.transforms_factory import create_transform
timm_kwargs = { 'img_size': 224, 'patch_size': 14, 'depth': 24, 'num_heads': 24, 'init_values': 1e-5, 'embed_dim': 1536, 'mlp_ratio': 2.66667*2, 'num_classes': 0, 'no_embed_class': True, 'mlp_layer': timm.layers.SwiGLUPacked, 'act_layer': torch.nn.SiLU, 'reg_tokens': 8, 'dynamic_img_size': True }uni_model = timm.create_model("hf-hub:MahmoodLab/UNI2-h", pretrained=True, **timm_kwargs)transform = create_transform(**resolve_data_config(uni_model.pretrained_cfg, model=uni_model))uni_model.eval()uni_model.to(device);```
### Mask-conditioned generation```python# Load imageimport numpy as npfrom PIL import Imagefrom huggingface_hub import hf_hub_download
# This is an example image/mask pair we provideimage_path = hf_hub_download(repo_id="StonyBrook-CVLab/PixCell-256-Cell-ControlNet", filename="test_image.png")mask_path = hf_hub_download(repo_id="StonyBrook-CVLab/PixCell-256-Cell-ControlNet", filename="test_mask.png")image = Image.open(image_path).convert("RGB")mask = np.asarray(Image.open(mask_path).convert("RGB"))
# Extract UNI embedding from the imageuni_inp = uni_transforms(image).unsqueeze(dim=0)with torch.inference_mode(): uni_emb = uni_model(uni_inp.to(device))
# reshape UNI to (bs, 1, D)uni_emb = uni_emb.unsqueeze(1)print("Extracted UNI:", uni_emb.shape)
# Get unconditional embedding for classifier-free guidanceuncond = pipeline_controlnet.get_unconditional_embedding(uni_emb.shape[0])# Generate new samples using the given masksamples = pipeline_controlnet(uni_embeds=uni_emb, controlnet_input=mask, negative_uni_embeds=uncond, guidance_scale=2.5, num_images_per_prompt=1).images```README.mdAdded+82