Spaces:
Runtime error
Runtime error
File size: 1,549 Bytes
2046ca8 db9993b db77225 2046ca8 db77225 2046ca8 b8bdcdd 986d5a9 2046ca8 2d4e7ec 2046ca8 279cced 2d4e7ec 2046ca8 045f0da 2046ca8 db77225 2046ca8 db77225 db9993b db77225 5e9c05b db77225 |
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 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
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")
examples = examples = [
['./example0.JPG'],
['./example1.JPG']
]
def inference(original_image):
image = tf.keras.utils.img_to_array(original_image)
image = image.astype("float32") / 255.0
image = np.reshape(image, (28, 28, 1))
output = model.predict(image)
return output
'''
def read_image(image):
image = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)
image = tf.image.resize(image,(28,28,1))
return image
def infer(model, image):
predictions = model.predict(image)
def display_result(input_image):
image = read_image(input_image)
prediction_label = infer(model=model, image=image)
return prediction_label
input = gr.inputs.Image()
examples = [["./example0.JPG"], ["./example1.JPG"]]
title = "Few shot learning"
description = "Upload an image or select from examples to classify fashion items."
'''
interface = gr.Interface(
fn = inference,
title = "Few shot learning with Reptile",
description = "Keras Implementation of Reptile",
inputs = gr.inputs.Image(shape=(28, 28, 1)),
outputs = "text",
examples = examples,
article = "Author: <a href=\"https://huggingface.co/\">Animesh Maheshwari</a>. Based on the keras example from <a href=\"\"></a> \n Model Link: https://huggingface.co/keras-io/keras-reptile",
).launch(enable_queue=True, debug = True) |