PlantDiseaseTreatmentAssistant / run_huggingface_training.py
iqramukhtiar's picture
Upload 3 files
78446ba verified
raw
history blame
1.67 kB
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 ===")
# First, check if the datasets library is installed
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)
# Step 1: Download the PlantVillage dataset from Hugging Face
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)
# Step 2: Train the model
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()