Skip to content

Commit d6ff94b

Browse files
committed
Fix
1 parent 280b741 commit d6ff94b

File tree

1 file changed

+6
-1
lines changed
  • label_studio_ml/examples/timeseries_segmenter

1 file changed

+6
-1
lines changed

label_studio_ml/examples/timeseries_segmenter/model.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
33
This example shows a very small yet functional ML backend that trains a
44
classifier on labeled time series CSV files and predicts segments for new
5-
tasks. The logic is intentionally simple so that it can serve as a starting
5+
tasks. The logic is intentionally simple so that it can serve as a starting
66
point for your own experiments.
77
"""
88

@@ -46,6 +46,7 @@ def _get_model(self, blank: bool = False) -> LogisticRegression:
4646
global _model
4747
if _model is not None and not blank:
4848
return _model
49+
4950
model_path = os.path.join(self.MODEL_DIR, "model.pkl")
5051
if not blank and os.path.exists(model_path):
5152
with open(model_path, "rb") as f:
@@ -158,7 +159,9 @@ def _collect_samples(self, tasks: List[Dict], params: Dict, label2idx: Dict[str,
158159
df = self._read_csv(task, task['data'][params['value']])
159160
if df.empty:
160161
continue
162+
161163
annotations = [a for a in task['annotations'] if a.get('result')]
164+
162165
for ann in annotations:
163166
for r in ann['result']:
164167
if r['from_name'] != params['from_name']:
@@ -209,12 +212,14 @@ def fit(self, event, data, **kwargs):
209212
):
210213
logger.info("Skip training: event %s is not supported", event)
211214
return
215+
212216
project_id = data['annotation']['project']
213217
tasks = self._get_tasks(project_id)
214218
if len(tasks) % self.START_TRAINING_EACH_N_UPDATES != 0 and event != 'START_TRAINING':
215219
logger.info(
216220
f'Skip training: {len(tasks)} tasks are not multiple of {self.START_TRAINING_EACH_N_UPDATES}')
217221
return
222+
218223
params = self._get_labeling_params()
219224
label2idx = {l: i for i, l in enumerate(params['labels'])}
220225

0 commit comments

Comments
 (0)