--- license: mit datasets: - remyxai/vqasynth_spacellava tags: - remyx - multitask base_model: - microsoft/Florence-2-base-ft --- [![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/drive/1or4muggFnUnZJ50tkCYCla7b9no9HogN?usp=sharing) ![image/png](https://cdn-uploads.huggingface.co/production/uploads/647777304ae93470ffc28913/eGBP2Selg2xAruycvTVI1.png) # Model Card for SpaceFlorence-2 **SpaceFlorence-2** does a full finetune of the BERT component of [Florence-2](https://github.com/haotian-liu/LLaVA/tree/main) with a [dataset](https://huggingface.co/datasets/remyxai/vqasynth_spacellava) designed with [VQASynth](https://github.com/remyxai/VQASynth/tree/main) to enhance spatial reasoning as in [SpatialVLM](https://spatial-vlm.github.io/) ## Model Details - **Developed by:** remyx.ai - **Model type:** MultiModal Model, Vision Language Model, Florence-2 - **Finetuned from model:** Florence-2 ### Model Sources - **Dataset:** [SpaceLLaVA](https://huggingface.co/datasets/remyxai/vqasynth_spacellava) - **Repository:** [VQASynth](https://github.com/remyxai/VQASynth/tree/main) - **Paper:** [SpatialVLM](https://arxiv.org/abs/2401.12168) # Running SpaceFlorence-2 ```python 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 = " 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="", 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} } ```