Spaces:
Runtime error
Runtime error
Update app.py
Browse files12 unmodified lines13141516161718194 unmodified lines24252627272829305 unmodified lines3637383939404142424344454647484950515253545545575846474849506151525354635512 unmodified lines
Inception_model = load_model(Inception_path)VGGNet_model = load_model(VGGNet_path)REsNet_model = load_model(ResNet_path)ResNet_model = load_model(ResNet_path)Efficient_model = load_model(EfficientNet_path)
def classify_selected_model(image, model_name):4 unmodified lines img = np.expand_dims(img, axis=0)
if model_name == "ResNet": predictions = REsNet_model.predict(img) predictions = ResNet_model.predict(img) elif model_name == "EfficientNet": predictions = Efficient_model.predict(img) elif model_name == "VGGNet":5 unmodified lines class_name = class_folders[class_index] probability = max(predictions[0])
return {"class_name": class_name, "probability": probability} return class_name, probability # Return two separate values
except Exception as e: return {"error": str(e)} return str(e), None # Return an error message and None for probability
# Create Gradio interface# iface = gr.Interface(# fn=classify_selected_model,# 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 service# iface.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(model_dropdown = gr.Dropdown(["ResNet", "EfficientNet", "VGGNet", "InceptionV3"], label="Select Model")
iface = gr.Interface( fn=classify_selected_model, inputs=[image_input, model_dropdown], outputs="json", outputs=["text", "number"], # Define separate outputs for class_name and probability live=True)
).launch(debug=True,share=True)iface.launch(debug=True, share=True)app.py+11-19