Spaces:
Runtime error
Runtime error
import gradio as gr | |
import pickle | |
categories = ['Telecaster', 'Stratocaster', 'Jazzmaster'] | |
examples = ['stratocaster.jpt', 'telecaster.jpg', 'jazzmaster.jpg'] | |
image = gr.inputs.Image(shape=(192, 192)) | |
label = gr.outputs.Label() | |
# Load the trained model from the model.pkl file | |
with open("model.pkl", "rb") as f: | |
model = pickle.load(f) | |
def predict(image): | |
# image = cv2.resize(image, (224, 224)) | |
# image = np.expand_dims(image, axis=0) | |
prediction, idx, probabilities = model.predict(image) | |
return dict(zip(categories, map(float, probabilities))) | |
iface = gr.Interface(fn=predict, inputs=image, outputs=label, | |
examples=examples, capture_session=True) | |
iface.launch() | |