Spaces:
Runtime error
Runtime error
Upload app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
+
from fastai.text.all import *
|
| 3 |
+
|
| 4 |
+
# Load the trained model
|
| 5 |
+
learn = load_learner("vehicle_classifier.pkl")
|
| 6 |
+
|
| 7 |
+
# Define prediction function
|
| 8 |
+
def classify_vehicle(text):
|
| 9 |
+
pred, _, probs = learn.predict(text)
|
| 10 |
+
return f"Prediction: {pred} (Confidence: {max(probs):.2f})"
|
| 11 |
+
|
| 12 |
+
# Gradio interface
|
| 13 |
+
demo = gr.Interface(
|
| 14 |
+
fn=classify_vehicle,
|
| 15 |
+
inputs=gr.Textbox(lines=2, placeholder="Enter vehicle description here..."),
|
| 16 |
+
outputs="text",
|
| 17 |
+
title="Vehicle Type Classifier",
|
| 18 |
+
description="Enter a vehicle name or description to classify its type (e.g., car, truck, van, etc.)"
|
| 19 |
+
)
|
| 20 |
+
|
| 21 |
+
# Launch the app
|
| 22 |
+
demo.launch()
|