Spaces:
Runtime error
Runtime error
Update app.py
Browse files35 unmodified lines363738393940414142434444454647484647484950511 unmodified line53545556575859606156575859606162636465666768697071727374637535 unmodified lines
keras_model = load_model(model_paths[model_name]) #keras_model = load_model(model_paths[model_name])
predictions = keras_model.predict(img) #predictions = keras_model.predict(img) class_index = np.argmax(predictions[0]) class_name = class_folders[class_index] probability = max(predictions[0]) #probability = max(predictions[0])
print(f'Predicted class index: {class_index}') print(f'Predicted class name: {class_name}') print(f'Probability: {probability}') # 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 line return {"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",# 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)# ).launch(debug=True)app.py+25-13