Mian Zhang commited on
Commit
21889ba
·
1 Parent(s): 8b6c23b
Files changed (1) hide show
  1. app.py +9 -3
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
- content = uploaded_file.read()
27
- if isinstance(content, bytes):
28
- content = content.decode('utf-8')
 
 
 
 
 
 
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