Start
13/04/2026
Close
∞
Iris Flower Classification Challenge
Classify iris flowers by species.
Challenge Rewards:
knowledgeParticipants
40
Submissions
23
Iris Flower Classification Model
Challenge participants: Build robust iris flower classification solutions.
Table of Contents
- Quick Start
- Introduction
- Requirements
- Project Structure
- Detailed Tutorial
- Submission Guidelines
- License
Quick Start
Clone the repository:
git clone [email protected]:AIOZAI/Iris_Flower_Model.git
or, download directly: Iris Flower Classification Baseline
Then, navigate into the project directory and follow the steps below:
# 1. Install dependencies (Do not add any other libraries to requirements.txt file)
pip install -r requirements.txt
# 2. Start developing your solution. Follow the tutorial below to implement your AI model
# 3. Run the demo to test your implementation
python demo.py
# 4. Verify Your Submission
python -m my_ai_lib.predict_submission
Note: You need to implement your iris flower classification solution following the tutorial guide.
Introduction
The Iris Flower Classification Challenge is a classic beginner-friendly ML project where you classify iris flowers into species based on their petals and sepals. Perfect for mastering the basics of supervised learning.
In this challenge, participants will be provided with:
-
Model Access: Iris Flower Classification Baseline
- Code baseline to develop solutions.
- Predefined libraries and tools in
requirements.txt(Do not add any other libraries to requirements.txt file).
-
Dataset Access: Iris Flower Dataset
- Training dataset to train your AI models.
- Testing dataset to predict labels for generating the submission file.
Goal: Classify iris flowers into species using petal/sepal measurements.
Requirements
System Requirements
- Python 3.10+
Dependencies
Install all required packages:
pip install -r requirements.txt
Project Structure
Your AI library should follow this structure:
repository/
├── my_ai_lib/ # Your AI library
│ ├── __init__.py # Required: Library initialization
│ ├── run.py # Required: Main workflow function
│ ├── predict_submission.py # Required: Submission function
│ └── [your_modules]/ # Your custom modules
├── models/ # Model weights directory
├── demo.py # Demo script
├── requirements.txt # Dependencies
└── README.md # Documentation
Key Components
| Component | Description | Status |
|---|---|---|
my_ai_lib/ | Core AI library directory | Required |
my_ai_lib/__init__.py | Library initialization | Required |
my_ai_lib/predict_submission.py | Generate predictions for challenge submission. | Required |
my_ai_lib/run.py | Main AI workflow | Required |
demo.py | Demo and testing script | Required |
Detailed Tutorial
Step 1: Initialize Your AI Library
1.1 Define my_ai_lib/__init__.py
from .run import run
This file exposes the run() function from run.py as an attribute of my_ai_lib, so you can call it as my_ai_lib.run().
1.2 Define Input/Output Objects in my_ai_lib/run.py
Create your custom input and output classes:
from pathlib import Path
from typing import Any, Union, Literal
from aioz_ainode_adapter.schemas import InputObject, OutputObject, FileObject
class IrisInput(InputObject):
# input_text is a comma-separated string representation of iris flower features
# (e.g., "5.1,3.5,1.4,0.2" for Sepal Length (cm), Sepal Width (cm), Petal Length (cm), Petal Width (cm))
input_text: str
class IrisOutput(OutputObject):
# species is the predicted iris flower species (setosa, versicolor, or virginica)
species: str
Step 2: Understanding AIOZ Schema Objects
The aioz_ainode_adapter library defines 3 core object types based on pydantic.BaseModel:
🔸 InputObject
Define the format for input when the AIOZ-AI-Node system sends to your AI library.
Default Parameters:
| Parameter | Type | Description |
|---|---|---|
device | Choice | Device for your model: ["cuda", "cpu", "gpu"] |
model_storage_directory | String | Directory containing model weights |
Important: Always use
model_storage_directoryfor model weight paths, as AIOZ-AI-Node will specify this location.
🔸 OutputObject
Define the format for output when your AI library sends to the AIOZ-AI-Node system.
🔸 FileObject
Define the format for the file, if your output has a file. This object has two fields:
| Field | Type | Description |
|---|---|---|
data | Choice | File data: io.BufferedReader, Path, or URL |
name | String | File name |
Example FileObject creation:
output_file = FileObject(data=open("file/path.csv", "rb"), name="output.csv")
Note:
- Input files must be local file paths or URLs
- Output files must be FileObject instances
Step 3: Implement the Main Workflow
3.1 Define Your AI Task Function
def do_ai_task(
input_text: str,
model_storage_directory: Union[str, Path],
device: Literal["cpu", "cuda", "gpu"] = "cpu",
*args, **kwargs) -> str:
"""
Classify iris flower species from petal/sepal measurements.
Args:
input_text: Comma-separated feature string
model_storage_directory: Path to directory containing trained model weights
device: Device to run inference on ("cpu", "cuda", or "gpu")
Returns:
species: Predicted iris species - "setosa", "versicolor", or "virginica"
"""
# 1. Parse features from input string
# features = [float(x) for x in input_text.split(",")]
# 2. Run prediction using your trained model
# species = model.predict([features])[0]
species = "virginica"
return species
3.2 Implement the Required run() Function
def run(input_obj: InputObject) -> OutputObject:
"""
Main entry point for the Iris Flower Classification library.
Args:
input_obj: Input object containing parameterized features
(e.g., input_text="5.1,3.5,1.4,0.2")
Returns:
output_obj: Object containing the predicted iris species
"""
try:
# Validate and parse input
iris_input = IrisInput.model_validate(input_obj.model_dump())
# Execute AI task
species = do_ai_task(
input_text=iris_input.input_text,
model_storage_directory=iris_input.model_storage_directory,
device=iris_input.device
)
# Create output object
output_obj = IrisOutput(species=species)
except Exception as e:
raise Exception(e)
return output_obj
Critical: The
run()function name is mandatory and cannot be changed. Thedo_ai_task()function can be renamed and customized.
Step 4: Create Demo Script
Create demo.py to test your implementation:
import my_ai_lib
from aioz_ainode_adapter.schemas import InputObject
def main():
"""Demo function to test the Iris Flower Classification library."""
# Example measurements:
# (Sepal Length (cm), Sepal Width (cm), Petal Length (cm), Petal Width (cm))
features = "5.1,3.5,1.4,0.2"
input_obj = InputObject(
input_text=features
)
output_obj = my_ai_lib.run(input_obj)
print(f"Output: {output_obj}")
if __name__ == '__main__':
main()
The my_ai_lib.run() function receives an InputObject and returns an OutputObject.
Run this command to test your implementation:
python demo.py
Expected console output:
Input: device='cpu' model_storage_directory='models' input_text='5.1,3.5,1.4,0.2'
Output: species='setosa'
Step 5: Add Model Weights
Place your trained model files in the models/ directory:
models/
├── model.pth # Your trained model
├── config.json # Model configuration
└── etc.
Step 6: Create Prediction Script (For Submission)
Implement the predict_submission() function in my_ai_lib/predict_submission.py
Requirements:
- Function accepting test data folder path (string)
- Load your trained model
- Process test dataset (test.csv in test data folder)
- Generate predictions
- Save results as
./result.csv
Implementation Template:
import os
import csv
from aioz_ainode_adapter.schemas import InputObject
import my_ai_lib
def predict_submission(test_data_folder: str):
"""
Generate predictions for challenge submission.
Args:
test_data_folder: Path to test data directory
"""
# TODO: Implement your prediction logic here
# Example:
# 1. Find test data (test.csv) in test data folder (using os.walk)
test_csv_path = os.path.join(test_data_folder, "test.csv")
if not os.path.exists(test_csv_path):
for root, _, files in os.walk(test_data_folder):
if "test.csv" in files:
test_csv_path = os.path.join(root, "test.csv")
break
results = []
# 2. Load model and predict on test dataset
with open(test_csv_path, "r") as f:
reader = csv.DictReader(f)
for row in reader:
features = ",".join([row['Sepal Length (cm)'], row['Sepal Width (cm)'],
row['Petal Length (cm)'], row['Petal Width (cm)']])
output_obj = my_ai_lib.run(InputObject(input_text=features))
results.append({"index": row["index"], "species": output_obj.species})
# 3. Save to ./result.csv
with open("./result.csv", "w", newline="") as f:
writer = csv.DictWriter(f, fieldnames=["index", "species"])
writer.writeheader()
writer.writerows(results)
print(f"Saved {len(results)} predictions to ./result.csv")
def main():
"""Main function for testing submission."""
predict_submission("path/to/test/data")
if __name__ == '__main__':
main()
Important: The
result.csvmust match the challenge's sample submission format.
Verify Your Submission:
python -m my_ai_lib.predict_submission
Submission Guidelines
Submission Format
The submission file has two fields:
- index: The unique identifier corresponding to each sample.
- species: The predicted label for the corresponding iris flower.
Example:
index,species
123,virginica
124,setosa
License
This repository is licensed under the MIT License.