Spaces:
Running
Running
final model
Browse files- .ipynb_checkpoints/classifier-checkpoint.ipynb +0 -0
- app.py +5 -10
- classifier.ipynb +0 -0
.ipynb_checkpoints/classifier-checkpoint.ipynb
CHANGED
The diff for this file is too large to render.
See raw diff
|
|
app.py
CHANGED
@@ -2,20 +2,14 @@ import gradio as gr
|
|
2 |
import numpy as np
|
3 |
|
4 |
# Load a pre-trained image classification model
|
5 |
-
|
6 |
|
7 |
# Function to make predictions from an image
|
8 |
def classify_image(image):
|
9 |
-
# Resize the image to the required input size of the model
|
10 |
-
|
11 |
-
# Preprocess the image to match the model's requirements
|
12 |
-
|
13 |
# Make a prediction
|
14 |
-
|
15 |
# Decode the prediction and get the class name
|
16 |
-
|
17 |
-
|
18 |
-
return classes[class_name]
|
19 |
|
20 |
# Sample images for user to choose from
|
21 |
sample_images = ["AcuraTLType-S2008.jpg", "AudiR8Coupe2012.jpg", "DodgeMagnumWagon2008.jpg"]
|
@@ -25,7 +19,8 @@ iface = gr.Interface(
|
|
25 |
inputs=gr.Image(label="Select an image", type="filepath"),
|
26 |
outputs="text",
|
27 |
live=True,
|
28 |
-
title="
|
|
|
29 |
examples=sample_images
|
30 |
)
|
31 |
|
|
|
2 |
import numpy as np
|
3 |
|
4 |
# Load a pre-trained image classification model
|
5 |
+
learn = load_learner('models/model.pth')
|
6 |
|
7 |
# Function to make predictions from an image
|
8 |
def classify_image(image):
|
|
|
|
|
|
|
|
|
9 |
# Make a prediction
|
|
|
10 |
# Decode the prediction and get the class name
|
11 |
+
name = learn.predict(image)
|
12 |
+
return name[0]
|
|
|
13 |
|
14 |
# Sample images for user to choose from
|
15 |
sample_images = ["AcuraTLType-S2008.jpg", "AudiR8Coupe2012.jpg", "DodgeMagnumWagon2008.jpg"]
|
|
|
19 |
inputs=gr.Image(label="Select an image", type="filepath"),
|
20 |
outputs="text",
|
21 |
live=True,
|
22 |
+
title="Car image classifier",
|
23 |
+
description="Upload a car image or select one of the examples below"
|
24 |
examples=sample_images
|
25 |
)
|
26 |
|
classifier.ipynb
CHANGED
The diff for this file is too large to render.
See raw diff
|
|