mirror of
https://github.com/azaion/ai-training.git
synced 2026-04-22 12:16:35 +00:00
add rknn conversion - install and use scripts, auto convert to rknn after AI training is done and put pt and rknn models to /azaion/models directory
This commit is contained in:
+26
-21
@@ -116,30 +116,35 @@ def process_image(img_ann):
|
||||
))
|
||||
|
||||
|
||||
def main():
|
||||
def preprocess_annotations():
|
||||
os.makedirs(processed_images_dir, exist_ok=True)
|
||||
os.makedirs(processed_labels_dir, exist_ok=True)
|
||||
while True:
|
||||
processed_images = set(f.name for f in os.scandir(processed_images_dir))
|
||||
images = []
|
||||
with os.scandir(data_images_dir) as imd:
|
||||
for image_file in imd:
|
||||
if image_file.is_file() and image_file.name not in processed_images:
|
||||
images.append(image_file)
|
||||
|
||||
for image_file in images:
|
||||
try:
|
||||
image_path = os.path.join(data_images_dir, image_file.name)
|
||||
labels_path = os.path.join(data_labels_dir, f'{Path(image_path).stem}.txt')
|
||||
image = cv2.imdecode(np.fromfile(image_path, dtype=np.uint8), cv2.IMREAD_UNCHANGED)
|
||||
process_image(ImageLabel(
|
||||
image_path=image_path,
|
||||
image=image,
|
||||
labels_path=labels_path,
|
||||
labels=read_labels(labels_path)
|
||||
))
|
||||
except Exception as e:
|
||||
print(f'Error appeared {e}')
|
||||
processed_images = set(f.name for f in os.scandir(processed_images_dir))
|
||||
images = []
|
||||
with os.scandir(data_images_dir) as imd:
|
||||
for image_file in imd:
|
||||
if image_file.is_file() and image_file.name not in processed_images:
|
||||
images.append(image_file)
|
||||
|
||||
for image_file in images:
|
||||
try:
|
||||
image_path = os.path.join(data_images_dir, image_file.name)
|
||||
labels_path = os.path.join(data_labels_dir, f'{Path(image_path).stem}.txt')
|
||||
image = cv2.imdecode(np.fromfile(image_path, dtype=np.uint8), cv2.IMREAD_UNCHANGED)
|
||||
process_image(ImageLabel(
|
||||
image_path=image_path,
|
||||
image=image,
|
||||
labels_path=labels_path,
|
||||
labels=read_labels(labels_path)
|
||||
))
|
||||
except Exception as e:
|
||||
print(f'Error appeared {e}')
|
||||
|
||||
|
||||
def main():
|
||||
while True:
|
||||
preprocess_annotations()
|
||||
print('All processed, waiting for 2 minutes...')
|
||||
time.sleep(120)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user