Spaces:
Runtime error
Runtime error
Update app.py
Browse files35 unmodified lines363738394041424344454647484950511 unmodified line535455565758596061626335 unmodified lineskeras_model = load_model(model_paths[model_name])predictions = keras_model.predict(img)class_index = np.argmax(predictions[0])class_name = class_folders[class_index]probability = max(predictions[0])print(f'Predicted class index: {class_index}')print(f'Predicted class name: {class_name}')print(f'Probability: {probability}')return {"class_name": class_name, "probability": probability}1 unmodified linereturn {"error": str(e)}# Create Gradio interfaceimage_input = gr.Image(type='filepath', label="Input Image")model_dropdown = gr.Dropdown(["ResNet", "EfficientNet", "VGGNet", "InceptionV3"], label="Select Model")gr.Interface(fn=classify_selected_model,inputs=[image_input, model_dropdown],outputs="json",live=True).launch(debug=True)35 unmodified lines363738394041424344454647484950511 unmodified line535455565758596061626364656667686970717273747535 unmodified lines#keras_model = load_model(model_paths[model_name])#predictions = keras_model.predict(img)class_index = np.argmax(predictions[0])class_name = class_folders[class_index]#probability = max(predictions[0])# print(f'Predicted class index: {class_index}')# print(f'Predicted class name: {class_name}')# print(f'Probability: {probability}')return {"class_name": class_name, "probability": probability}1 unmodified linereturn {"error": str(e)}# Create Gradio interface# Create a Gradio interface with a dropdown for model selectioniface = gr.Interface(fn=classify_image,inputs=["image", gr.Dropdown(["ResNet", "EfficientNet", "VGGNet", "InceptionV3"], label="Select Model")],outputs="text",live=True)# Launch the Gradio interface and deploy on Gradio's public sharing serviceiface.launch(share=True)# image_input = gr.Image(type='filepath', label="Input Image")# model_dropdown = gr.Dropdown(["ResNet", "EfficientNet", "VGGNet", "InceptionV3"], label="Select Model")# gr.Interface(# fn=classify_selected_model,# inputs=[image_input, model_dropdown],# outputs="json",# live=True# ).launch(debug=True)
app.py+25-13