File size: 3,018 Bytes
fa49101
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
"""

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()