Image Classification
Transformers
Safetensors
English
siglip
Formula-Text-Detection
SigLIP2
Image-Classification
Instructions to use prithivMLmods/Formula-Text-Detection with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use prithivMLmods/Formula-Text-Detection with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("image-classification", model="prithivMLmods/Formula-Text-Detection") pipe("https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/hub/parrots.png")# pip install -U transformers accelerate # Load model directly from transformers import AutoProcessor, AutoModelForImageClassification processor = AutoProcessor.from_pretrained("prithivMLmods/Formula-Text-Detection") model = AutoModelForImageClassification.from_pretrained("prithivMLmods/Formula-Text-Detection", device_map="auto") - Notebooks
- Google Colab
- Kaggle
Update README.md
Browse files1 unmodified line234567897 unmodified lines1718191 unmodified linelicense: apache-2.0datasets:- AadityaJain/Fromula_text_classification---```pyClassification Report:precision recall f1-score support7 unmodified lines```1 unmodified line234567891011121314151617181920212223247 unmodified lines32333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131 unmodified linelicense: apache-2.0datasets:- AadityaJain/Fromula_text_classificationlanguage:- enbase_model:- google/siglip2-base-patch16-224pipeline_tag: image-classificationlibrary_name: transformerstags:- Formula-Text-Detection- SigLIP2---# **Formula-Text-Detection**> **Formula-Text-Detection** is a vision-language encoder model fine-tuned from **google/siglip2-base-patch16-224** for **binary image classification**. It is built using the **SiglipForImageClassification** architecture to distinguish between **mathematical formulas** and **natural text** in document or image regions.```pyClassification Report:precision recall f1-score support7 unmodified lines```---## **Label Space: 2 Classes**The model classifies each input image into one of the following categories:```Class 0: "formula"Class 1: "text"```---## **Install Dependencies**```bashpip install -q transformers torch pillow gradio```---## **Inference Code**```pythonimport gradio as grfrom transformers import AutoImageProcessor, SiglipForImageClassificationfrom PIL import Imageimport torch# Load model and processormodel_name = "prithivMLmods/Formula-Text-Detection" # Replace with your model path if differentmodel = SiglipForImageClassification.from_pretrained(model_name)processor = AutoImageProcessor.from_pretrained(model_name)# Label mappingid2label = {"0": "formula","1": "text"}def classify_formula_or_text(image):image = Image.fromarray(image).convert("RGB")inputs = processor(images=image, return_tensors="pt")with torch.no_grad():outputs = model(**inputs)logits = outputs.logitsprobs = torch.nn.functional.softmax(logits, dim=1).squeeze().tolist()prediction = {id2label[str(i)]: round(probs[i], 3) for i in range(len(probs))}return prediction# Gradio Interfaceiface = gr.Interface(fn=classify_formula_or_text,inputs=gr.Image(type="numpy"),outputs=gr.Label(num_top_classes=2, label="Formula or Text"),title="Formula-Text-Detection",description="Upload an image region to classify whether it contains a mathematical formula or natural text.")if __name__ == "__main__":iface.launch()```---## **Intended Use****Formula-Text-Detection** can be used in:- **OCR Preprocessing** – Improve document OCR accuracy by separating formulas from text.- **Scientific Document Analysis** – Automatically detect mathematical content.- **Educational Platforms** – Classify and annotate scanned materials.- **Layout Understanding** – Help AI systems interpret mixed-content documents.
README.md+94