car-damage-api / app.py
eslamESssamM's picture
update
93bc1ca verified
raw
history blame
672 Bytes
import gradio as gr
from transformers import pipeline
from PIL import Image
import torch
# Load your model
device = 0 if torch.cuda.is_available() else -1
pipe = pipeline("image-classification", model="beingamit99/car_damage_detection", device=device)
def predict_damage(image):
if image.mode != "RGB":
image = image.convert("RGB")
results = pipe(image)
return results
# Create the Gradio interface
iface = gr.Interface(
fn=predict_damage,
inputs=gr.Image(type="pil"),
outputs=gr.JSON(),
title="Car Damage Detection API",
description="Upload an image of a car to detect damages."
)
if __name__ == "__main__":
iface.launch()