dupthotshering commited on
Commit
c4ce074
·
verified ·
1 Parent(s): cd1fcc9

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +25 -0
app.py ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from transformers import pipeline
3
+
4
+ # Load the image classification model
5
+ pipe = pipeline("image-classification", model="SriramSridhar78/sriram-car-classifier")
6
+
7
+ # Define the prediction function
8
+ def predict(input_img):
9
+ predictions = pipe(input_img)
10
+ return input_img, {p["label"]: p["score"] for p in predictions}
11
+
12
+ # Create Gradio UI
13
+ gradio_app = gr.Interface(
14
+ fn=predict,
15
+ inputs=gr.Image(label="Upload Car Image", sources=['upload', 'webcam'], type="pil"),
16
+ outputs=[
17
+ gr.Image(label="Processed Image"),
18
+ gr.Label(label="Car Model Type", num_top_classes=3)
19
+ ],
20
+ title="Car Classifier",
21
+ description="Upload an image of a car and get the predicted class"
22
+ )
23
+
24
+ # Launch the Gradio app
25
+ gradio_app.launch()