Spaces:
Runtime error
Runtime error
Commit
·
db77225
1
Parent(s):
986d5a9
Update app.py
Browse files
app.py
CHANGED
|
@@ -6,7 +6,15 @@ import cv2
|
|
| 6 |
|
| 7 |
img_size = 28
|
| 8 |
model = from_pretrained_keras("keras-io/keras-reptile")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 9 |
|
|
|
|
| 10 |
def read_image(image):
|
| 11 |
image = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)
|
| 12 |
image = tf.image.resize(image,(28,28,1))
|
|
@@ -24,7 +32,14 @@ examples = [["./example0.JPG"], ["./example1.JPG"]]
|
|
| 24 |
title = "Few shot learning"
|
| 25 |
description = "Upload an image or select from examples to classify fashion items."
|
| 26 |
|
|
|
|
| 27 |
|
| 28 |
-
gr.Interface(
|
| 29 |
-
|
| 30 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 6 |
|
| 7 |
img_size = 28
|
| 8 |
model = from_pretrained_keras("keras-io/keras-reptile")
|
| 9 |
+
examples = [["./example0.JPG"], ["./example1.JPG"]]
|
| 10 |
+
def inference(original_image):
|
| 11 |
+
image = tf.keras.utils.img_to_array(original_image)
|
| 12 |
+
image = image.astype("float32") / 255.0
|
| 13 |
+
image = np.reshape(image, (28, 28, 1))
|
| 14 |
+
output = model.predict(image)
|
| 15 |
+
return output
|
| 16 |
|
| 17 |
+
'''
|
| 18 |
def read_image(image):
|
| 19 |
image = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)
|
| 20 |
image = tf.image.resize(image,(28,28,1))
|
|
|
|
| 32 |
title = "Few shot learning"
|
| 33 |
description = "Upload an image or select from examples to classify fashion items."
|
| 34 |
|
| 35 |
+
'''
|
| 36 |
|
| 37 |
+
interface = gr.Interface(
|
| 38 |
+
fn = inference,
|
| 39 |
+
title = "Few shot learning with Reptile",
|
| 40 |
+
description = "Keras Implementation of Reptile for ",
|
| 41 |
+
inputs = gr.inputs.Image(shape=(28, 28, 1)),
|
| 42 |
+
outputs = "text",
|
| 43 |
+
examples = examples,
|
| 44 |
+
article = "Author: <a href=\"https://huggingface.co/Blazer007\">Animesh Maheshwari</a>. Based on the keras example from <a href=\"\"></a> \n Model Link: https://huggingface.co/keras-io/keras-reptile",
|
| 45 |
+
).launch(enable_queue=True, debug = True)
|