Spaces:
Runtime error
Runtime error
| import gradio as gr | |
| import tensorflow as tf | |
| model = tf.keras.models.load_model('fire_model.h5') | |
| def predict_input_image(img): | |
| class_names = ['fire_images', 'non_fire_images'] | |
| img_4d = img.reshape(-1, 196, 196, 3) | |
| prediction = model.predict(img_4d)[0] | |
| pred = [1-prediction, prediction] | |
| # predlab = classes[pred] | |
| confidences = {class_names[i]: float(pred[i]) for i in range(2)} | |
| print() | |
| return confidences | |
| image = gr.inputs.Image(shape=(196, 196)) | |
| label = gr.outputs.Label(num_top_classes=1) | |
| gr.Interface(fn=predict_input_image, | |
| inputs=image, outputs=label,interpretation='default').launch() |