Run this model with HF Jobs
Run KennethTM/pix2struct-base-table2html on Hugging Face's managed compute, monitor its progress, and retrieve the results when it's done.
Paste one of these prompts into your coding agent:
Fine-tune on my dataset
Use HF Jobs to fine-tune https://huggingface.co/KennethTM/pix2struct-base-table2html. Ask me which dataset to train on, then push the fine-tuned model to a new model repo. Run `hf jobs --help` first to learn the CLI.
Run batch inference
Use HF Jobs to run batch inference with https://huggingface.co/KennethTM/pix2struct-base-table2html on the inputs in a mounted HF Bucket. Ask me which Bucket to use, then write the outputs back to it and keep each input ID. Run `hf jobs --help` first to learn the CLI.
Instructions to use KennethTM/pix2struct-base-table2html with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use KennethTM/pix2struct-base-table2html with Transformers:
# Use a pipeline as a high-level helper # Warning: Pipeline type "image-to-text" is no longer supported in transformers v5. # You must load the model directly (see below) or downgrade to v4.x with: # pip install "transformers<5.0.0" from transformers import pipeline pipe = pipeline("image-to-text", model="KennethTM/pix2struct-base-table2html")# pip install -U transformers accelerate # Load model directly from transformers import AutoProcessor, AutoModelForMultimodalLM processor = AutoProcessor.from_pretrained("KennethTM/pix2struct-base-table2html") model = AutoModelForMultimodalLM.from_pretrained("KennethTM/pix2struct-base-table2html", device_map="auto") - Notebooks
- Google Colab
- Kaggle
Update README.md
Browse files123345678910116121381415161718191220211422231624251826272021222324252628292830313233343536303738394041424332333444454647484936505152535455563857584059606162426344644665486650676852535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819969---library_name: transformerstags: []license: mitdatasets:- SpursgoZmy/MMTab- apoidea/pubtabnet-htmllanguage:- enbase_model: google/pix2struct-base---
# Model Card for Model ID# pix2struct-base-table2html
<!-- Provide a quick summary of what the model is/does. -->*Turn table images into HTML!*
## About
This model takes an image of a table and outputs HTML - the model parses both the optical character recognition (OCR) and the structure to HTML format.
## Model DetailsThe model expects an image containing only a table. If the table is embedded in a document, first use a table detection model to extract it.
### Model DescriptionThe model is finetuned from [Pix2Struct base model](https://huggingface.co/google/pix2struct-base) using a max_patch_length of 1024 and max generation length of 1024. The max_patch_length should likely not be changed for inference but the generation length can be changed.
<!-- Provide a longer summary of what this model is. -->The model has been trained using two datasets: [MMTab](https://huggingface.co/datasets/SpursgoZmy/MMTab) and [PubTabNet](https://huggingface.co/datasets/apoidea/pubtabnet-html).
This is the model card of a 🤗 transformers model that has been pushed on the Hub. This model card has been automatically generated.## Usage
- **Developed by:** [More Information Needed]- **Funded by [optional]:** [More Information Needed]- **Shared by [optional]:** [More Information Needed]- **Model type:** [More Information Needed]- **Language(s) (NLP):** [More Information Needed]- **License:** [More Information Needed]- **Finetuned from model [optional]:** [More Information Needed]Below is a complete example for loading the model and performing inference on an example table image:
### Model Sources [optional]```pythonimport torchfrom transformers import AutoProcessor, Pix2StructForConditionalGenerationfrom PIL import Imageimport requestsfrom io import BytesIO
<!-- Provide the basic links for the model. --># Load model and processordevice = "cuda" if torch.cuda.is_available() else "cpu"processor = AutoProcessor.from_pretrained("pix2struct-base-table2html")model = Pix2StructForConditionalGeneration.from_pretrained("pix2struct-base-table2html")model.to(device)model.eval()
- **Repository:** [More Information Needed]- **Paper [optional]:** [More Information Needed]- **Demo [optional]:** [More Information Needed]# Load example image from URL# Example from the MMTab dataseturl = "https://example.com/path_to_table_image.jpg"response = requests.get(url)image = Image.open(BytesIO(response.content))
## Uses# Run model inferenceencoding = processor(image, return_tensors="pt", max_patches=1024)with torch.inference_mode(): flattened_patches = encoding.pop("flattened_patches").to(device) attention_mask = encoding.pop("attention_mask").to(device) predictions = model.generate(flattened_patches=flattened_patches, attention_mask=attention_mask, max_new_tokens=1024)
<!-- Address questions around how the model is intended to be used, including the foreseeable users of the model and those affected by the model. -->predictions_decoded = processor.tokenizer.batch_decode(predictions, skip_special_tokens=True)
### Direct Use# Show predictions as textprint(predictions_decoded[0])```
<!-- This section is for the model use without fine-tuning or plugging into a larger ecosystem/app. -->
[More Information Needed]
### Downstream Use [optional]
<!-- This section is for the model use when fine-tuned for a task, or when plugged into a larger ecosystem/app -->
[More Information Needed]## Demo app
### Out-of-Scope Use
<!-- This section addresses misuse, malicious use, and uses that the model will not work well for. -->
[More Information Needed]
## Bias, Risks, and Limitations
<!-- This section is meant to convey both technical and sociotechnical limitations. -->
[More Information Needed]
### Recommendations
<!-- This section is meant to convey recommendations with respect to the bias, risk, and technical limitations. -->
Users (both direct and downstream) should be made aware of the risks, biases and limitations of the model. More information needed for further recommendations.
## How to Get Started with the Model
Use the code below to get started with the model.
[More Information Needed]
## Training Details
### Training Data
<!-- This should link to a Dataset Card, perhaps with a short stub of information on what the training data is all about as well as documentation related to data pre-processing or additional filtering. -->
[More Information Needed]
### Training Procedure
<!-- This relates heavily to the Technical Specifications. Content here should link to that section when it is relevant to the training procedure. -->
#### Preprocessing [optional]
[More Information Needed]
#### Training Hyperparameters
- **Training regime:** [More Information Needed] <!--fp32, fp16 mixed precision, bf16 mixed precision, bf16 non-mixed precision, fp16 non-mixed precision, fp8 mixed precision -->
#### Speeds, Sizes, Times [optional]
<!-- This section provides information about throughput, start/end time, checkpoint size if relevant, etc. -->
[More Information Needed]
## Evaluation
<!-- This section describes the evaluation protocols and provides the results. -->
### Testing Data, Factors & Metrics
#### Testing Data
<!-- This should link to a Dataset Card if possible. -->
[More Information Needed]
#### Factors
<!-- These are the things the evaluation is disaggregating by, e.g., subpopulations or domains. -->
[More Information Needed]
#### Metrics
<!-- These are the evaluation metrics being used, ideally with a description of why. -->
[More Information Needed]
### Results
[More Information Needed]
#### Summary
## Model Examination [optional]
<!-- Relevant interpretability work for the model goes here -->
[More Information Needed]
## Environmental Impact
<!-- Total emissions (in grams of CO2eq) and additional considerations, such as electricity usage, go here. Edit the suggested text below accordingly -->
Carbon emissions can be estimated using the [Machine Learning Impact calculator](https://mlco2.github.io/impact#compute) presented in [Lacoste et al. (2019)](https://arxiv.org/abs/1910.09700).
- **Hardware Type:** [More Information Needed]- **Hours used:** [More Information Needed]- **Cloud Provider:** [More Information Needed]- **Compute Region:** [More Information Needed]- **Carbon Emitted:** [More Information Needed]
## Technical Specifications [optional]
### Model Architecture and Objective
[More Information Needed]
### Compute Infrastructure
[More Information Needed]
#### Hardware
[More Information Needed]
#### Software
[More Information Needed]
## Citation [optional]
<!-- If there is a paper or blog post introducing the model, the APA and Bibtex information for that should go in this section. -->
**BibTeX:**
[More Information Needed]
**APA:**
[More Information Needed]
## Glossary [optional]
<!-- If relevant, include terms and calculations in this section that can help readers understand the model or model card. -->
[More Information Needed]
## More Information [optional]
[More Information Needed]
## Model Card Authors [optional]
[More Information Needed]
## Model Card Contact
[More Information Needed]Try the [demo app]() which contain both table detection and recognition!README.md+45-175