mirror of
https://github.com/azaion/ai-training.git
synced 2026-04-22 22:56:34 +00:00
3fd726f9c7
add train some catches
23 lines
698 B
Python
23 lines
698 B
Python
import json
|
|
from os.path import dirname, join
|
|
|
|
|
|
class AnnotationClass:
|
|
def __init__(self, id, name, color):
|
|
self.id = id
|
|
self.name = name
|
|
self.color = color
|
|
|
|
@staticmethod
|
|
def read_json():
|
|
classes_path = join(dirname(dirname(__file__)), 'classes.json')
|
|
with open(classes_path, 'r', encoding='utf-8') as f:
|
|
j = json.loads(f.read())
|
|
return {cl['Id']: AnnotationClass(id=cl['Id'], name=cl['Name'], color=cl['Color']) for cl in j}
|
|
|
|
@property
|
|
def color_tuple(self):
|
|
color = self.color[3:]
|
|
lv = len(color)
|
|
xx = range(0, lv, lv // 3)
|
|
return tuple(int(color[i:i + lv // 3], 16) for i in xx) |