Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -155,11 +155,13 @@ def get_recog_table(model_table_df):
|
|
155 |
values.append(row)
|
156 |
return values
|
157 |
|
158 |
-
def build_leaderboard_tab(leaderboard_table_file, text_recog_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 |
model_table_df = pd.DataFrame(data)
|
|
|
163 |
recog_table_df = pd.DataFrame(data_recog)
|
164 |
md_head = f"""
|
165 |
# π OCRBench Leaderboard
|
@@ -168,8 +170,8 @@ def build_leaderboard_tab(leaderboard_table_file, text_recog_file, show_plot=Fal
|
|
168 |
gr.Markdown(md_head, elem_id="leaderboard_markdown")
|
169 |
with gr.Tabs() as tabs:
|
170 |
# arena table
|
171 |
-
arena_table_vals = get_arena_table(model_table_df)
|
172 |
with gr.Tab("OCRBench", id=0):
|
|
|
173 |
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."
|
174 |
gr.Markdown(md, elem_id="leaderboard_markdown")
|
175 |
gr.Dataframe(
|
@@ -240,7 +242,41 @@ def build_leaderboard_tab(leaderboard_table_file, text_recog_file, show_plot=Fal
|
|
240 |
column_widths=[60, 120,150,100, 100, 100, 100, 100, 100,100, 80],
|
241 |
wrap=True,
|
242 |
)
|
243 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
244 |
else:
|
245 |
pass
|
246 |
md_tail = f"""
|
@@ -249,7 +285,7 @@ def build_leaderboard_tab(leaderboard_table_file, text_recog_file, show_plot=Fal
|
|
249 |
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."""
|
250 |
gr.Markdown(md_tail, elem_id="leaderboard_markdown")
|
251 |
|
252 |
-
def build_demo(leaderboard_table_file, recog_table_file):
|
253 |
text_size = gr.themes.sizes.text_lg
|
254 |
|
255 |
with gr.Blocks(
|
@@ -258,7 +294,7 @@ def build_demo(leaderboard_table_file, recog_table_file):
|
|
258 |
css=block_css,
|
259 |
) as demo:
|
260 |
leader_components = build_leaderboard_tab(
|
261 |
-
leaderboard_table_file, recog_table_file,show_plot=True
|
262 |
)
|
263 |
return demo
|
264 |
|
@@ -267,7 +303,8 @@ if __name__ == "__main__":
|
|
267 |
parser.add_argument("--share", action="store_true")
|
268 |
parser.add_argument("--OCRBench_file", type=str, default="./OCRBench.csv")
|
269 |
parser.add_argument("--TextRecognition_file", type=str, default="./TextRecognition.csv")
|
|
|
270 |
args = parser.parse_args()
|
271 |
|
272 |
-
demo = build_demo(args.OCRBench_file, args.TextRecognition_file)
|
273 |
demo.launch()
|
|
|
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
|
|
|
170 |
gr.Markdown(md_head, elem_id="leaderboard_markdown")
|
171 |
with gr.Tabs() as tabs:
|
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(
|
|
|
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=[
|
251 |
+
"Rank",
|
252 |
+
"Name",
|
253 |
+
"Language Model",
|
254 |
+
"Open Source",
|
255 |
+
"Text Recognition",
|
256 |
+
"Scene Text-Centric VQA",
|
257 |
+
"Doc-Oriented VQA",
|
258 |
+
"KIE",
|
259 |
+
"HMER",
|
260 |
+
"Final Score",
|
261 |
+
],
|
262 |
+
datatype=[
|
263 |
+
"str",
|
264 |
+
"markdown",
|
265 |
+
"str",
|
266 |
+
"str",
|
267 |
+
"number",
|
268 |
+
"number",
|
269 |
+
"number",
|
270 |
+
"number",
|
271 |
+
"number",
|
272 |
+
"number",
|
273 |
+
],
|
274 |
+
value=arena_table_vals,
|
275 |
+
elem_id="arena_leaderboard_dataframe",
|
276 |
+
height=700,
|
277 |
+
column_widths=[60, 120,150,100, 150, 200, 180, 80, 80, 160],
|
278 |
+
wrap=True,
|
279 |
+
)
|
280 |
else:
|
281 |
pass
|
282 |
md_tail = f"""
|
|
|
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, recog_table_file, Inaccessible_model_file):
|
289 |
text_size = gr.themes.sizes.text_lg
|
290 |
|
291 |
with gr.Blocks(
|
|
|
294 |
css=block_css,
|
295 |
) as demo:
|
296 |
leader_components = build_leaderboard_tab(
|
297 |
+
leaderboard_table_file, recog_table_file,Inaccessible_model_file,show_plot=True
|
298 |
)
|
299 |
return demo
|
300 |
|
|
|
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, args.TextRecognition_file, args.Inaccessible_model_file)
|
310 |
demo.launch()
|