eslamESssamM commited on
Commit
1708c87
·
verified ·
1 Parent(s): 113ecdf

Create app.py

Browse files

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()

Files changed (1) hide show
  1. app.py +0 -0
app.py ADDED
File without changes