本地MacOS环境运行Azure AutoML图像分类遇EmptyDataException错误
Looks like the issue here is that Azure AutoML isn't correctly parsing your image dataset from the training_data parameter. Even though you've structured your DataFrame with image arrays and labels, for image tasks, you need to explicitly separate your features (X) and label (y) instead of relying solely on the training_data argument. Here's how to fix this step by step:
1. Explicitly Split Features and Label
Your DataFrame has np_image (image arrays) and y (labels) columns. Pull these out into separate variables and pass them directly to AutoMLConfig using X and y parameters instead of training_data:
# Split your DataFrame into features and label X = train_data_img[["np_image"]] y = train_data_img["y"] # Update your AutoMLConfig automl_classifier = AutoMLConfig( task='classification', primary_metric='AUC_weighted', experiment_timeout_minutes=5, blocked_models=['XGBoostClassifier'], X=X, # Pass feature DataFrame here y=y, # Pass label series here n_cross_validations=2 )
2. Verify Image Data Consistency
Azure AutoML requires all image features to have the same dimensions. Double-check that every array in your np_image column is shaped correctly for color images (256x256x3):
# Validate image shapes assert all(img.shape == (256, 256, 3) for img in train_data_img["np_image"]), "All images must be 256x256x3"
3. Fix Variable Name Mismatch
In your original code, you defined the config as automl_classifier but tried to submit automl_config—this would throw a NameError once you fix the data issue. Make sure the variable names match when submitting the experiment:
# Use the correct config variable name run = experiment.submit(automl_classifier, show_output=True)
Why This Works
The EmptyDataException occurs because AutoML can't automatically extract image features from the full training_data DataFrame. By explicitly passing X (which holds your image arrays) and y (your labels), you're giving AutoML clear guidance on which data to use for training.
内容的提问来源于stack exchange,提问作者Baenka

