KennethTM commited on
Commit
9f99215
·
verified ·
1 Parent(s): eb1108a

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +183 -3
README.md CHANGED
@@ -43,13 +43,13 @@ from io import BytesIO
43
 
44
  # Load model and processor
45
  device = "cuda" if torch.cuda.is_available() else "cpu"
46
- processor = AutoProcessor.from_pretrained("pix2struct-base-table2html")
47
- model = Pix2StructForConditionalGeneration.from_pretrained("pix2struct-base-table2html")
48
  model.to(device)
49
  model.eval()
50
 
51
  # Load example image from URL
52
- url = "https://example.com/path_to_table_image.jpg"
53
  response = requests.get(url)
54
  image = Image.open(BytesIO(response.content))
55
 
@@ -64,4 +64,184 @@ predictions_decoded = processor.tokenizer.batch_decode(predictions, skip_special
64
 
65
  # Show predictions as text
66
  print(predictions_decoded[0])
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
67
  ```
 
43
 
44
  # Load model and processor
45
  device = "cuda" if torch.cuda.is_available() else "cpu"
46
+ processor = AutoProcessor.from_pretrained("KennethTM/pix2struct-base-table2html")
47
+ model = Pix2StructForConditionalGeneration.from_pretrained("KennethTM/pix2struct-base-table2html")
48
  model.to(device)
49
  model.eval()
50
 
51
  # Load example image from URL
52
+ url = "https://huggingface.co/KennethTM/pix2struct-base-table2html/resolve/main/example_recog_1.jpg"
53
  response = requests.get(url)
54
  image = Image.open(BytesIO(response.content))
55
 
 
64
 
65
  # Show predictions as text
66
  print(predictions_decoded[0])
67
+ ```
68
+
69
+ Example image:
70
+ ![](https://huggingface.co/KennethTM/pix2struct-base-table2html/resolve/main/example_recog_1.jpg)
71
+
72
+ Model HTML output for example image:
73
+ ```html
74
+ <table border="1" cellspacing="0">
75
+ <tr>
76
+ <th>
77
+ Rank
78
+ </th>
79
+ <th>
80
+ Lane
81
+ </th>
82
+ <th>
83
+ Name
84
+ </th>
85
+ <th>
86
+ Nationality
87
+ </th>
88
+ <th>
89
+ Time
90
+ </th>
91
+ <th>
92
+ Notes
93
+ </th>
94
+ </tr>
95
+ <tr>
96
+ <td>
97
+ </td>
98
+ <td>
99
+ 4
100
+ </td>
101
+ <td>
102
+ Michael Phelps
103
+ </td>
104
+ <td>
105
+ United States
106
+ </td>
107
+ <td>
108
+ 51.25
109
+ </td>
110
+ <td>
111
+ OR
112
+ </td>
113
+ </tr>
114
+ <tr>
115
+ <td>
116
+ </td>
117
+ <td>
118
+ 3
119
+ </td>
120
+ <td>
121
+ Ian Crocker
122
+ </td>
123
+ <td>
124
+ United States
125
+ </td>
126
+ <td>
127
+ 51.29
128
+ </td>
129
+ <td>
130
+ </td>
131
+ </tr>
132
+ <tr>
133
+ <td>
134
+ </td>
135
+ <td>
136
+ 5
137
+ </td>
138
+ <td>
139
+ Andriy Serdinov
140
+ </td>
141
+ <td>
142
+ Ukraine
143
+ </td>
144
+ <td>
145
+ 51.36
146
+ </td>
147
+ <td>
148
+ EU
149
+ </td>
150
+ </tr>
151
+ <tr>
152
+ <td>
153
+ 4
154
+ </td>
155
+ <td>
156
+ 1
157
+ </td>
158
+ <td>
159
+ Thomas Rupprath
160
+ </td>
161
+ <td>
162
+ Germany
163
+ </td>
164
+ <td>
165
+ 52.27
166
+ </td>
167
+ <td>
168
+ </td>
169
+ </tr>
170
+ <tr>
171
+ <td>
172
+ 5
173
+ </td>
174
+ <td>
175
+ 6
176
+ </td>
177
+ <td>
178
+ Igor Marchenko
179
+ </td>
180
+ <td>
181
+ Russia
182
+ </td>
183
+ <td>
184
+ 52.32
185
+ </td>
186
+ <td>
187
+ </td>
188
+ </tr>
189
+ <tr>
190
+ <td>
191
+ 6
192
+ </td>
193
+ <td>
194
+ 2
195
+ </td>
196
+ <td>
197
+ Gabriel Mangabeira
198
+ </td>
199
+ <td>
200
+ Brazil
201
+ </td>
202
+ <td>
203
+ 52.34
204
+ </td>
205
+ <td>
206
+ </td>
207
+ </tr>
208
+ <tr>
209
+ <td>
210
+ 7
211
+ </td>
212
+ <td>
213
+ 8
214
+ </td>
215
+ <td>
216
+ Duje Draganja
217
+ </td>
218
+ <td>
219
+ Croatia
220
+ </td>
221
+ <td>
222
+ 52.46
223
+ </td>
224
+ <td>
225
+ </td>
226
+ </tr>
227
+ <tr>
228
+ <td>
229
+ 8
230
+ </td>
231
+ <td>
232
+ 7
233
+ </td>
234
+ <td>
235
+ Geoff Huegill
236
+ </td>
237
+ <td>
238
+ Australia
239
+ </td>
240
+ <td>
241
+ 52.56
242
+ </td>
243
+ <td>
244
+ </td>
245
+ </tr>
246
+ </table>
247
  ```