mirror of
https://github.com/azaion/ai-training.git
synced 2026-04-22 22:56:34 +00:00
36 lines
1.0 KiB
Python
36 lines
1.0 KiB
Python
import json
|
|
from enum import Enum
|
|
from os.path import dirname, join
|
|
|
|
|
|
class WeatherMode(Enum):
|
|
Norm = 0
|
|
Wint = 20
|
|
Night = 40
|
|
|
|
|
|
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())
|
|
annotations_dict = {}
|
|
for mode in WeatherMode:
|
|
for cl in j:
|
|
id = mode.value + cl['Id']
|
|
name = cl['Name'] if mode.value == 0 else f'{cl["Name"]}({mode.name})'
|
|
annotations_dict[id] = AnnotationClass(id, name, cl['Color'])
|
|
return annotations_dict
|
|
|
|
@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) |