aniketmaurya commited on
Commit
9a1ecfd
·
verified ·
1 Parent(s): b811a42

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +34 -134
README.md CHANGED
@@ -20,31 +20,16 @@ pipeline_tag: visual-question-answering
20
 
21
  This is the model card of a 🤗 transformers model that has been pushed on the Hub. This model card has been automatically generated.
22
 
23
- - **Developed by:** [More Information Needed]
24
- - **Funded by [optional]:** [More Information Needed]
25
- - **Shared by [optional]:** [More Information Needed]
26
- - **Model type:** [More Information Needed]
27
- - **Language(s) (NLP):** [More Information Needed]
28
- - **License:** [More Information Needed]
29
- - **Finetuned from model [optional]:** [More Information Needed]
30
 
31
- ### Model Sources [optional]
32
-
33
- <!-- Provide the basic links for the model. -->
34
-
35
- - **Repository:** [More Information Needed]
36
- - **Paper [optional]:** [More Information Needed]
37
- - **Demo [optional]:** [More Information Needed]
38
 
39
  ## Uses
40
 
41
- <!-- Address questions around how the model is intended to be used, including the foreseeable users of the model and those affected by the model. -->
42
-
43
- ### Recommendations
44
-
45
- <!-- This section is meant to convey recommendations with respect to the bias, risk, and technical limitations. -->
46
 
47
- Users (both direct and downstream) should be made aware of the risks, biases and limitations of the model. More information needed for further recommendations.
48
 
49
  ## How to Get Started with the Model
50
 
@@ -60,10 +45,10 @@ from transformers import AutoProcessor, AutoModelForCausalLM
60
  device = "cuda:0" if torch.cuda.is_available() else "cpu"
61
  torch_dtype = torch.float16 if torch.cuda.is_available() else torch.float32
62
 
63
- model = AutoModelForCausalLM.from_pretrained("microsoft/Florence-2-base-ft", torch_dtype=torch_dtype, trust_remote_code=True).to(device)
64
  processor = AutoProcessor.from_pretrained("microsoft/Florence-2-base-ft", trust_remote_code=True)
65
 
66
- prompt = "<OD>"
67
 
68
  url = "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/transformers/tasks/car.jpg?download=true"
69
  image = Image.open(requests.get(url, stream=True).raw)
@@ -73,15 +58,13 @@ inputs = processor(text=prompt, images=image, return_tensors="pt").to(device, to
73
  generated_ids = model.generate(
74
  input_ids=inputs["input_ids"],
75
  pixel_values=inputs["pixel_values"],
76
- max_new_tokens=1024,
77
  do_sample=False,
78
  num_beams=3
79
  )
80
  generated_text = processor.batch_decode(generated_ids, skip_special_tokens=False)[0]
81
 
82
- parsed_answer = processor.post_process_generation(generated_text, task="<OD>", image_size=(image.width, image.height))
83
-
84
- print(parsed_answer)
85
  ```
86
 
87
 
@@ -89,123 +72,40 @@ print(parsed_answer)
89
 
90
  ### Training Data
91
 
92
- <!-- 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. -->
93
 
94
- [More Information Needed]
95
 
96
  ### Training Procedure
97
 
98
- <!-- This relates heavily to the Technical Specifications. Content here should link to that section when it is relevant to the training procedure. -->
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
99
 
100
  #### Preprocessing [optional]
101
 
102
- [More Information Needed]
103
-
104
 
105
- #### Training Hyperparameters
106
 
107
- - **Training regime:** [More Information Needed] <!--fp32, fp16 mixed precision, bf16 mixed precision, bf16 non-mixed precision, fp16 non-mixed precision, fp8 mixed precision -->
108
-
109
- #### Speeds, Sizes, Times [optional]
110
-
111
- <!-- This section provides information about throughput, start/end time, checkpoint size if relevant, etc. -->
112
-
113
- [More Information Needed]
114
 
115
  ## Evaluation
116
 
117
- <!-- This section describes the evaluation protocols and provides the results. -->
118
-
119
- ### Testing Data, Factors & Metrics
120
-
121
- #### Testing Data
122
-
123
- <!-- This should link to a Dataset Card if possible. -->
124
-
125
- [More Information Needed]
126
-
127
- #### Factors
128
-
129
- <!-- These are the things the evaluation is disaggregating by, e.g., subpopulations or domains. -->
130
-
131
- [More Information Needed]
132
-
133
- #### Metrics
134
-
135
- <!-- These are the evaluation metrics being used, ideally with a description of why. -->
136
-
137
- [More Information Needed]
138
-
139
- ### Results
140
-
141
- [More Information Needed]
142
-
143
- #### Summary
144
-
145
-
146
-
147
- ## Model Examination [optional]
148
-
149
- <!-- Relevant interpretability work for the model goes here -->
150
-
151
- [More Information Needed]
152
-
153
- ## Environmental Impact
154
-
155
- <!-- Total emissions (in grams of CO2eq) and additional considerations, such as electricity usage, go here. Edit the suggested text below accordingly -->
156
-
157
- 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).
158
-
159
- - **Hardware Type:** [More Information Needed]
160
- - **Hours used:** [More Information Needed]
161
- - **Cloud Provider:** [More Information Needed]
162
- - **Compute Region:** [More Information Needed]
163
- - **Carbon Emitted:** [More Information Needed]
164
-
165
- ## Technical Specifications [optional]
166
-
167
- ### Model Architecture and Objective
168
-
169
- [More Information Needed]
170
-
171
- ### Compute Infrastructure
172
-
173
- [More Information Needed]
174
-
175
- #### Hardware
176
-
177
- [More Information Needed]
178
-
179
- #### Software
180
-
181
- [More Information Needed]
182
-
183
- ## Citation [optional]
184
-
185
- <!-- If there is a paper or blog post introducing the model, the APA and Bibtex information for that should go in this section. -->
186
-
187
- **BibTeX:**
188
-
189
- [More Information Needed]
190
-
191
- **APA:**
192
-
193
- [More Information Needed]
194
-
195
- ## Glossary [optional]
196
-
197
- <!-- If relevant, include terms and calculations in this section that can help readers understand the model or model card. -->
198
-
199
- [More Information Needed]
200
-
201
- ## More Information [optional]
202
-
203
- [More Information Needed]
204
-
205
- ## Model Card Authors [optional]
206
-
207
- [More Information Needed]
208
-
209
- ## Model Card Contact
210
-
211
- [More Information Needed]
 
20
 
21
  This is the model card of a 🤗 transformers model that has been pushed on the Hub. This model card has been automatically generated.
22
 
23
+ - **Developed by:** Aniket Maurya
24
+ - **Model type:** Visual language model
25
+ - **License:** MIT
26
+ - **Finetuned from model [optional]:** microsoft/Florence-2-base-ft
 
 
 
27
 
 
 
 
 
 
 
 
28
 
29
  ## Uses
30
 
31
+ Use this model for extracting total amount from a receipt.
 
 
 
 
32
 
 
33
 
34
  ## How to Get Started with the Model
35
 
 
45
  device = "cuda:0" if torch.cuda.is_available() else "cpu"
46
  torch_dtype = torch.float16 if torch.cuda.is_available() else torch.float32
47
 
48
+ model = AutoModelForCausalLM.from_pretrained("aniketmaurya/receipt-model-2025", torch_dtype=torch_dtype, trust_remote_code=True).to(device)
49
  processor = AutoProcessor.from_pretrained("microsoft/Florence-2-base-ft", trust_remote_code=True)
50
 
51
+ prompt = "<VQA>Given the following receipt, extract the total amount spent."
52
 
53
  url = "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/transformers/tasks/car.jpg?download=true"
54
  image = Image.open(requests.get(url, stream=True).raw)
 
58
  generated_ids = model.generate(
59
  input_ids=inputs["input_ids"],
60
  pixel_values=inputs["pixel_values"],
61
+ max_new_tokens=100,
62
  do_sample=False,
63
  num_beams=3
64
  )
65
  generated_text = processor.batch_decode(generated_ids, skip_special_tokens=False)[0]
66
 
67
+ print(generated_text)
 
 
68
  ```
69
 
70
 
 
72
 
73
  ### Training Data
74
 
75
+ Public receipt data comprising 216 images forked from Roboflow universe and annotated manually for total amount.
76
 
 
77
 
78
  ### Training Procedure
79
 
80
+ Training configuration
81
+ ```
82
+ {
83
+ 'model_id': 'microsoft/Florence-2-base-ft',
84
+ 'revision': 'refs/pr/20',
85
+ 'epochs': 30,
86
+ 'optimizer': 'adamw',
87
+ 'lr': 5e-06,
88
+ 'lr_scheduler': 'linear',
89
+ 'batch_size': 8,
90
+ 'val_batch_size': None,
91
+ 'num_workers': 0,
92
+ 'val_num_workers': None,
93
+ 'lora_r': 8,
94
+ 'lora_alpha': 8,
95
+ 'lora_dropout': 0.05,
96
+ 'bias': 'none',
97
+ 'use_rslora': True,
98
+ 'init_lora_weights': 'gaussian',
99
+ }
100
+ ```
101
 
102
  #### Preprocessing [optional]
103
 
104
+ **Image augmentations:**
 
105
 
106
+ - shear, random rotate, and noise
107
 
 
 
 
 
 
 
 
108
 
109
  ## Evaluation
110
 
111
+ Vibe check 😎