|
|
import os |
|
|
import sys |
|
|
|
|
|
def main(): |
|
|
""" |
|
|
Main script to run the training process using the Hugging Face dataset. |
|
|
""" |
|
|
print("=== Plant Disease Model Training with Hugging Face Dataset ===") |
|
|
|
|
|
|
|
|
try: |
|
|
import datasets |
|
|
print("Hugging Face datasets library is installed.") |
|
|
except ImportError: |
|
|
print("Error: Hugging Face datasets library is not installed.") |
|
|
print("Installing required packages...") |
|
|
os.system("pip install datasets") |
|
|
print("Please run this script again after installation.") |
|
|
sys.exit(1) |
|
|
|
|
|
|
|
|
print("\nStep 1: Downloading dataset from Hugging Face") |
|
|
try: |
|
|
import download_huggingface_dataset |
|
|
success = download_huggingface_dataset.download_plantvillage_from_huggingface() |
|
|
if success: |
|
|
print("Dataset downloaded successfully from Hugging Face") |
|
|
else: |
|
|
print("Failed to download dataset from Hugging Face") |
|
|
sys.exit(1) |
|
|
except Exception as e: |
|
|
print(f"Error during dataset download: {e}") |
|
|
sys.exit(1) |
|
|
|
|
|
|
|
|
print("\nStep 2: Training model with Hugging Face dataset") |
|
|
try: |
|
|
import train_huggingface_model |
|
|
train_huggingface_model.train_model_with_huggingface_data() |
|
|
except Exception as e: |
|
|
print(f"Error during model training: {e}") |
|
|
sys.exit(1) |
|
|
|
|
|
print("\nTraining completed successfully!") |
|
|
print("You can now run the application with 'python app.py'") |
|
|
|
|
|
if __name__ == "__main__": |
|
|
main() |
|
|
|