Anish1718's picture
Update app.py
565e516 verified
raw
history blame contribute delete
711 Bytes
import gradio as gr
import tensorflow as tf
import numpy as np
from PIL import Image
# Load the model
model = tf.keras.models.load_model("car_damage_model .h5")
# Prediction function
def predict_damage(img):
img = img.resize((224, 224))
img = np.array(img) / 255.0
img = np.expand_dims(img, axis=0)
pred = model.predict(img)[0][0]
label = "Whole Car" if pred > 0.5 else "Damaged Car"
return f"{label} ({pred:.4f})"
# Gradio interface
interface = gr.Interface(
fn=predict_damage,
inputs=gr.Image(type="pil"),
outputs=gr.Label(),
title="Car Damage Classifier",
description="Upload a car image and this model will tell if it's damaged or not."
)
interface.launch()