Spaces:
Build error
Build error
new version
Browse files
app.py
CHANGED
@@ -5,9 +5,9 @@ import numpy as np
|
|
5 |
import gradio as gr
|
6 |
|
7 |
tf.keras.optimizers.AdamW = AdamW
|
8 |
-
model = from_pretrained_keras("keras-io/
|
|
|
9 |
|
10 |
-
IMAGE_SIZE = 72
|
11 |
|
12 |
def softmax(x):
|
13 |
f_x = np.exp(x) / np.sum(np.exp(x))
|
@@ -16,10 +16,8 @@ def softmax(x):
|
|
16 |
labels = ["apple", "aquarium_fish", "baby", "bear", "beaver", "bed", "bee", "beetle", "bicycle", "bottle", "bowl", "boy", "bridge", "bus", "butterfly", "camel", "can", "castle", "caterpillar", "cattle", "chair", "chimpanzee", "clock", "cloud", "cockroach", "couch", "cra", "crocodile", "cup", "dinosaur", "dolphin", "elephant", "flatfish", "forest", "fox", "girl", "hamster", "house", "kangaroo", "keyboard", "lamp", "lawn_mower", "leopard", "lion", "lizard", "lobster", "man", "maple_tree", "motorcycle", "mountain", "mouse", "mushroom", "oak_tree", "orange", "orchid", "otter", "palm_tree", "pear", "pickup_truck", "pine_tree", "plain", "plate", "poppy", "porcupine", "possum", "rabbit", "raccoon", "ray", "road", "rocket", "rose", "sea", "seal", "shark", "shrew", "skunk", "skyscraper", "snail", "snake", "spider", "squirrel", "streetcar", "sunflower", "sweet_pepper", "table", "tank", "telephone", "television", "tiger", "tractor", "train", "trout", "tulip", "turtle", "wardrobe", "whale", "willow_tree", "wolf", "woman", "worm"]
|
17 |
|
18 |
def classify_image(image):
|
19 |
-
|
20 |
-
|
21 |
-
tf.convert_to_tensor([image]), size=(IMAGE_SIZE, IMAGE_SIZE))
|
22 |
-
pred = model.predict(resized_image)
|
23 |
prediction = softmax(pred)[0]
|
24 |
return {labels[i]: float(prediction[i]) for i in range(100)}
|
25 |
|
|
|
5 |
import gradio as gr
|
6 |
|
7 |
tf.keras.optimizers.AdamW = AdamW
|
8 |
+
model = from_pretrained_keras("keras-io/vit_small_ds_v2")
|
9 |
+
|
10 |
|
|
|
11 |
|
12 |
def softmax(x):
|
13 |
f_x = np.exp(x) / np.sum(np.exp(x))
|
|
|
16 |
labels = ["apple", "aquarium_fish", "baby", "bear", "beaver", "bed", "bee", "beetle", "bicycle", "bottle", "bowl", "boy", "bridge", "bus", "butterfly", "camel", "can", "castle", "caterpillar", "cattle", "chair", "chimpanzee", "clock", "cloud", "cockroach", "couch", "cra", "crocodile", "cup", "dinosaur", "dolphin", "elephant", "flatfish", "forest", "fox", "girl", "hamster", "house", "kangaroo", "keyboard", "lamp", "lawn_mower", "leopard", "lion", "lizard", "lobster", "man", "maple_tree", "motorcycle", "mountain", "mouse", "mushroom", "oak_tree", "orange", "orchid", "otter", "palm_tree", "pear", "pickup_truck", "pine_tree", "plain", "plate", "poppy", "porcupine", "possum", "rabbit", "raccoon", "ray", "road", "rocket", "rose", "sea", "seal", "shark", "shrew", "skunk", "skyscraper", "snail", "snake", "spider", "squirrel", "streetcar", "sunflower", "sweet_pepper", "table", "tank", "telephone", "television", "tiger", "tractor", "train", "trout", "tulip", "turtle", "wardrobe", "whale", "willow_tree", "wolf", "woman", "worm"]
|
17 |
|
18 |
def classify_image(image):
|
19 |
+
image = image.reshape((1, 32, 32, 3))
|
20 |
+
pred = model.predict(image)
|
|
|
|
|
21 |
prediction = softmax(pred)[0]
|
22 |
return {labels[i]: float(prediction[i]) for i in range(100)}
|
23 |
|