Spaces:
Sleeping
Sleeping
Upload 10 files
Browse files- .gitattributes +1 -0
- app.py +38 -0
- images/bond.jpg +0 -0
- images/cat.jpg +0 -0
- images/dog.jpg +0 -0
- images/johnson.jpg +0 -0
- images/kronk.jpg +0 -0
- images/panda.jpg +0 -0
- images/zebra.jpg +0 -0
- mySpiritualAnimalResNet50V2.keras +3 -0
- requirements.txt +1 -0
.gitattributes
CHANGED
@@ -33,3 +33,4 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
|
33 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
34 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
35 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
|
|
|
33 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
34 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
35 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
36 |
+
mySpiritualAnimalResNet50V2.keras filter=lfs diff=lfs merge=lfs -text
|
app.py
ADDED
@@ -0,0 +1,38 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
import tensorflow as tf
|
3 |
+
from PIL import Image
|
4 |
+
import numpy as np
|
5 |
+
|
6 |
+
# Load your custom regression model
|
7 |
+
model_path = "mySpiritualAnimalResNet50V2.keras"
|
8 |
+
model = tf.keras.models.load_model(model_path)
|
9 |
+
model.summary() # Check if the model architecture loaded matches the expected one
|
10 |
+
|
11 |
+
labels = ['antelope', 'badger', 'bat', 'bear', 'bee', 'beetle', 'bison', 'boar', 'butterfly', 'cat', 'caterpillar', 'chimpanzee', 'cockroach', 'cow', 'coyote', 'crab', 'crow', 'deer', 'dog', 'dolphin', 'donkey', 'dragonfly', 'duck', 'eagle', 'elephant', 'flamingo', 'fly', 'fox', 'goat', 'goldfish', 'goose', 'gorilla', 'grasshopper', 'hamster', 'hare', 'hedgehog', 'hippopotamus', 'hornbill', 'horse', 'hummingbird', 'hyena', 'jellyfish', 'kangaroo', 'koala', 'ladybugs', 'leopard', 'lion', 'lizard', 'lobster', 'mosquito', 'moth', 'mouse', 'octopus', 'okapi', 'orangutan', 'otter', 'owl', 'ox', 'oyster', 'panda', 'parrot', 'pelecaniformes', 'penguin', 'pig', 'pigeon', 'porcupine', 'possum', 'raccoon', 'rat', 'red_panda', 'reindeer', 'rhinoceros', 'sandpiper', 'seahorse', 'seal', 'shark', 'sheep', 'snake', 'sparrow', 'squid', 'squirrel', 'starfish', 'swan', 'tiger', 'turkey', 'turtle', 'whale', 'wolf', 'wombat', 'woodpecker', 'zebra']
|
12 |
+
|
13 |
+
# Define regression function
|
14 |
+
def predict_regression(image):
|
15 |
+
# Preprocess image
|
16 |
+
image = Image.fromarray(image.astype('uint8')) # Convert numpy array to PIL image
|
17 |
+
image = image.resize((150, 150))
|
18 |
+
# If model expects RGB, convert to RGB
|
19 |
+
image = image.convert('RGB') # Ensure image is in RGB format
|
20 |
+
|
21 |
+
|
22 |
+
image = np.array(image)
|
23 |
+
print(image.shape)
|
24 |
+
# Predict
|
25 |
+
prediction = model.predict(image[None, ...]) # Assuming single regression value
|
26 |
+
confidences = {labels[i]: np.round(float(prediction[0][i]), 2) for i in range(len(labels))}
|
27 |
+
return confidences
|
28 |
+
|
29 |
+
|
30 |
+
# Create Gradio interface
|
31 |
+
input_image = gr.Image()
|
32 |
+
output_text = gr.Textbox(label="Predicted Value")
|
33 |
+
interface = gr.Interface(fn=predict_regression,
|
34 |
+
inputs=input_image,
|
35 |
+
outputs=gr.Label(),
|
36 |
+
examples=["images/bond.jpg", "images/cat.jpg", "images/kronk.jpgg", "images/zebra.jpg", "images/dog.jpg", "images/johnson.jpg", "images/panda.jpg" ],
|
37 |
+
description="A simple mlp classification model for image classification using a few pokemons.")
|
38 |
+
interface.launch()
|
images/bond.jpg
ADDED
images/cat.jpg
ADDED
images/dog.jpg
ADDED
images/johnson.jpg
ADDED
images/kronk.jpg
ADDED
images/panda.jpg
ADDED
images/zebra.jpg
ADDED
mySpiritualAnimalResNet50V2.keras
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:85cc3afb88c4456a450772f5f47e8abe91e6613c9e8e20dd3fee2ca1ec000cd5
|
3 |
+
size 285416811
|
requirements.txt
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
tensorflow
|