Mercurial > repos > bgruening > json2yolosegment
diff yolov8.py @ 3:97bc82ee2a61 draft
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools commit 743c8acf1ea4e4b1e718743d3772b7e592646611
author | bgruening |
---|---|
date | Mon, 14 Jul 2025 18:28:46 +0000 |
parents | 158e6ce48345 |
children | f6990d85161c |
line wrap: on
line diff
--- a/yolov8.py Fri Jul 11 06:49:20 2025 +0000 +++ b/yolov8.py Mon Jul 14 18:28:46 2025 +0000 @@ -1,7 +1,6 @@ import argparse import os import pathlib -import shutil import time from argparse import RawTextHelpFormatter from collections import defaultdict @@ -175,15 +174,6 @@ # # Functions # - -def safe_rmtree(path): - try: - shutil.rmtree(path) - except OSError: - time.sleep(1) - shutil.rmtree(path, ignore_errors=True) - - # Train a new model on the dataset mentioned in yaml file def trainModel(model_path, model_name, yaml_filepath, **kwargs): if "imgsz" in kwargs: @@ -271,9 +261,6 @@ else: init_lr = 1.0 - train_save_path = os.path.expanduser('~/runs/' + args.mode + '/train/') - if os.path.isdir(train_save_path): - safe_rmtree(train_save_path) # Load a pretrained YOLO model (recommended for training) if args.model_format == 'pt': model = YOLO(os.path.join(model_path, model_name + "." + args.model_format)) @@ -291,10 +278,6 @@ # Validate the trained model def validateModel(model): - # Remove prediction save path if already exists - val_save_path = os.path.expanduser('~/runs/' + args.mode + '/val/') - if os.path.isdir(val_save_path): - safe_rmtree(val_save_path) # Validate the model metrics = model.val() # no args needed, dataset & settings remembered metrics.box.map # map50-95 @@ -330,13 +313,7 @@ else: maximum_detections = 300 - if "run_dir" in kwargs: - run_save_dir = kwargs['run_dir'] - else: - # Remove prediction save path if already exists - pred_save_path = os.path.expanduser('~/runs/' + args.mode + '/predict/') - if os.path.isdir(pred_save_path): - safe_rmtree(pred_save_path) + run_save_dir = kwargs['run_dir'] # For Galaxy, run_save_dir is always provided via xml wrapper if "foldername" in kwargs: save_folder_name = kwargs['foldername'] # infer on a local image or directory containing images/videos