Spaces:
Runtime error
Runtime error
Update app.py
Browse files3 unmodified lines4567891011121314151617183 unmodified linesimport gradio as grimport cv2iface = gr.Interface(fn=predict_with_deep_learning_model,inputs=gr.Image(),outputs=gr.Textbox(),live=True)iface.launch()3 unmodified lines4567891011121314151617181920212223242526272829303132333435363738394041423 unmodified linesdef classify_selected_model(image, model_name):img = cv2.imread(image.name)img = cv2.resize(img, (150, 150))img = np.expand_dims(img, axis=0)img = img / 255.0if model_name.lower() == 'inceptionv3':predictions = inception_model.predict(img)elif model_name.lower() == 'vggnet':predictions = vggnet_model.predict(img)elif model_name.lower() == 'resnet':predictions = resnet_model.predict(img)elif model_name.lower() == 'efficientnet':predictions = efficientnet_model.predict(img)else:return {"error": "Invalid model selection"}class_index = np.argmax(predictions)class_name = class_folders[class_index]probability = predictions[0, class_index]print(f"Class Index: {class_index}")print(f"Class Name: {class_name}")print(f"Probability: {probability}")return {class_name: probability}image_input = gr.Image()model_selection_input = gr.Dropdown(["InceptionV3", "VGGNet", "ResNet", "EfficientNet"], value="InceptionV3")gr.Interface(fn=classify_selected_model,inputs=[image_input, model_selection_input],outputs="label",live=True).launch(debug=True)
app.py+33-9