Spaces:
Sleeping
Sleeping
Andrew Green
commited on
Commit
·
f051782
1
Parent(s):
152ae6f
Fix dict key mismatch
Browse files
app.py
CHANGED
@@ -33,14 +33,6 @@ def get_pipeline():
|
|
33 |
@spaces.GPU
|
34 |
def classify_abstracts(abstracts:Dict[str, str],batch_size=64, progress=gr.Progress()) -> None:
|
35 |
pipe = get_pipeline()
|
36 |
-
# pmids = list(abstracts.keys())
|
37 |
-
# batch_size = 64
|
38 |
-
# classification = []
|
39 |
-
# abstracts_list = list(abstracts.values())
|
40 |
-
# for i in range(0, len(abstracts), batch_size):
|
41 |
-
# classification.extend(pipe(abstracts_list[i:i+batch_size]))
|
42 |
-
|
43 |
-
|
44 |
|
45 |
# return classification
|
46 |
results = []
|
@@ -67,7 +59,7 @@ def classify_abstracts(abstracts:Dict[str, str],batch_size=64, progress=gr.Progr
|
|
67 |
for pmid, classification in zip(batch_pmids, classifications):
|
68 |
results.append({
|
69 |
'pmid': pmid,
|
70 |
-
'classification': classification['label'],
|
71 |
'score': classification['score']
|
72 |
})
|
73 |
|
@@ -78,9 +70,7 @@ def classify_abstracts(abstracts:Dict[str, str],batch_size=64, progress=gr.Progr
|
|
78 |
except Exception as e:
|
79 |
print(f"Error classifying batch starting at index {i}: {str(e)}")
|
80 |
continue
|
81 |
-
|
82 |
-
abs['label'] = label_lookup[abs['label']]
|
83 |
-
abs['pmid'] = pmid
|
84 |
progress(1.0, desc="Classification complete!")
|
85 |
return results
|
86 |
|
|
|
33 |
@spaces.GPU
|
34 |
def classify_abstracts(abstracts:Dict[str, str],batch_size=64, progress=gr.Progress()) -> None:
|
35 |
pipe = get_pipeline()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
36 |
|
37 |
# return classification
|
38 |
results = []
|
|
|
59 |
for pmid, classification in zip(batch_pmids, classifications):
|
60 |
results.append({
|
61 |
'pmid': pmid,
|
62 |
+
'classification': label_lookup[classification['label']],
|
63 |
'score': classification['score']
|
64 |
})
|
65 |
|
|
|
70 |
except Exception as e:
|
71 |
print(f"Error classifying batch starting at index {i}: {str(e)}")
|
72 |
continue
|
73 |
+
|
|
|
|
|
74 |
progress(1.0, desc="Classification complete!")
|
75 |
return results
|
76 |
|