Spaces:
Runtime error
Runtime error
import gradio as gr | |
import numpy as np | |
import cv2 | |
def classify(input): | |
image = input['layers'][0] | |
print("Type of image variable:", type(image)) | |
dimensions = image.shape | |
print("Dimensions of the image:", dimensions) | |
# Resize image to 28x28 using interpolation | |
resized_image = cv2.resize(image, (28, 28)) | |
# Convert image to grayscale | |
gray_image = cv2.cvtColor(resized_image, cv2.COLOR_RGBA2GRAY) | |
# Reshape the image to add a single channel dimension | |
final_image = np.expand_dims(gray_image, axis=-1) | |
print("Final image shape:", final_image.shape) | |
print("Final image:", final_image) | |
#input = np.reshape(input, (1, 28, 28)) | |
#print(input) | |
return '' | |
label = gr.Label(num_top_classes=10) | |
interface = gr.Interface(fn=classify, inputs="sketchpad", outputs=label, | |
live=True) | |
interface.launch() |