b2u commited on
Commit
51dd92c
·
1 Parent(s): 43f685f
Files changed (1) hide show
  1. model.py +11 -1
model.py CHANGED
@@ -140,7 +140,17 @@ class T5Model(LabelStudioMLBase):
140
  logger.info(f"Additional kwargs: {kwargs}")
141
 
142
  predictions = []
143
- valid_choices = self.get_valid_choices(kwargs.get('label_config', ''))
 
 
 
 
 
 
 
 
 
 
144
 
145
  try:
146
  for task in tasks:
 
140
  logger.info(f"Additional kwargs: {kwargs}")
141
 
142
  predictions = []
143
+ # Get valid choices during initialization instead of from kwargs
144
+ valid_choices = []
145
+ try:
146
+ import xml.etree.ElementTree as ET
147
+ root = ET.fromstring(self.label_config)
148
+ choices = root.findall('.//Choice')
149
+ valid_choices = [choice.get('value') for choice in choices]
150
+ logger.info(f"Valid choices: {valid_choices}")
151
+ except Exception as e:
152
+ logger.error(f"Error parsing choices: {str(e)}")
153
+ valid_choices = ["no_category"] # fallback
154
 
155
  try:
156
  for task in tasks: