Spaces:
Running
Running
ZeroCommand
commited on
Commit
•
104fec1
1
Parent(s):
3025552
add warning component
Browse files- text_classification_ui_helpers.py +3 -4
- wordings.py +6 -0
text_classification_ui_helpers.py
CHANGED
@@ -12,7 +12,7 @@ from io_utils import (get_yaml_path, read_column_mapping, save_job_to_pipe,
|
|
12 |
write_column_mapping, write_log_to_user_file)
|
13 |
from text_classification import (check_model, get_example_prediction,
|
14 |
get_labels_and_features_from_dataset)
|
15 |
-
from wordings import CONFIRM_MAPPING_DETAILS_FAIL_RAW
|
16 |
|
17 |
MAX_LABELS = 20
|
18 |
MAX_FEATURES = 20
|
@@ -133,7 +133,7 @@ def check_model_and_show_prediction(
|
|
133 |
if not isinstance(ds_labels, list) or not isinstance(ds_features, list):
|
134 |
# gr.Warning(CONFIRM_MAPPING_DETAILS_FAIL_RAW)
|
135 |
return (
|
136 |
-
gr.update(visible=
|
137 |
gr.update(visible=False),
|
138 |
gr.update(visible=False, open=False),
|
139 |
*dropdown_placement,
|
@@ -151,9 +151,8 @@ def check_model_and_show_prediction(
|
|
151 |
collections.Counter(model_id2label.values()) != collections.Counter(ds_labels)
|
152 |
or ds_features[0] != "text"
|
153 |
):
|
154 |
-
gr.Warning(CONFIRM_MAPPING_DETAILS_FAIL_RAW)
|
155 |
return (
|
156 |
-
gr.update(visible=
|
157 |
gr.update(visible=False),
|
158 |
gr.update(visible=True, open=True),
|
159 |
*column_mappings,
|
|
|
12 |
write_column_mapping, write_log_to_user_file)
|
13 |
from text_classification import (check_model, get_example_prediction,
|
14 |
get_labels_and_features_from_dataset)
|
15 |
+
from wordings import CONFIRM_MAPPING_DETAILS_FAIL_RAW, MAPPING_STYLED_ERROR_WARNING
|
16 |
|
17 |
MAX_LABELS = 20
|
18 |
MAX_FEATURES = 20
|
|
|
133 |
if not isinstance(ds_labels, list) or not isinstance(ds_features, list):
|
134 |
# gr.Warning(CONFIRM_MAPPING_DETAILS_FAIL_RAW)
|
135 |
return (
|
136 |
+
gr.update(value=MAPPING_STYLED_ERROR_WARNING, visible=True),
|
137 |
gr.update(visible=False),
|
138 |
gr.update(visible=False, open=False),
|
139 |
*dropdown_placement,
|
|
|
151 |
collections.Counter(model_id2label.values()) != collections.Counter(ds_labels)
|
152 |
or ds_features[0] != "text"
|
153 |
):
|
|
|
154 |
return (
|
155 |
+
gr.update(value=MAPPING_STYLED_ERROR_WARNING, visible=True),
|
156 |
gr.update(visible=False),
|
157 |
gr.update(visible=True, open=True),
|
158 |
*column_mappings,
|
wordings.py
CHANGED
@@ -27,3 +27,9 @@ PREDICTION_SAMPLE_MD = """
|
|
27 |
</h1>
|
28 |
Here is a sample prediction from your model based on your dataset.
|
29 |
"""
|
|
|
|
|
|
|
|
|
|
|
|
|
|
27 |
</h1>
|
28 |
Here is a sample prediction from your model based on your dataset.
|
29 |
"""
|
30 |
+
|
31 |
+
MAPPING_STYLED_ERROR_WARNING = """
|
32 |
+
<h3 style="text-align: center;color: coral; background-color: #fff0f3; border-radius: 8px; padding: 10px; ">
|
33 |
+
Sorry, we cannot auto-align the labels/features of your dataset and model. Please double check.
|
34 |
+
</h3>
|
35 |
+
"""
|