Spaces:
Runtime error
Runtime error
Update app.py
Browse files4 unmodified lines567891011128910111213141516 unmodified lines323334353637353637383939404142434243444546471 unmodified line4950515253525354555655565758594 unmodified lines
class_folders = ["Ajloun Castle", "Jeresh", "Petra", "Roman amphitheater", "Umm_Qais", "Wadi_Rum"]
Inception_path='./Models/inceptionv3_-saved-model-59-val_accuracy-0.94.hdf5'VGGNet_path='./Models/vgg_16_-saved-model-89-acc-0.93.hdf5'ResNet_path= './Models/resnet50-saved-model-79-val_acc-1.00.hdf5'EfficientNet_path= './Models/efficientnet-saved-model-06-val_acc-0.98.hdf5'# Define paths for the HDF5 modelsInception_path='./inceptionv3_-saved-model-59-val_accuracy-0.94.hdf5'VGGNet_path='./vgg_16_-saved-model-89-acc-0.93.hdf5'ResNet_path= './resnet50-saved-model-79-val_acc-1.00.hdf5'EfficientNet_path= './efficientnet-saved-model-06-val_acc-0.98.hdf5'
Inception_model = load_model(Inception_path)VGGNet_model = load_model(VGGNet_path)16 unmodified lines elif model_name == "InceptionV3": predictions = Inception_model.predict(img)
class_indices = np.argsort(predictions[0]) class_probabilities = predictions[0][class_indices] class_names = [class_folders[idx] for idx in class_indices] class_index = np.argmax(predictions[0]) class_name = class_folders[class_index] probability = max(predictions[0])
return class_names, class_probabilities.tolist() return class_name, probability # Return two separate values
except Exception as e: return [str(e)], [None]
return str(e), None # Return an error message and None for probability
# Create Gradio interfaceimage_input = gr.Image(type='filepath', label="Input Image")model_dropdown = gr.Dropdown(["ResNet", "EfficientNet", "VGGNet", "InceptionV3"], label="Select Model")
1 unmodified line fn=classify_selected_model, inputs=[image_input, model_dropdown], outputs=[ gr.Textbox(label="Predicted Classes"), gr.Number(label="Class Probabilities") gr.Textbox(label="Predicted Class"), gr.Number(label="Probability") ], title ="Image Classification Interface" , live=True live=True, title="Image Classification Interface")
iface.launch(debug=True, share=True)app.py+15-15