---
title: Florence-2-Flux-Large
canonical_url: "https://www.modelscope.cn/models/cutemodel/Florence-2-Flux-Large"
md_url: "https://www.modelscope.cn/models/cutemodel/Florence-2-Flux-Large.md"
repository: cutemodel/Florence-2-Flux-Large
last_updated: 2024-12-17
license: apache-2.0
pipeline_tag: image-text-to-text
tasks:
  - image-text-to-text
model_type:
  - florence2
architectures:
  - Florence2ForConditionalGeneration
base_model:
  - microsoft/Florence-2-large
base_model_relation: finetune
parameters: 822.9M
tensor_type:
  - F32
library_name:
  - pytorch
  - transformer
  - safetensors
frameworks:
  - Pytorch
language:
  - en
inference_backends:
  - "deploy_task vlm/text/emb"
  - "vllm 0.9.2"
downloads: 742
stars: 2
tags:
  - art
---

# Florence-2-Flux-Large

> Florence-2-Flux-Large - cutemodel 在 ModelScope 开源的模型。

cutemodel/Florence-2-Flux-Large 是 ModelScope 魔搭社区上的 822.9M 参数image-text-to-text模型，采用 apache-2.0 许可，基于 microsoft/Florence-2-large 构建，可用 deploy_task vlm/text/emb、vllm 0.9.2 部署。

- **Repository**: cutemodel/Florence-2-Flux-Large
- **License**: apache-2.0
- **Tasks**: image-text-to-text
- **Parameters**: 822.9M
- **Base model**: microsoft/Florence-2-large
- **Inference backends**: deploy_task vlm/text/emb, vllm 0.9.2
- **Tags**: art
- **Downloads**: 742
- **Stars**: 2
- **Last updated**: 2024-12-17

Source: https://www.modelscope.cn/models/cutemodel/Florence-2-Flux-Large

---

```
pip install -q datasets flash_attn timm einops
```

```python

from transformers import AutoModelForCausalLM, AutoProcessor, AutoConfig
import torch

device = torch.device("cuda" if torch.cuda.is_available() else "cpu")

model = AutoModelForCausalLM.from_pretrained("gokaygokay/Florence-2-Flux-Large", trust_remote_code=True).to(device).eval()
processor = AutoProcessor.from_pretrained("gokaygokay/Florence-2-Flux-Large", trust_remote_code=True)

# Function to run the model on an example
def run_example(task_prompt, text_input, image):
    prompt = task_prompt + text_input

    # Ensure the image is in RGB mode
    if image.mode != "RGB":
        image = image.convert("RGB")

    inputs = processor(text=prompt, images=image, return_tensors="pt").to(device)
    generated_ids = model.generate(
        input_ids=inputs["input_ids"],
        pixel_values=inputs["pixel_values"],
        max_new_tokens=1024,
        num_beams=3,
        repetition_penalty=1.10,
    )
    generated_text = processor.batch_decode(generated_ids, skip_special_tokens=False)[0]
    parsed_answer = processor.post_process_generation(generated_text, task=task_prompt, image_size=(image.width, image.height))
    return parsed_answer

from PIL import Image
import requests
import copy

url = "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/transformers/tasks/car.jpg?download=true"
image = Image.open(requests.get(url, stream=True).raw)
answer = run_example("<DESCRIPTION>", "Describe this image in great detail.", image)

final_answer = answer["<DESCRIPTION>"]
print(final_answer)
   
```
