Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -2,12 +2,12 @@
|
|
| 2 |
from gradio import Interface, Image, Label
|
| 3 |
import tensorflow as tf
|
| 4 |
# Load your TensorFlow model
|
| 5 |
-
model = tf.keras.models.load_model("
|
| 6 |
|
| 7 |
# Define your class names if needed
|
| 8 |
class_names = ['Asian-Green-Bee-Eater', 'Brown-Headed-Barbet', 'Cattle-Egret', 'Common-Kingfisher', 'Common-Myna', 'House-Crow', 'Indian-Grey-Hornbill', 'Indian-Peacock', 'Indian-Roller', 'White-Breasted-Kingfisher']
|
| 9 |
|
| 10 |
-
|
| 11 |
# Function to make predictions
|
| 12 |
def classify_image(image):
|
| 13 |
# Preprocess the image
|
|
@@ -15,7 +15,7 @@ def classify_image(image):
|
|
| 15 |
img = tf.expand_dims(img, 0) # Add batch dimension
|
| 16 |
# Make prediction
|
| 17 |
prediction = model.predict(img)
|
| 18 |
-
predicted_class =
|
| 19 |
return predicted_class
|
| 20 |
|
| 21 |
# Gradio interface
|
|
@@ -24,5 +24,5 @@ label = Label()
|
|
| 24 |
|
| 25 |
# Create interface
|
| 26 |
interface = Interface(classify_image, image, label,
|
| 27 |
-
title="
|
| 28 |
-
description="Upload an image of a
|
|
|
|
| 2 |
from gradio import Interface, Image, Label
|
| 3 |
import tensorflow as tf
|
| 4 |
# Load your TensorFlow model
|
| 5 |
+
model = tf.keras.models.load_model("traffic.h5")
|
| 6 |
|
| 7 |
# Define your class names if needed
|
| 8 |
class_names = ['Asian-Green-Bee-Eater', 'Brown-Headed-Barbet', 'Cattle-Egret', 'Common-Kingfisher', 'Common-Myna', 'House-Crow', 'Indian-Grey-Hornbill', 'Indian-Peacock', 'Indian-Roller', 'White-Breasted-Kingfisher']
|
| 9 |
|
| 10 |
+
Class_names=['15 kmph', '18', '19', '30 kmph', '4 weehler', '40 kmph', '5 kmp only', '50 kmph', '51', '52', '53', '56', '57', '60 kmph', '70 kmph', '8', '80 kmph', '9', 'bicycle', 'chemical caution', 'cycle lane', 'dead end', 'go a ahead', 'home zone', 'horn', 'left dent curve', 'left service road', 'no 4-wheeler', 'no entry', 'no horn', 'no left turn', 'no over cross', 'no right and left turn', 'no right turn', 'no stopping and standing', 'no u-turn', 'proceed straight or turn right', 'railway gate', 'railway station', 'right service road', 'right v-dent curve', 'ring road', 'school zone', 'series of bends', 'side road left', 'side road right', 'sidewalk intersection', 'sland', 'traffic lights', 'turn left', 'turn right', 'turn right or left', 'u-turn', 'uphill', 'v-cuts', 'working area', 'zebra-crossing']
|
| 11 |
# Function to make predictions
|
| 12 |
def classify_image(image):
|
| 13 |
# Preprocess the image
|
|
|
|
| 15 |
img = tf.expand_dims(img, 0) # Add batch dimension
|
| 16 |
# Make prediction
|
| 17 |
prediction = model.predict(img)
|
| 18 |
+
predicted_class = Class_names[prediction.argmax()]
|
| 19 |
return predicted_class
|
| 20 |
|
| 21 |
# Gradio interface
|
|
|
|
| 24 |
|
| 25 |
# Create interface
|
| 26 |
interface = Interface(classify_image, image, label,
|
| 27 |
+
title="traffic sign detection ",
|
| 28 |
+
description="Upload an image of a traffic sign to classify its sign. ").launch()
|