Spaces:
Runtime error
Runtime error
Commit
·
1bcaf5a
1
Parent(s):
abe371d
add
Browse files
app.py
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
from gradio_leaderboard import Leaderboard, ColumnFilter, SelectColumns
|
| 3 |
import pandas as pd
|
|
@@ -108,6 +109,14 @@ def init_leaderboard(dataframe):
|
|
| 108 |
# interactive=False,
|
| 109 |
# )
|
| 110 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 111 |
|
| 112 |
demo = gr.Blocks(css=custom_css)
|
| 113 |
with demo:
|
|
@@ -169,7 +178,12 @@ with demo:
|
|
| 169 |
row_count=5,
|
| 170 |
)
|
| 171 |
with gr.Row():
|
| 172 |
-
gr.Markdown("# ✉️✨ Submit your
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 173 |
|
| 174 |
with gr.Row():
|
| 175 |
with gr.Column():
|
|
|
|
| 1 |
+
import json
|
| 2 |
import gradio as gr
|
| 3 |
from gradio_leaderboard import Leaderboard, ColumnFilter, SelectColumns
|
| 4 |
import pandas as pd
|
|
|
|
| 109 |
# interactive=False,
|
| 110 |
# )
|
| 111 |
|
| 112 |
+
def process_json(file):
|
| 113 |
+
""" 读取用户上传的 JSON 文件并返回解析后的数据 """
|
| 114 |
+
try:
|
| 115 |
+
with open(file.name, 'r', encoding='utf-8') as f:
|
| 116 |
+
data = json.load(f)
|
| 117 |
+
return json.dumps(data, indent=4, ensure_ascii=False) # 格式化 JSON 以便显示
|
| 118 |
+
except Exception as e:
|
| 119 |
+
return str(e)
|
| 120 |
|
| 121 |
demo = gr.Blocks(css=custom_css)
|
| 122 |
with demo:
|
|
|
|
| 178 |
row_count=5,
|
| 179 |
)
|
| 180 |
with gr.Row():
|
| 181 |
+
gr.Markdown("# ✉️✨ Submit your results here!", elem_classes="markdown-text")
|
| 182 |
+
|
| 183 |
+
json_input = gr.File(label="Please upload an JSON file", type="file")
|
| 184 |
+
output = gr.Textbox(label="解析后的 JSON 内容", lines=10)
|
| 185 |
+
|
| 186 |
+
json_input.change(process_json, inputs=json_input, outputs=output)
|
| 187 |
|
| 188 |
with gr.Row():
|
| 189 |
with gr.Column():
|