Comments (2)
Here is how you can do it:
- Write a dataset class, which reads an image address and the labels associated with it (like for sequence labeling, in which we need to predict what is the class for each text, we would have a label of (seq_len, 1), since each would have a single class)
- Now, extract the features using the
create_features
function - And from the dataset object, return the 5 parameters (1. resized_scaled_img, 2.x_features, 3.y_featuers, 4. input_ids, 5l. labels)
- Use a collate function in PyTorch for handling multiple inputs from a single dataset and then pass it as follows:
- Use ResNetFeatureExtractor, to get the image feature of the resized_scaled)img
- Use DocFormerEmbedding, to get the extracted features of x_features, y_features
- Use LanguageFeatureExtractor, to get the features of the tokenized words
- Having obtained these things, pass it through the DocFormerEncoder
- And then, attach a linear layer according to your task requirement
- Take the loss and backward propagate it
Hope this helps
We would shortly include these things in a smaller boilerplate, so that code becomes more clear and more concise, but I hope this helps.
from docformer.
Here is how you can do it:
- Write a dataset class, which reads an image address and the labels associated with it (like for sequence labeling, in which we need to predict what is the class for each text, we would have a label of (seq_len, 1), since each would have a single class)
- Now, extract the features using the
create_features
function- And from the dataset object, return the 5 parameters (1. resized_scaled_img, 2.x_features, 3.y_featuers, 4. input_ids, 5l. labels)
- Use a collate function in PyTorch for handling multiple inputs from a single dataset and then pass it as follows:
- Use ResNetFeatureExtractor, to get the image feature of the resized_scaled)img
- Use DocFormerEmbedding, to get the extracted features of x_features, y_features
- Use LanguageFeatureExtractor, to get the features of the tokenized words
- Having obtained these things, pass it through the DocFormerEncoder
- And then, attach a linear layer according to your task requirement
- Take the loss and backward propagate it
Hope this helps
We would shortly include these things in a smaller boilerplate, so that code becomes more clear and more concise, but I hope this helps.
@uakarsh Thanks for detailed step by step explanation, i'll have a go at it.
from docformer.
Related Issues (20)
- Weird output HOT 7
- Reference code of pre-training tasks HOT 4
- [Errno 2] No such file or directory: 'rvl_cdip_dataset.csv'
- NER task HOT 4
- Predictions are wrong. HOT 1
- can you provide visual question answering task code HOT 1
- Unable to convert model to onnx HOT 3
- DocFormer for Token Classification. HOT 3
- Shape mismatch during sanity check HOT 1
- finetune the Docformer HOT 8
- Pre-trained models HOT 5
- Error in Example: Please provide the bounding box and words or pass the argument "use_ocr" = True HOT 1
- DocFormer for key-value pairs extraction HOT 1
- Using pre-trained models HOT 17
- Inference for token classification. HOT 1
- We can not find DocFormer_For_IR in modeling.py and modeling_l.py HOT 1
- Permission Denied Pretraining Weights HOT 2
- NotImplementedError: Support for `validation_epoch_end` has been removed in v2.0.0. `DocFormer` implements this method HOT 2
- pre-training code tutorial HOT 3
- The pre-trained weight link is invalid HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from docformer.