Falconsai/florence-2-invoice
is a fine-tuned version of the
microsoft/Florence-2-base-ft
model. This model has been specifically trained to identify and extract key fields from invoice images. The fine-tuning process utilized a curated dataset of invoices annotated to recognize the following fields:
Billing address, - Discount percentage, - Due date
Email client, - Header, - Invoice date
Invoice number, - Name client, - Products
Remise, - Shipping address, - Subtotal
Tax, - Tax percentage, - Tel client, - Total
Base Model
The base model used for fine-tuning is
microsoft/Florence-2-base-ft
, a state-of-the-art vision model developed by Microsoft.
Fine-tuning Configuration
The fine-tuning process was carried out using a Low-Rank Adaptation (LoRa) configuration with the following parameters:
The fine-tuning process was conducted on an Alienware system, ensuring robust performance and efficient training.
Dataset
The model was trained on a curated dataset of invoice images. Each invoice was annotated to identify the specific fields listed above. This dataset ensured that the model learned to accurately detect and extract key information from various invoice formats.
Usage
Inference
To use this model for inference, you can load it via the Hugging Face Transformers library:
import torch
from PIL import Image
from transformers import (
AdamW,
AutoModelForCausalLM,
AutoProcessor,
get_scheduler
)
defrun_florence_invoice(img, task_prompt, text_input=None):
image = Image.open(img)
# Ensure the image is in RGB formatif image.mode != "RGB":
image = image.convert("RGB")
model_id2 = "Falconsai/florence-2-invoice"
model = AutoModelForCausalLM.from_pretrained(model_id2, trust_remote_code=True).eval().cuda()
processor = AutoProcessor.from_pretrained(model_id2, trust_remote_code=True)
with torch.no_grad():
if text_input isNone:
prompt = task_prompt
else:
prompt = task_prompt + text_input
inputs = processor(text=prompt, images=image, return_tensors="pt")
generated_ids = model.generate(
input_ids=inputs["input_ids"].cuda(),
pixel_values=inputs["pixel_values"].cuda(),
max_new_tokens=1024,
num_beams=3
)
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))
del model
del processor
return parsed_answer
## Call the function as follows:### Return all fields identified:
img = './invoice.png'
run_florence_invoice(img, '<OD>')
### Return Specific field
img = './invoice.png'
results = run_florence_invoice(img, "<CAPTION_TO_PHRASE_GROUNDING>", text_input="invoice date")
Applications
This model is ideal for automating the extraction of key information from invoices in various business and financial applications. It can significantly reduce the manual effort required for data entry and validation in accounting and bookkeeping processes.
Evaluation
The model has been evaluated on a held-out set of annotated invoice images. The evaluation metrics used included precision, recall, and F1-score for each of the identified fields. Detailed evaluation results and visualizations are available in the
results
directory of the repository.
Limitations
The model's performance is dependent on the quality and variability of the training dataset. It may not perform as well on invoices that significantly differ from those seen during training.
Fine-tuning was conducted with specific LoRa configurations, which may need to be adjusted for different use cases or datasets.
Contact
For more information or questions about this model, please contact the developers at [
[email protected]
].
License
This model is licensed under the MIT License. See the
LICENSE
file for more details.
Acknowledgments
We would like to thank Microsoft for the development of the Florence2 vision model and the broader machine learning community for their contributions and support.
Runs of Falconsai florence-2-invoice on huggingface.co
11
Total runs
0
24-hour runs
0
3-day runs
-1
7-day runs
-6
30-day runs
More Information About florence-2-invoice huggingface.co Model
florence-2-invoice huggingface.co
florence-2-invoice huggingface.co is an AI model on huggingface.co that provides florence-2-invoice's model effect (), which can be used instantly with this Falconsai florence-2-invoice model. huggingface.co supports a free trial of the florence-2-invoice model, and also provides paid use of the florence-2-invoice. Support call florence-2-invoice model through api, including Node.js, Python, http.
florence-2-invoice huggingface.co is an online trial and call api platform, which integrates florence-2-invoice's modeling effects, including api services, and provides a free online trial of florence-2-invoice, you can try florence-2-invoice online for free by clicking the link below.
Falconsai florence-2-invoice online free url in huggingface.co:
florence-2-invoice is an open source model from GitHub that offers a free installation service, and any user can find florence-2-invoice on GitHub to install. At the same time, huggingface.co provides the effect of florence-2-invoice install, users can directly use florence-2-invoice installed effect in huggingface.co for debugging and trial. It also supports api for free installation.