Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -74,9 +74,9 @@ def get_arena_table(model_table_df):
|
|
74 |
# model display name
|
75 |
row.append(model_name)
|
76 |
|
77 |
-
row.append(
|
78 |
-
|
79 |
-
)
|
80 |
row.append(
|
81 |
model_table_df["Open Source"].values[model_key]
|
82 |
)
|
@@ -118,10 +118,56 @@ def get_arena_table(model_table_df):
|
|
118 |
values.append(row)
|
119 |
return values
|
120 |
|
121 |
-
def
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
122 |
if leaderboard_table_file:
|
123 |
data = load_leaderboard_table_csv(leaderboard_table_file)
|
|
|
|
|
124 |
model_table_df = pd.DataFrame(data)
|
|
|
125 |
md_head = f"""
|
126 |
# π OCRBench v2 Leaderboard
|
127 |
| [GitHub](https://github.com/Yuliang-Liu/MultimodalOCR) | [Paper](https://arxiv.org/abs/2305.07895) |
|
@@ -137,7 +183,6 @@ def build_leaderboard_tab(leaderboard_table_file, show_plot=False):
|
|
137 |
headers=[
|
138 |
"Rank",
|
139 |
"Name",
|
140 |
-
"Language Model",
|
141 |
"Open Source",
|
142 |
"Text Recognition",
|
143 |
"Text Referring",
|
@@ -153,7 +198,6 @@ def build_leaderboard_tab(leaderboard_table_file, show_plot=False):
|
|
153 |
"str",
|
154 |
"markdown",
|
155 |
"str",
|
156 |
-
"str",
|
157 |
"number",
|
158 |
"number",
|
159 |
"number",
|
@@ -168,6 +212,39 @@ def build_leaderboard_tab(leaderboard_table_file, show_plot=False):
|
|
168 |
elem_id="arena_leaderboard_dataframe",
|
169 |
wrap=False,
|
170 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
171 |
else:
|
172 |
pass
|
173 |
md_tail = f"""
|
@@ -176,7 +253,7 @@ def build_leaderboard_tab(leaderboard_table_file, show_plot=False):
|
|
176 |
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."""
|
177 |
gr.Markdown(md_tail, elem_id="leaderboard_markdown")
|
178 |
|
179 |
-
def build_demo(leaderboard_table_file):
|
180 |
text_size = gr.themes.sizes.text_lg
|
181 |
|
182 |
with gr.Blocks(
|
@@ -185,15 +262,16 @@ def build_demo(leaderboard_table_file):
|
|
185 |
css=block_css,
|
186 |
) as demo:
|
187 |
leader_components = build_leaderboard_tab(
|
188 |
-
leaderboard_table_file,show_plot=True
|
189 |
)
|
190 |
return demo
|
191 |
|
192 |
if __name__ == "__main__":
|
193 |
parser = argparse.ArgumentParser()
|
194 |
parser.add_argument("--share", action="store_true")
|
195 |
-
parser.add_argument("--OCRBench_file", type=str, default="./
|
|
|
196 |
args = parser.parse_args()
|
197 |
|
198 |
-
demo = build_demo(args.OCRBench_file)
|
199 |
demo.launch()
|
|
|
74 |
# model display name
|
75 |
row.append(model_name)
|
76 |
|
77 |
+
# row.append(
|
78 |
+
# model_table_df["Language Model"].values[model_key]
|
79 |
+
# )
|
80 |
row.append(
|
81 |
model_table_df["Open Source"].values[model_key]
|
82 |
)
|
|
|
118 |
values.append(row)
|
119 |
return values
|
120 |
|
121 |
+
def get_cn_table(model_table_df):
|
122 |
+
# sort by rating
|
123 |
+
model_table_df = model_table_df.sort_values(by=["Average Score"], ascending=False)
|
124 |
+
values = []
|
125 |
+
for i in range(len(model_table_df)):
|
126 |
+
row = []
|
127 |
+
model_key = model_table_df.index[i]
|
128 |
+
model_name = model_table_df["Model"].values[model_key]
|
129 |
+
# rank
|
130 |
+
row.append(i + 1)
|
131 |
+
# model display name
|
132 |
+
row.append(model_name)
|
133 |
+
|
134 |
+
row.append(
|
135 |
+
model_table_df["Open Source"].values[model_key]
|
136 |
+
)
|
137 |
+
row.append(
|
138 |
+
model_table_df["Text Recognition"].values[model_key]
|
139 |
+
)
|
140 |
+
|
141 |
+
|
142 |
+
row.append(
|
143 |
+
model_table_df["Relation Extraction"].values[model_key]
|
144 |
+
)
|
145 |
+
|
146 |
+
row.append(
|
147 |
+
model_table_df["Element Parsing"].values[model_key]
|
148 |
+
)
|
149 |
+
|
150 |
+
row.append(
|
151 |
+
model_table_df["Visual Text Understanding"].values[model_key]
|
152 |
+
)
|
153 |
+
|
154 |
+
row.append(
|
155 |
+
model_table_df["Knowledge Reasoning"].values[model_key]
|
156 |
+
)
|
157 |
+
|
158 |
+
row.append(
|
159 |
+
model_table_df["Average Score"].values[model_key]
|
160 |
+
)
|
161 |
+
values.append(row)
|
162 |
+
return values
|
163 |
+
|
164 |
+
def build_leaderboard_tab(leaderboard_table_file, leaderboard_table_file_2, show_plot=False):
|
165 |
if leaderboard_table_file:
|
166 |
data = load_leaderboard_table_csv(leaderboard_table_file)
|
167 |
+
data_2 = load_leaderboard_table_csv(leaderboard_table_file_2)
|
168 |
+
|
169 |
model_table_df = pd.DataFrame(data)
|
170 |
+
model_table_df_2 = pd.DataFrame(data_2)
|
171 |
md_head = f"""
|
172 |
# π OCRBench v2 Leaderboard
|
173 |
| [GitHub](https://github.com/Yuliang-Liu/MultimodalOCR) | [Paper](https://arxiv.org/abs/2305.07895) |
|
|
|
183 |
headers=[
|
184 |
"Rank",
|
185 |
"Name",
|
|
|
186 |
"Open Source",
|
187 |
"Text Recognition",
|
188 |
"Text Referring",
|
|
|
198 |
"str",
|
199 |
"markdown",
|
200 |
"str",
|
|
|
201 |
"number",
|
202 |
"number",
|
203 |
"number",
|
|
|
212 |
elem_id="arena_leaderboard_dataframe",
|
213 |
wrap=False,
|
214 |
)
|
215 |
+
with gr.Tab("Text Recognition", id=1):
|
216 |
+
arena_table_vals = get_cn_table(model_table_df_2)
|
217 |
+
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."
|
218 |
+
gr.Markdown(md, elem_id="leaderboard_markdown")
|
219 |
+
gr.Dataframe(
|
220 |
+
headers=[
|
221 |
+
"Rank",
|
222 |
+
"Name",
|
223 |
+
"Open Source",
|
224 |
+
"Text Recognition",
|
225 |
+
"Relation Extraction",
|
226 |
+
"Element Parsing",
|
227 |
+
"Visual Text Understanding",
|
228 |
+
"Knowledge Reasoning",
|
229 |
+
"Average Score",
|
230 |
+
],
|
231 |
+
datatype=[
|
232 |
+
"str",
|
233 |
+
"markdown",
|
234 |
+
"str",
|
235 |
+
"number",
|
236 |
+
"number",
|
237 |
+
"number",
|
238 |
+
"number",
|
239 |
+
"number",
|
240 |
+
"number",
|
241 |
+
],
|
242 |
+
value=arena_table_vals,
|
243 |
+
elem_id="arena_leaderboard_dataframe",
|
244 |
+
# height=700,
|
245 |
+
# column_widths=[60, 120,150,100, 100, 100, 100, 100, 80],
|
246 |
+
wrap=True,
|
247 |
+
)
|
248 |
else:
|
249 |
pass
|
250 |
md_tail = f"""
|
|
|
253 |
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."""
|
254 |
gr.Markdown(md_tail, elem_id="leaderboard_markdown")
|
255 |
|
256 |
+
def build_demo(leaderboard_table_file, leaderboard_table_file_2):
|
257 |
text_size = gr.themes.sizes.text_lg
|
258 |
|
259 |
with gr.Blocks(
|
|
|
262 |
css=block_css,
|
263 |
) as demo:
|
264 |
leader_components = build_leaderboard_tab(
|
265 |
+
leaderboard_table_file, leaderboard_table_file_2, show_plot=True
|
266 |
)
|
267 |
return demo
|
268 |
|
269 |
if __name__ == "__main__":
|
270 |
parser = argparse.ArgumentParser()
|
271 |
parser.add_argument("--share", action="store_true")
|
272 |
+
parser.add_argument("--OCRBench_file", type=str, default="./OCRBench_en.csv")
|
273 |
+
parser.add_argument("--OCRBench_file_2", type=str, default="./OCRBench_cn.csv")
|
274 |
args = parser.parse_args()
|
275 |
|
276 |
+
demo = build_demo(args.OCRBench_file, args.OCRBench_file_2)
|
277 |
demo.launch()
|