eslamESssamM commited on
Commit
93bc1ca
·
verified ·
1 Parent(s): 1708c87
Files changed (1) hide show
  1. app.py +26 -0
app.py CHANGED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from transformers import pipeline
3
+ from PIL import Image
4
+ import torch
5
+
6
+ # Load your model
7
+ device = 0 if torch.cuda.is_available() else -1
8
+ pipe = pipeline("image-classification", model="beingamit99/car_damage_detection", device=device)
9
+
10
+ def predict_damage(image):
11
+ if image.mode != "RGB":
12
+ image = image.convert("RGB")
13
+ results = pipe(image)
14
+ return results
15
+
16
+ # Create the Gradio interface
17
+ iface = gr.Interface(
18
+ fn=predict_damage,
19
+ inputs=gr.Image(type="pil"),
20
+ outputs=gr.JSON(),
21
+ title="Car Damage Detection API",
22
+ description="Upload an image of a car to detect damages."
23
+ )
24
+
25
+ if __name__ == "__main__":
26
+ iface.launch()