Spaces:
Sleeping
Sleeping
built interface commit
Browse files
app.py
CHANGED
|
@@ -1,7 +1,31 @@
|
|
| 1 |
import gradio as gr
|
|
|
|
|
|
|
| 2 |
|
| 3 |
-
|
| 4 |
-
return "Hello " + name + "!!"
|
| 5 |
|
| 6 |
-
|
| 7 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
+
import tensorflow as tf
|
| 3 |
+
import cv2
|
| 4 |
|
| 5 |
+
# Load your machine learning model that is trained to recognize car brands
|
|
|
|
| 6 |
|
| 7 |
+
|
| 8 |
+
# model = tf.keras.models.load_model("model.h5")
|
| 9 |
+
|
| 10 |
+
# Define the input and output interfaces for the Gradio interface
|
| 11 |
+
inputs = gr.inputs.Image()
|
| 12 |
+
outputs = gr.outputs.Textbox()
|
| 13 |
+
|
| 14 |
+
# Define the function that will be called when the user submits an image
|
| 15 |
+
def predict(image):
|
| 16 |
+
# Preprocess the image to be compatible with your model
|
| 17 |
+
image = cv2.resize(image, (224, 224))
|
| 18 |
+
image = image / 255.0
|
| 19 |
+
image = image.reshape(1, 224, 224, 3)
|
| 20 |
+
|
| 21 |
+
# Use the model to make a prediction
|
| 22 |
+
prediction = 'model.predict(image)'
|
| 23 |
+
|
| 24 |
+
# Return the predicted brand as a string
|
| 25 |
+
return "The brand of this car is: " + str(prediction)
|
| 26 |
+
|
| 27 |
+
# Create the Gradio interface
|
| 28 |
+
interface = gr.Interface(fn=predict, inputs=inputs, outputs=outputs, title="Car Brand Predictor")
|
| 29 |
+
|
| 30 |
+
# Display the interface
|
| 31 |
+
interface.launch()
|