import gradio as gr from transformers import pipeline import datetime # Load the Hugging Face model for weather prediction model = pipeline("text-classification", model="nlptown/bert-base-multilingual-uncased-sentiment") def predict_weather(description): # Use the Hugging Face model to predict the weather sentiment prediction = model(description)[0] # Map the sentiment prediction to weather categories if prediction['label'] == 'positive': weather = 'Sunny' elif prediction['label'] == 'negative': weather = 'Rainy' else: weather = 'Neutral' # Calculate tomorrow's date tomorrow = datetime.date.today() + datetime.timedelta(days=1) # Return the predicted weather and tomorrow's date return weather, tomorrow # Define the input field for the Gradio interface description_input = gr.inputs.Textbox(label="Weather Description") # Define the output fields for the Gradio interface weather_output = gr.outputs.Textbox(label="Predicted Weather") date_output = gr.outputs.Textbox(label="Tomorrow's Date") # Create the Gradio interface interface = gr.Interface(fn=predict_weather, inputs=description_input, outputs=[weather_output, date_output], title="Tomorrow's Weather Prediction", description="Predict tomorrow's weather based on description.") # Launch the Gradio interface interface.launch()