Spaces:
Running
Running
Mian Zhang commited on
Commit ·
21889ba
1
Parent(s): 8b6c23b
update
Browse files
app.py
CHANGED
|
@@ -23,9 +23,15 @@ def calculate_accuracy(uploaded_file):
|
|
| 23 |
"""Calculate Task 1 accuracy from uploaded predictions"""
|
| 24 |
try:
|
| 25 |
# Read uploaded file
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
content =
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 29 |
|
| 30 |
predictions = json.loads(content)
|
| 31 |
|
|
|
|
| 23 |
"""Calculate Task 1 accuracy from uploaded predictions"""
|
| 24 |
try:
|
| 25 |
# Read uploaded file
|
| 26 |
+
if hasattr(uploaded_file, 'read'):
|
| 27 |
+
# File-like object
|
| 28 |
+
content = uploaded_file.read()
|
| 29 |
+
if isinstance(content, bytes):
|
| 30 |
+
content = content.decode('utf-8')
|
| 31 |
+
else:
|
| 32 |
+
# NamedString or file path
|
| 33 |
+
with open(uploaded_file, 'r') as f:
|
| 34 |
+
content = f.read()
|
| 35 |
|
| 36 |
predictions = json.loads(content)
|
| 37 |
|