Safetensors
florence2
remyx
multitask
custom_code
Edit model card

Open In Colab

image/png

Model Card for SpaceFlorence-2

SpaceFlorence-2 does a full finetune of the BERT component of Florence-2 with a dataset designed with VQASynth to enhance spatial reasoning as in SpatialVLM

Model Details

  • Developed by: remyx.ai
  • Model type: MultiModal Model, Vision Language Model, Florence-2
  • Finetuned from model: Florence-2

Model Sources

Running SpaceFlorence-2

import requests

import torch
from PIL import Image
from transformers import AutoProcessor, AutoModelForCausalLM 


device = "cuda:0" if torch.cuda.is_available() else "cpu"
torch_dtype = torch.float16 if torch.cuda.is_available() else torch.float32

model = AutoModelForCausalLM.from_pretrained("remyxai/SpaceFlorence-2", trust_remote_code=True).to(device)
processor = AutoProcessor.from_pretrained("remyxai/SpaceFlorence-2", trust_remote_code=True)

prompt = "<SpatialVQA> How far between the person and the pallet of boxes?"

url = "https://remyx.ai/assets/spatialvlm/warehouse_rgb.jpg?download=true"
image = Image.open(requests.get(url, stream=True).raw)

inputs = processor(text=prompt, images=image, return_tensors="pt").to(device, torch_dtype)

generated_ids = model.generate(
    input_ids=inputs["input_ids"],
    pixel_values=inputs["pixel_values"],
    max_new_tokens=1024,
    num_beams=3,
    do_sample=False
)
generated_text = processor.batch_decode(generated_ids, skip_special_tokens=False)[0]

parsed_answer = processor.post_process_generation(generated_text, task="<SpatialVQA>", image_size=(image.width, image.height))

print(parsed_answer)

Citation

@article{chen2024spatialvlm,
  title = {SpatialVLM: Endowing Vision-Language Models with Spatial Reasoning Capabilities},
  author = {Chen, Boyuan and Xu, Zhuo and Kirmani, Sean and Ichter, Brian and Driess, Danny and Florence, Pete and Sadigh, Dorsa and Guibas, Leonidas and Xia, Fei},
  journal = {arXiv preprint arXiv:2401.12168},
  year = {2024},
  url = {https://arxiv.org/abs/2401.12168},
}

@article{xiao2023florence,
  title={Florence-2: Advancing a unified representation for a variety of vision tasks},
  author={Xiao, Bin and Wu, Haiping and Xu, Weijian and Dai, Xiyang and Hu, Houdong and Lu, Yumao and Zeng, Michael and Liu, Ce and Yuan, Lu},
  journal={arXiv preprint arXiv:2311.06242},
  year={2023}
}
Downloads last month
56
Safetensors
Model size
271M params
Tensor type
F32
·
Inference API
Unable to determine this model's library. Check the docs .

Model tree for remyxai/SpaceFlorence-2

Finetuned
(6)
this model

Dataset used to train remyxai/SpaceFlorence-2

Collections including remyxai/SpaceFlorence-2