Spaces:
Running
Running
ZeroCommand
commited on
Commit
•
0fbc450
1
Parent(s):
9f91529
clean code
Browse files- text_classification.py +2 -4
text_classification.py
CHANGED
@@ -22,16 +22,14 @@ class HuggingFaceInferenceAPIResponse:
|
|
22 |
def get_labels_and_features_from_dataset(ds):
|
23 |
try:
|
24 |
dataset_features = ds.features
|
25 |
-
label_keys = [i for i in dataset_features.keys() if i
|
26 |
features = [f for f in dataset_features.keys() if not f.startswith("label")]
|
27 |
-
if len(label_keys) == 0: # no labels found
|
28 |
-
label_keys = [i for i in dataset_features.keys() if i.startswith('label')]
|
29 |
|
30 |
if len(label_keys) == 0: # no labels found
|
31 |
# return everything for post processing
|
32 |
return list(dataset_features.keys()), list(dataset_features.keys()), None
|
33 |
if not isinstance(dataset_features[label_keys[0]], datasets.ClassLabel):
|
34 |
-
if hasattr(dataset_features[label_keys[0]],
|
35 |
label_feat = dataset_features[label_keys[0]].feature
|
36 |
labels = label_feat.names
|
37 |
else:
|
|
|
22 |
def get_labels_and_features_from_dataset(ds):
|
23 |
try:
|
24 |
dataset_features = ds.features
|
25 |
+
label_keys = [i for i in dataset_features.keys() if i.startswith("label")]
|
26 |
features = [f for f in dataset_features.keys() if not f.startswith("label")]
|
|
|
|
|
27 |
|
28 |
if len(label_keys) == 0: # no labels found
|
29 |
# return everything for post processing
|
30 |
return list(dataset_features.keys()), list(dataset_features.keys()), None
|
31 |
if not isinstance(dataset_features[label_keys[0]], datasets.ClassLabel):
|
32 |
+
if hasattr(dataset_features[label_keys[0]], "feature"):
|
33 |
label_feat = dataset_features[label_keys[0]].feature
|
34 |
labels = label_feat.names
|
35 |
else:
|