Replies: 6 comments 5 replies
-
@clstaudt hi there, Thank you for reaching out and providing detailed information about the issue you're encountering with augmentation settings in YOLOv8. Let's address this step-by-step to ensure we can resolve the problem effectively. Verify VersionsFirst, please ensure that you are using the latest versions of both pip install --upgrade torch ultralytics Minimum Reproducible ExampleTo better assist you, could you please provide a minimum reproducible code example? This will help us replicate the issue on our end and investigate further. You can refer to our guide on creating a minimum reproducible example here: Minimum Reproducible Example. Augmentation SettingsIt seems like you've made a good attempt to disable augmentations by setting the parameters in your
Additional Checks
If the issue persists after these steps, please share the minimum reproducible code example, and we’ll be happy to dive deeper into the problem. Thank you for your patience, and we look forward to resolving this for you! |
Beta Was this translation helpful? Give feedback.
-
@glenn-jocher
path: /path/to/YOLO_Data_CuvetteClassifier
train: /path/to/YOLO_Data_CuvetteClassifier/train
val: /path/to/YOLO_Data_CuvetteClassifier/val
nc: 2
names: ['stable', 'unstable']
hsv_h: 0.0
hsv_s: 0.0
hsv_v: 0.0
degrees: 0.0
translate: 0.0
scale: 0.0
shear: 0.0
perspective: 0.0
flipud: 0.0
fliplr: 0.0
mosaic: false
mixup: false The augmentation parameters are definitely being ignore, silently, and I cannot see why:
|
Beta Was this translation helpful? Give feedback.
-
@glenn-jocher I have a question: The documentation states that for classification I should use base_model = "yolov8n-cls.pt"
self.model = ultralytics.YOLO(base_model, task="classify") since this is pretrained on ImageNet. That's different from your example, is it still correct? Could you maybe provide an MWE specifically for classification fine-tuning that I can check my code against? |
Beta Was this translation helpful? Give feedback.
-
@glenn-jocher I am unable to reproduce your MWE. Something seems to be wrong with the dataset. However, I triple-checked that it conforms to your example. YOLO attempts to download a dataset, which doesn't make sense. There seems to be confusion about whether the dataset path should point to a folder or to the This is the error I am seeing:
My data.yaml file: path: /path/to/project/data/Lumifuge/Photos/YOLO_Data_CuvetteClassifier
train: train/images
val: val/images
test: test/images
nc: 2
names: ['stable', 'unstable'] The model training code: class CuvetteClassifier:
"""
Classifies lab cuvette images using a fine-tuned YOLOv8 model.
"""
base_model = "yolov8n-cls.pt"
def __init__(self, model_path=None, model_img_size=640, device="mps", project_path=None):
"""
Initializes the CuvetteClassifier.
:param model_path: path to the pre-trained model file
:param model_img_size: input size for the model images
:param device: computation device ('cpu', 'cuda', or 'mps')
"""
self.model_img_size = model_img_size
self.device = device
self.model = None
if model_path:
self.model = ultralytics.YOLO(model_path, task="classify")
else:
logger.info(
f"No model path provided, downloading base model {CuvetteClassifier.base_model}"
)
self.model = ultralytics.YOLO(CuvetteClassifier.base_model, task="classify")
if project_path:
self.project_path = project_path
else:
self.project_path = "runs/train"
def train(self, dataset_path, n_epochs=16):
"""
Fine-tunes the YOLOv8 model on the provided dataset for classification.
:param dataset_path: path to the dataset directory
:param n_epochs: number of epochs to train the model
"""
dataset_path = Path(dataset_path).resolve()
data_config_path = dataset_path / "data.yaml"
if not self.model:
logger.error("Model is not loaded. Please provide a valid model path.")
raise ValueError("Model is not loaded. Please provide a valid model path.")
logger.info(f"Training model at {dataset_path} for {n_epochs} epochs.")
self.model.train(
data=data_config_path,
imgsz=self.model_img_size,
epochs=n_epochs,
device=self.device,
project=self.project_path,
name=f"cuvette_classification-{datetime.datetime.now().strftime('%Y%m%d-%H%M')}",
exist_ok=True,
hsv_h=0.0,
hsv_s=0.0,
hsv_v=0.0,
degrees=0.0,
translate=0.0,
scale=0.0,
shear=0.0,
perspective=0.0,
flipud=0.0,
fliplr=0.0,
mosaic=False,
mixup=False,
) yolo_dataset_dir = data_dir / "Lumifuge" / "Photos" / "YOLO_Data_CuvetteClassifier"
classifier = CuvetteClassifier()
classifier.train(
dataset_path=yolo_dataset_dir.resolve(),
n_epochs=8
) |
Beta Was this translation helpful? Give feedback.
-
@glenn-jocher If I pass the dataset folder path (not the path to the |
Beta Was this translation helpful? Give feedback.
-
@glenn-jocher What is it with the ChatGPT-generated answers? This might be good as first-level support, but at this point I'd rather have a human response. |
Beta Was this translation helpful? Give feedback.
-
Hi all, I am using YOLOv8 for classification. When I look at the training image output it seems that various augmentations are applied:
In particular, the image is cut to a central part, also sheared and occluded with black boxes etc.
Unfortunately this is counterproductive for my classification problem. I want to pass the images as they are for now.
The
args.yaml
confirm that the augmentation args are not all set to 0.After much trial & error I was unable to deactivate augmentation by setting all augmentation params to 0.
data.yaml
:This is ignored.
model.train
.They were ignored.
What am I doing wrong?
Beta Was this translation helpful? Give feedback.
All reactions