Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -108,61 +108,10 @@ def get_arena_table(model_table_df):
|
|
108 |
values.append(row)
|
109 |
return values
|
110 |
|
111 |
-
def
|
112 |
-
# sort by rating
|
113 |
-
values = []
|
114 |
-
for i in range(len(model_table_df)):
|
115 |
-
row = []
|
116 |
-
model_key = model_table_df.index[i]
|
117 |
-
model_name = model_table_df["Model"].values[model_key]
|
118 |
-
# rank
|
119 |
-
row.append(i + 1)
|
120 |
-
# model display name
|
121 |
-
row.append(model_name)
|
122 |
-
|
123 |
-
row.append(
|
124 |
-
model_table_df["Language Model"].values[model_key]
|
125 |
-
)
|
126 |
-
row.append(
|
127 |
-
model_table_df["Open Source"].values[model_key]
|
128 |
-
)
|
129 |
-
row.append(
|
130 |
-
model_table_df["Regular Text"].values[model_key]
|
131 |
-
)
|
132 |
-
|
133 |
-
row.append(
|
134 |
-
model_table_df["Irregular Text"].values[model_key]
|
135 |
-
)
|
136 |
-
|
137 |
-
row.append(
|
138 |
-
model_table_df["Artistic Text"].values[model_key]
|
139 |
-
)
|
140 |
-
|
141 |
-
row.append(
|
142 |
-
model_table_df["Handwriting"].values[model_key]
|
143 |
-
)
|
144 |
-
|
145 |
-
row.append(
|
146 |
-
model_table_df["Digit string"].values[model_key]
|
147 |
-
)
|
148 |
-
|
149 |
-
row.append(
|
150 |
-
model_table_df["Non-semantic Text"].values[model_key]
|
151 |
-
)
|
152 |
-
row.append(
|
153 |
-
model_table_df["ALL"].values[model_key]
|
154 |
-
)
|
155 |
-
values.append(row)
|
156 |
-
return values
|
157 |
-
|
158 |
-
def build_leaderboard_tab(leaderboard_table_file, text_recog_file, Inaccessible_model_file, show_plot=False):
|
159 |
if leaderboard_table_file:
|
160 |
data = load_leaderboard_table_csv(leaderboard_table_file)
|
161 |
-
data_recog = load_leaderboard_table_csv(text_recog_file)
|
162 |
-
data_Inaccessible = load_leaderboard_table_csv(Inaccessible_model_file)
|
163 |
model_table_df = pd.DataFrame(data)
|
164 |
-
model_table_df_Inaccessible = pd.DataFrame(data_Inaccessible)
|
165 |
-
recog_table_df = pd.DataFrame(data_recog)
|
166 |
md_head = f"""
|
167 |
# π OCRBench Leaderboard
|
168 |
| [GitHub](https://github.com/Yuliang-Liu/MultimodalOCR) | [Paper](https://arxiv.org/abs/2305.07895) |
|
@@ -172,79 +121,7 @@ def build_leaderboard_tab(leaderboard_table_file, text_recog_file, Inaccessible_
|
|
172 |
# arena table
|
173 |
with gr.Tab("OCRBench", id=0):
|
174 |
arena_table_vals = get_arena_table(model_table_df)
|
175 |
-
md = "OCRBench is a comprehensive evaluation benchmark designed to assess the OCR capabilities of Large Multimodal Models. It comprises five components: Text Recognition, SceneText-Centric VQA, Document-Oriented VQA, Key Information Extraction, and Handwritten Mathematical Expression Recognition. The benchmark includes 1000 question-answer pairs, and all the answers undergo manual verification and correction to ensure a more precise evaluation."
|
176 |
-
gr.Markdown(md, elem_id="leaderboard_markdown")
|
177 |
-
gr.Dataframe(
|
178 |
-
headers=[
|
179 |
-
"Rank",
|
180 |
-
"Name",
|
181 |
-
"Language Model",
|
182 |
-
"Open Source",
|
183 |
-
"Text Recognition",
|
184 |
-
"Scene Text-Centric VQA",
|
185 |
-
"Doc-Oriented VQA",
|
186 |
-
"KIE",
|
187 |
-
"HMER",
|
188 |
-
"Final Score",
|
189 |
-
],
|
190 |
-
datatype=[
|
191 |
-
"str",
|
192 |
-
"markdown",
|
193 |
-
"str",
|
194 |
-
"str",
|
195 |
-
"number",
|
196 |
-
"number",
|
197 |
-
"number",
|
198 |
-
"number",
|
199 |
-
"number",
|
200 |
-
"number",
|
201 |
-
],
|
202 |
-
value=arena_table_vals,
|
203 |
-
elem_id="arena_leaderboard_dataframe",
|
204 |
-
height=700,
|
205 |
-
column_widths=[60, 120,150,100, 150, 200, 180, 80, 80, 160],
|
206 |
-
wrap=True,
|
207 |
-
)
|
208 |
-
with gr.Tab("Text Recognition", id=1):
|
209 |
-
arena_table_vals = get_recog_table(recog_table_df)
|
210 |
-
md = "OCRBench is a comprehensive evaluation benchmark designed to assess the OCR capabilities of Large Multimodal Models. It comprises five components: Text Recognition, SceneText-Centric VQA, Document-Oriented VQA, Key Information Extraction, and Handwritten Mathematical Expression Recognition. The benchmark includes 1000 question-answer pairs, and all the answers undergo manual verification and correction to ensure a more precise evaluation."
|
211 |
-
gr.Markdown(md, elem_id="leaderboard_markdown")
|
212 |
-
gr.Dataframe(
|
213 |
-
headers=[
|
214 |
-
"Rank",
|
215 |
-
"Name",
|
216 |
-
"Language Model",
|
217 |
-
"Open Source",
|
218 |
-
"Regular Text",
|
219 |
-
"Irregular Text",
|
220 |
-
"Artistic Text",
|
221 |
-
"Handwriting",
|
222 |
-
"Digit string",
|
223 |
-
"Non-semantic Text",
|
224 |
-
"ALL",
|
225 |
-
],
|
226 |
-
datatype=[
|
227 |
-
"str",
|
228 |
-
"markdown",
|
229 |
-
"str",
|
230 |
-
"str",
|
231 |
-
"number",
|
232 |
-
"number",
|
233 |
-
"number",
|
234 |
-
"number",
|
235 |
-
"number",
|
236 |
-
"number",
|
237 |
-
"number",
|
238 |
-
],
|
239 |
-
value=arena_table_vals,
|
240 |
-
elem_id="arena_leaderboard_dataframe",
|
241 |
-
height=700,
|
242 |
-
column_widths=[60, 120,150,100, 100, 100, 100, 100, 100,100, 80],
|
243 |
-
wrap=True,
|
244 |
-
)
|
245 |
-
with gr.Tab("Inaccessible Model", id=2):
|
246 |
-
arena_table_vals = get_arena_table(model_table_df_Inaccessible)
|
247 |
-
md = "The models on this list are neither open-source nor have API call interfaces available."
|
248 |
gr.Markdown(md, elem_id="leaderboard_markdown")
|
249 |
gr.Dataframe(
|
250 |
headers=[
|
@@ -285,7 +162,7 @@ def build_leaderboard_tab(leaderboard_table_file, text_recog_file, Inaccessible_
|
|
285 |
If you would like to include your model in the OCRBench leaderboard, please follow the evaluation instructions provided on [GitHub](https://github.com/Yuliang-Liu/MultimodalOCR), [VLMEvalKit](https://github.com/open-compass/VLMEvalKit) or [lmms-eval](https://github.com/EvolvingLMMs-Lab/lmms-eval) and feel free to contact us via email at [email protected]. We will update the leaderboard in time."""
|
286 |
gr.Markdown(md_tail, elem_id="leaderboard_markdown")
|
287 |
|
288 |
-
def build_demo(leaderboard_table_file
|
289 |
text_size = gr.themes.sizes.text_lg
|
290 |
|
291 |
with gr.Blocks(
|
@@ -294,7 +171,7 @@ def build_demo(leaderboard_table_file, recog_table_file, Inaccessible_model_file
|
|
294 |
css=block_css,
|
295 |
) as demo:
|
296 |
leader_components = build_leaderboard_tab(
|
297 |
-
leaderboard_table_file,
|
298 |
)
|
299 |
return demo
|
300 |
|
@@ -302,9 +179,7 @@ if __name__ == "__main__":
|
|
302 |
parser = argparse.ArgumentParser()
|
303 |
parser.add_argument("--share", action="store_true")
|
304 |
parser.add_argument("--OCRBench_file", type=str, default="./OCRBench.csv")
|
305 |
-
parser.add_argument("--TextRecognition_file", type=str, default="./TextRecognition.csv")
|
306 |
-
parser.add_argument("--Inaccessible_model_file", type=str, default="./Inaccessible_model.csv")
|
307 |
args = parser.parse_args()
|
308 |
|
309 |
-
demo = build_demo(args.OCRBench_file
|
310 |
demo.launch()
|
|
|
108 |
values.append(row)
|
109 |
return values
|
110 |
|
111 |
+
def build_leaderboard_tab(leaderboard_table_file, show_plot=False):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
112 |
if leaderboard_table_file:
|
113 |
data = load_leaderboard_table_csv(leaderboard_table_file)
|
|
|
|
|
114 |
model_table_df = pd.DataFrame(data)
|
|
|
|
|
115 |
md_head = f"""
|
116 |
# π OCRBench Leaderboard
|
117 |
| [GitHub](https://github.com/Yuliang-Liu/MultimodalOCR) | [Paper](https://arxiv.org/abs/2305.07895) |
|
|
|
121 |
# arena table
|
122 |
with gr.Tab("OCRBench", id=0):
|
123 |
arena_table_vals = get_arena_table(model_table_df)
|
124 |
+
md = "OCRBench v2 is a comprehensive evaluation benchmark designed to assess the OCR capabilities of Large Multimodal Models. It comprises five components: Text Recognition, SceneText-Centric VQA, Document-Oriented VQA, Key Information Extraction, and Handwritten Mathematical Expression Recognition. The benchmark includes 1000 question-answer pairs, and all the answers undergo manual verification and correction to ensure a more precise evaluation."
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
125 |
gr.Markdown(md, elem_id="leaderboard_markdown")
|
126 |
gr.Dataframe(
|
127 |
headers=[
|
|
|
162 |
If you would like to include your model in the OCRBench leaderboard, please follow the evaluation instructions provided on [GitHub](https://github.com/Yuliang-Liu/MultimodalOCR), [VLMEvalKit](https://github.com/open-compass/VLMEvalKit) or [lmms-eval](https://github.com/EvolvingLMMs-Lab/lmms-eval) and feel free to contact us via email at [email protected]. We will update the leaderboard in time."""
|
163 |
gr.Markdown(md_tail, elem_id="leaderboard_markdown")
|
164 |
|
165 |
+
def build_demo(leaderboard_table_file):
|
166 |
text_size = gr.themes.sizes.text_lg
|
167 |
|
168 |
with gr.Blocks(
|
|
|
171 |
css=block_css,
|
172 |
) as demo:
|
173 |
leader_components = build_leaderboard_tab(
|
174 |
+
leaderboard_table_file,show_plot=True
|
175 |
)
|
176 |
return demo
|
177 |
|
|
|
179 |
parser = argparse.ArgumentParser()
|
180 |
parser.add_argument("--share", action="store_true")
|
181 |
parser.add_argument("--OCRBench_file", type=str, default="./OCRBench.csv")
|
|
|
|
|
182 |
args = parser.parse_args()
|
183 |
|
184 |
+
demo = build_demo(args.OCRBench_file)
|
185 |
demo.launch()
|