Spaces:
Sleeping
Sleeping
File size: 672 Bytes
93bc1ca |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
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()
|