--- library_name: transformers tags: - art - background license: mit language: - en base_model: - microsoft/Florence-2-base-ft pipeline_tag: image-to-text --- ## Uses GPT4-O Style captioner, finetuned version using florence-2-base-ft ### Direct Use This model can be used to create gpt4-o styple captions. ### Out-of-Scope Use - This model might not generate long-text descriptions as the context length is 1024. - Linear scaling is applied to increase the context length, its effect was not measured! ## How to Get Started with the Model ```sh # Load fine-tuned model and processor import torch from transformers import AutoModelForCausalLM, AutoProcessor from PIL import Image device = torch.device("cuda" if torch.cuda.is_available() else "cpu") repo_name = "Vimax97/Florence-2-base-gpt4_captioner_v1" model = AutoModelForCausalLM.from_pretrained(repo_name, trust_remote_code=True).to(device) processor = AutoProcessor.from_pretrained(repo_name, trust_remote_code=True) # Inference image = Image.open("") prompt = "" + 'What is the style description for this image?' 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, do_sample=False, num_beams=3 ) generated_text = processor.batch_decode(generated_ids, skip_special_tokens=False)[0] parsed_answer = processor.post_process_generation(generated_text, task=prompt, image_size=(image.width, image.height)) print("Generated: ",parsed_answer[prompt]) ``` #### Training Hyperparameters - **Training regime:** fp32 precision, 1000 images were used, 1 epoch of finetuning #### Summary