Spaces:
Sleeping
Sleeping
debugging
Browse files
model.py
CHANGED
|
@@ -37,8 +37,28 @@ class BertClassifier(LabelStudioMLBase):
|
|
| 37 |
|
| 38 |
# Parse label config to get categories
|
| 39 |
from label_studio_ml.model import parse_config
|
| 40 |
-
|
| 41 |
-
logger.info(f"Parsed
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 42 |
|
| 43 |
# Load training configuration from environment variables with defaults
|
| 44 |
self.learning_rate = float(os.getenv('LEARNING_RATE', '2e-5'))
|
|
|
|
| 37 |
|
| 38 |
# Parse label config to get categories
|
| 39 |
from label_studio_ml.model import parse_config
|
| 40 |
+
parsed_config = parse_config(label_config)
|
| 41 |
+
logger.info(f"Parsed config: {parsed_config}")
|
| 42 |
+
|
| 43 |
+
# Extract categories from the parsed config
|
| 44 |
+
if not parsed_config:
|
| 45 |
+
raise ValueError("Label config parsing returned empty result")
|
| 46 |
+
|
| 47 |
+
# Find the first Choices tag in the config
|
| 48 |
+
choices_tag = None
|
| 49 |
+
for tag_name, tag_info in parsed_config.items():
|
| 50 |
+
if tag_info.get('type') == 'Choices':
|
| 51 |
+
choices_tag = tag_info
|
| 52 |
+
break
|
| 53 |
+
|
| 54 |
+
if not choices_tag:
|
| 55 |
+
raise ValueError("No Choices tag found in label config")
|
| 56 |
+
|
| 57 |
+
self.categories = choices_tag.get('values', [])
|
| 58 |
+
if not self.categories:
|
| 59 |
+
raise ValueError("No categories found in label config")
|
| 60 |
+
|
| 61 |
+
logger.info(f"Found categories: {self.categories}")
|
| 62 |
|
| 63 |
# Load training configuration from environment variables with defaults
|
| 64 |
self.learning_rate = float(os.getenv('LEARNING_RATE', '2e-5'))
|