Spaces:
Runtime error
Runtime error
小形克宏 commited on
Commit ·
987829f
1
Parent(s): 4a695de
Fix: remove gr.State, support Gradio 5 filepath API
Browse files
app.py
CHANGED
|
@@ -285,21 +285,23 @@ def compare_experiments(
|
|
| 285 |
def process_files(public_150_file, inference_files):
|
| 286 |
"""メイン処理:ファイルを受け取って分析結果を返す"""
|
| 287 |
if public_150_file is None:
|
| 288 |
-
return "❌ public_150.json をアップロードしてください", None, None, None
|
| 289 |
|
| 290 |
if not inference_files:
|
| 291 |
-
return "❌ inference.json を1つ以上アップロードしてください", None, None, None
|
| 292 |
|
| 293 |
try:
|
| 294 |
-
#
|
| 295 |
-
|
|
|
|
| 296 |
|
| 297 |
all_results = {}
|
| 298 |
all_summaries = {}
|
| 299 |
|
| 300 |
for inf_file in inference_files:
|
| 301 |
-
|
| 302 |
-
|
|
|
|
| 303 |
inference_data = json.load(f)
|
| 304 |
|
| 305 |
df = analyze_single_inference(inference_data, task_info)
|
|
@@ -343,11 +345,11 @@ def process_files(public_150_file, inference_files):
|
|
| 343 |
format_comparison_rows.append(row)
|
| 344 |
format_df = pd.DataFrame(format_comparison_rows)
|
| 345 |
|
| 346 |
-
return summary_text, comparison_df, error_df, format_df
|
| 347 |
|
| 348 |
except Exception as e:
|
| 349 |
error_trace = traceback.format_exc()
|
| 350 |
-
return f"❌ エラーが発生しました:\n```\n{error_trace}\n```", None, None, None
|
| 351 |
|
| 352 |
|
| 353 |
# ---------------------------------------------------------------------------
|
|
@@ -416,7 +418,7 @@ def create_app():
|
|
| 416 |
analyze_btn.click(
|
| 417 |
fn=process_files,
|
| 418 |
inputs=[public_file, inference_files],
|
| 419 |
-
outputs=[summary_output, comparison_table, error_table, format_table
|
| 420 |
)
|
| 421 |
|
| 422 |
gr.Markdown(
|
|
|
|
| 285 |
def process_files(public_150_file, inference_files):
|
| 286 |
"""メイン処理:ファイルを受け取って分析結果を返す"""
|
| 287 |
if public_150_file is None:
|
| 288 |
+
return "❌ public_150.json をアップロードしてください", None, None, None
|
| 289 |
|
| 290 |
if not inference_files:
|
| 291 |
+
return "❌ inference.json を1つ以上アップロードしてください", None, None, None
|
| 292 |
|
| 293 |
try:
|
| 294 |
+
# Gradio 5ではfilepathモードで文字列パスが渡される
|
| 295 |
+
pub_path = public_150_file if isinstance(public_150_file, str) else public_150_file.name
|
| 296 |
+
task_info = load_public_150(pub_path)
|
| 297 |
|
| 298 |
all_results = {}
|
| 299 |
all_summaries = {}
|
| 300 |
|
| 301 |
for inf_file in inference_files:
|
| 302 |
+
inf_path = inf_file if isinstance(inf_file, str) else inf_file.name
|
| 303 |
+
filename = Path(inf_path).stem
|
| 304 |
+
with open(inf_path, "r", encoding="utf-8") as f:
|
| 305 |
inference_data = json.load(f)
|
| 306 |
|
| 307 |
df = analyze_single_inference(inference_data, task_info)
|
|
|
|
| 345 |
format_comparison_rows.append(row)
|
| 346 |
format_df = pd.DataFrame(format_comparison_rows)
|
| 347 |
|
| 348 |
+
return summary_text, comparison_df, error_df, format_df
|
| 349 |
|
| 350 |
except Exception as e:
|
| 351 |
error_trace = traceback.format_exc()
|
| 352 |
+
return f"❌ エラーが発生しました:\n```\n{error_trace}\n```", None, None, None
|
| 353 |
|
| 354 |
|
| 355 |
# ---------------------------------------------------------------------------
|
|
|
|
| 418 |
analyze_btn.click(
|
| 419 |
fn=process_files,
|
| 420 |
inputs=[public_file, inference_files],
|
| 421 |
+
outputs=[summary_output, comparison_table, error_table, format_table],
|
| 422 |
)
|
| 423 |
|
| 424 |
gr.Markdown(
|