Spaces:
Runtime error
Runtime error
| import gradio as gr | |
| from fastai.text.all import * | |
| # Load the trained model | |
| learn = load_learner("vehicle_classifier.pkl") | |
| # Define prediction function | |
| def classify_vehicle(text): | |
| pred, _, probs = learn.predict(text) | |
| return f"Prediction: {pred} (Confidence: {max(probs):.2f})" | |
| # Gradio interface | |
| demo = gr.Interface( | |
| fn=classify_vehicle, | |
| inputs=gr.Textbox(lines=2, placeholder="Enter vehicle description here..."), | |
| outputs="text", | |
| title="Vehicle Type Classifier", | |
| description="Enter a vehicle name or description to classify its type (e.g., car, truck, van, etc.)" | |
| ) | |
| # Launch the app | |
| demo.launch() | |