Spaces:
Runtime error
Runtime error
Akshat-1812 commited on
Commit ·
69363a4
1
Parent(s): f6c6181
First Commit
Browse files- 20220804-16551659632113-all-images-Adam.h5 +3 -0
- German.jpg +0 -0
- app.py +79 -0
20220804-16551659632113-all-images-Adam.h5
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:da173ad036b3c0d5358aa6729626c00435d383c7b9ba02798cc3dd5909fcebaf
|
| 3 |
+
size 23432380
|
German.jpg
ADDED
|
app.py
ADDED
|
@@ -0,0 +1,79 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
+
import requests
|
| 3 |
+
import tensorflow as tf
|
| 4 |
+
import tensorflow_hub as hub
|
| 5 |
+
|
| 6 |
+
path = '20220804-16551659632113-all-images-Adam.h5'
|
| 7 |
+
model = tf.keras.models.load_model(path,custom_objects={"KerasLayer":hub.KerasLayer})
|
| 8 |
+
|
| 9 |
+
labels = ['affenpinscher', 'afghan_hound', 'african_hunting_dog', 'airedale',
|
| 10 |
+
'american_staffordshire_terrier', 'appenzeller',
|
| 11 |
+
'australian_terrier', 'basenji', 'basset', 'beagle',
|
| 12 |
+
'bedlington_terrier', 'bernese_mountain_dog',
|
| 13 |
+
'black-and-tan_coonhound', 'blenheim_spaniel', 'bloodhound',
|
| 14 |
+
'bluetick', 'border_collie', 'border_terrier', 'borzoi',
|
| 15 |
+
'boston_bull', 'bouvier_des_flandres', 'boxer',
|
| 16 |
+
'brabancon_griffon', 'briard', 'brittany_spaniel', 'bull_mastiff',
|
| 17 |
+
'cairn', 'cardigan', 'chesapeake_bay_retriever', 'chihuahua',
|
| 18 |
+
'chow', 'clumber', 'cocker_spaniel', 'collie',
|
| 19 |
+
'curly-coated_retriever', 'dandie_dinmont', 'dhole', 'dingo',
|
| 20 |
+
'doberman', 'english_foxhound', 'english_setter',
|
| 21 |
+
'english_springer', 'entlebucher', 'eskimo_dog',
|
| 22 |
+
'flat-coated_retriever', 'french_bulldog', 'german_shepherd',
|
| 23 |
+
'german_short-haired_pointer', 'giant_schnauzer',
|
| 24 |
+
'golden_retriever', 'gordon_setter', 'great_dane',
|
| 25 |
+
'great_pyrenees', 'greater_swiss_mountain_dog', 'groenendael',
|
| 26 |
+
'ibizan_hound', 'irish_setter', 'irish_terrier',
|
| 27 |
+
'irish_water_spaniel', 'irish_wolfhound', 'italian_greyhound',
|
| 28 |
+
'japanese_spaniel', 'keeshond', 'kelpie', 'kerry_blue_terrier',
|
| 29 |
+
'komondor', 'kuvasz', 'labrador_retriever', 'lakeland_terrier',
|
| 30 |
+
'leonberg', 'lhasa', 'malamute', 'malinois', 'maltese_dog',
|
| 31 |
+
'mexican_hairless', 'miniature_pinscher', 'miniature_poodle',
|
| 32 |
+
'miniature_schnauzer', 'newfoundland', 'norfolk_terrier',
|
| 33 |
+
'norwegian_elkhound', 'norwich_terrier', 'old_english_sheepdog',
|
| 34 |
+
'otterhound', 'papillon', 'pekinese', 'pembroke', 'pomeranian',
|
| 35 |
+
'pug', 'redbone', 'rhodesian_ridgeback', 'rottweiler',
|
| 36 |
+
'saint_bernard', 'saluki', 'samoyed', 'schipperke',
|
| 37 |
+
'scotch_terrier', 'scottish_deerhound', 'sealyham_terrier',
|
| 38 |
+
'shetland_sheepdog', 'shih-tzu', 'siberian_husky', 'silky_terrier',
|
| 39 |
+
'soft-coated_wheaten_terrier', 'staffordshire_bullterrier',
|
| 40 |
+
'standard_poodle', 'standard_schnauzer', 'sussex_spaniel',
|
| 41 |
+
'tibetan_mastiff', 'tibetan_terrier', 'toy_poodle', 'toy_terrier',
|
| 42 |
+
'vizsla', 'walker_hound', 'weimaraner', 'welsh_springer_spaniel',
|
| 43 |
+
'west_highland_white_terrier', 'whippet',
|
| 44 |
+
'wire-haired_fox_terrier', 'yorkshire_terrier']
|
| 45 |
+
|
| 46 |
+
# load the model
|
| 47 |
+
def predict_breed(image):
|
| 48 |
+
|
| 49 |
+
|
| 50 |
+
# reshape the input
|
| 51 |
+
image = image.reshape((-1, 224, 224, 3))
|
| 52 |
+
|
| 53 |
+
image = tf.image.convert_image_dtype(image, dtype=tf.float32)
|
| 54 |
+
|
| 55 |
+
image = tf.constant(image)
|
| 56 |
+
|
| 57 |
+
# prediction = model_1000_images.predict(image).flatten()
|
| 58 |
+
prediction = model.predict(image).flatten()
|
| 59 |
+
|
| 60 |
+
# return prediction labels
|
| 61 |
+
return {labels[i]: float(prediction[i]) for i in range(120)}
|
| 62 |
+
|
| 63 |
+
title = "Dog Vision"
|
| 64 |
+
description = "A Dog Breed Classifier trained on the MobileNetV2 Deep Learning Model result."
|
| 65 |
+
|
| 66 |
+
examples = ['German.jpg']
|
| 67 |
+
|
| 68 |
+
enable_queue=True
|
| 69 |
+
|
| 70 |
+
gr.Interface(
|
| 71 |
+
fn=predict_breed,
|
| 72 |
+
inputs=gr.inputs.Image(shape=(224, 224)),
|
| 73 |
+
outputs=gr.outputs.Label(num_top_classes=3),
|
| 74 |
+
title=title,
|
| 75 |
+
description=description,
|
| 76 |
+
examples=examples,
|
| 77 |
+
cache_examples=True,
|
| 78 |
+
examples_per_page=2,
|
| 79 |
+
enable_queue=enable_queue).launch()
|