budijuarto's picture
Deploy Indonesian Herbal Plants Classifier
fa49101 verified
"""
Main script to run the complete pipeline
Training -> Evaluation -> Visualization -> Gradio -> Hugging Face
"""
import sys
from pathlib import Path
# Add src to path
sys.path.insert(0, str(Path(__file__).parent))
import config
from dataset import create_data_loaders
from trainer import train_all_models
from evaluator import evaluate_all_models
def main():
"""Run the complete training and evaluation pipeline"""
print("""
╔══════════════════════════════════════════════════════════════════╗
β•‘ β•‘
β•‘ 🌿 INDONESIAN HERBAL PLANTS CLASSIFICATION 🌿 β•‘
β•‘ β•‘
β•‘ 5 State-of-the-Art Deep Learning Models (2025) β•‘
β•‘ - YOLOv11 Classification β•‘
β•‘ - EfficientNetV2-S β•‘
β•‘ - ConvNeXt V2 β•‘
β•‘ - Vision Transformer (ViT) β•‘
β•‘ - Hybrid CNN + ViT (CoAtNet-style) β•‘
β•‘ β•‘
β•šβ•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•
""")
print(f"\nπŸ“ Base Directory: {config.BASE_DIR}")
print(f"πŸ“ Data Directory: {config.DATA_DIR}")
print(f"πŸ“ Output Directory: {config.OUTPUT_DIR}")
print(f"πŸ–₯️ Device: {config.DEVICE}")
# Step 1: Train all models
print("\n" + "="*70)
print("STEP 1: TRAINING ALL MODELS")
print("="*70)
training_results, test_loader, class_names = train_all_models()
# Step 2: Evaluate all models
print("\n" + "="*70)
print("STEP 2: EVALUATING ALL MODELS")
print("="*70)
all_metrics = evaluate_all_models(test_loader, class_names, training_results)
# Step 3: Summary
print("\n" + "="*70)
print("PIPELINE COMPLETED!")
print("="*70)
print(f"\nπŸ“Š Results saved to: {config.OUTPUT_DIR}")
print(f"πŸ“ˆ Plots saved to: {config.PLOTS_DIR}")
print(f"πŸ€– Models saved to: {config.MODELS_DIR}")
print("\nπŸ“ Next Steps:")
print(" 1. Run Gradio interface:")
print(f" python {config.BASE_DIR}/src/app.py")
print("\n 2. Push to Hugging Face:")
print(f" python {config.BASE_DIR}/src/huggingface_upload.py --username YOUR_USERNAME --token YOUR_TOKEN")
return training_results, all_metrics
if __name__ == "__main__":
training_results, all_metrics = main()