YosuNamgay commited on
Commit
d373bb3
·
verified ·
1 Parent(s): 6068bb6

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +22 -0
app.py ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from transformers import pipeline
3
+
4
+ # Load the car 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 the Gradio interface
13
+ gradio_app = gr.Interface(
14
+ fn=predict,
15
+ inputs=gr.Image(label="Upload Car Image", sources=['upload', 'webcam'], type="pil"),
16
+ outputs=[gr.Image(label="Processed Image"), gr.Label(label="Car Model Type", num_top_classes=3)],
17
+ title="Car Classifier",
18
+ description="Upload an image of a car and get the predicted class"
19
+ )
20
+
21
+ if __name__ == "__main__":
22
+ gradio_app.launch()