Spaces:
Runtime error
Runtime error
File size: 1,147 Bytes
2046ca8 5213a99 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
import numpy as np
import tensorflow as tf
import gradio as gr
from huggingface_hub import from_pretrained_keras
import cv2
img_size = 28
model = from_pretrained_keras("keras-io/keras-reptile")
def read_image(image):
image = tf.convert_to_tensor(image)
image = cv2.resize()
image = image / 127.5 - 1
return image
def infer(model, image_tensor):
predictions = model.predict(np.expand_dims((image_tensor), axis=0))
predictions = np.squeeze(predictions)
predictions = np.argmax(predictions, axis=0)
return predictions
def display_result(input_image):
image_tensor = read_image(input_image)
prediction_label = infer(model=model, image_tensor=image_tensor)
return prediction_label
input = gr.inputs.Image()
examples = [["/content/drive/MyDrive/boot.jpg"], ["/content/drive/MyDrive/sneaker.jpg"]]
title = "Few shot learning"
description = "Upload an image or select from examples to classify fashion items."
gr.Interface(display_result, input, outputs="text", examples=examples, allow_flagging=False, analytics_enabled=False,
title=title, description=description).launch(enable_queue=True)
gr.launch() |