This model uses data synthesis techniques and publically available models to reproduce the work described in SpatialVLM to enhance the spatial reasoning of multimodal models.
With a pipeline of expert models, we can infer spatial relationships between objects in a scene to create VQA dataset for spatial reasoning.
Developed by: remyx.ai
Model type: MultiModal Model, Vision Language Model, Llama 3
Quick Start
To run SpaceMantis, follow these steps:
python
1import torch
2from PIL import Image
3from models.mllava import MLlavaProcessor, LlavaForConditionalGeneration, chat_mllava
45# Load the model and processor6attn_implementation =None# or "flash_attention_2"7processor = MLlavaProcessor.from_pretrained("remyxai/SpaceMantis")8model = LlavaForConditionalGeneration.from_pretrained("remyxai/SpaceMantis", device_map="cuda", torch_dtype=torch.float16, attn_implementation=attn_implementation)910generation_kwargs ={11"max_new_tokens":1024,12"num_beams":1,13"do_sample":False14}1516# Function to run inference17defrun_inference(image_path, content):18# Load the image19 image = Image.open(image_path).convert("RGB")20# Convert the image to base6421 images =[image]22# Run the inference23 response, history = chat_mllava(content, images, model, processor,**generation_kwargs)24return response
2526# Example usage27image_path ="path/to/your/image.jpg"28content ="Your question here."29response = run_inference(image_path, content)30print("Response:", response)
@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{jiang2024mantis,
title={MANTIS: Interleaved Multi-Image Instruction Tuning},
author={Jiang, Dongfu and He, Xuan and Zeng, Huaye and Wei, Con and Ku, Max and Liu, Qian and Chen, Wenhu},
journal={arXiv preprint arXiv:2405.01483},
year={2024}
}