| import gradio as gr
|
| import tensorflow as tf
|
| import cv2
|
|
|
|
|
| model = tf.keras.models.load_model(r"C:/Users/Irfan Arshad/Downloads/alexnet_cifar10.h5")
|
|
|
|
|
| def predict(image):
|
|
|
| image = cv2.resize(image, (32, 32))
|
| print("Resized image shape:", image.shape)
|
|
|
| image = image.astype('float32') / 255.0
|
|
|
| image = tf.expand_dims(image, 0)
|
|
|
| prediction = model.predict(image)
|
| class_index = tf.argmax(prediction, axis=1)[0].numpy()
|
| class_label = class_names[class_index]
|
| return class_label
|
|
|
|
|
| class_names = [
|
| "airplane", "automobile", "bird", "cat", "deer",
|
| "dog", "frog", "horse", "ship", "truck"
|
| ]
|
|
|
| gr.Interface(fn=predict, inputs='image', outputs='text').launch() |