I am getting error while using gradio with my model #634
Unanswered
Akshat-1812
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
@mrdbourke
I have downloaded the pre-trained model which I created sometime ago. While integrating it with gradio I am getting error.
`import gradio as gr
import requests
import tensorflow as tf
import tensorflow_hub as hub
path = '20220804-16551659632113-all-images-Adam.h5'
model = tf.keras.models.load_model(path,custom_objects={"KerasLayer":hub.KerasLayer})
labels = ['affenpinscher', 'afghan_hound', 'african_hunting_dog', 'airedale',
'american_staffordshire_terrier', 'appenzeller',
'australian_terrier', 'basenji', 'basset', 'beagle',
'bedlington_terrier', 'bernese_mountain_dog',
'black-and-tan_coonhound', 'blenheim_spaniel', 'bloodhound',
'bluetick', 'border_collie', 'border_terrier', 'borzoi',
'boston_bull', 'bouvier_des_flandres', 'boxer',
'brabancon_griffon', 'briard', 'brittany_spaniel', 'bull_mastiff',
'cairn', 'cardigan', 'chesapeake_bay_retriever', 'chihuahua',
'chow', 'clumber', 'cocker_spaniel', 'collie',
'curly-coated_retriever', 'dandie_dinmont', 'dhole', 'dingo',
'doberman', 'english_foxhound', 'english_setter',
'english_springer', 'entlebucher', 'eskimo_dog',
'flat-coated_retriever', 'french_bulldog', 'german_shepherd',
'german_short-haired_pointer', 'giant_schnauzer',
'golden_retriever', 'gordon_setter', 'great_dane',
'great_pyrenees', 'greater_swiss_mountain_dog', 'groenendael',
'ibizan_hound', 'irish_setter', 'irish_terrier',
'irish_water_spaniel', 'irish_wolfhound', 'italian_greyhound',
'japanese_spaniel', 'keeshond', 'kelpie', 'kerry_blue_terrier',
'komondor', 'kuvasz', 'labrador_retriever', 'lakeland_terrier',
'leonberg', 'lhasa', 'malamute', 'malinois', 'maltese_dog',
'mexican_hairless', 'miniature_pinscher', 'miniature_poodle',
'miniature_schnauzer', 'newfoundland', 'norfolk_terrier',
'norwegian_elkhound', 'norwich_terrier', 'old_english_sheepdog',
'otterhound', 'papillon', 'pekinese', 'pembroke', 'pomeranian',
'pug', 'redbone', 'rhodesian_ridgeback', 'rottweiler',
'saint_bernard', 'saluki', 'samoyed', 'schipperke',
'scotch_terrier', 'scottish_deerhound', 'sealyham_terrier',
'shetland_sheepdog', 'shih-tzu', 'siberian_husky', 'silky_terrier',
'soft-coated_wheaten_terrier', 'staffordshire_bullterrier',
'standard_poodle', 'standard_schnauzer', 'sussex_spaniel',
'tibetan_mastiff', 'tibetan_terrier', 'toy_poodle', 'toy_terrier',
'vizsla', 'walker_hound', 'weimaraner', 'welsh_springer_spaniel',
'west_highland_white_terrier', 'whippet',
'wire-haired_fox_terrier', 'yorkshire_terrier']
load the model
def predict_breed(image):
title = "Dog Vision"
description = "A Dog Breed Classifier trained on the MobileNetV2 Deep Learning Model result."
examples = ['German.jpg']
enable_queue=True
gr.Interface(
fn=predict_breed,
inputs=gr.inputs.Image(shape=(224, 224)),
outputs=gr.outputs.Label(num_top_classes=3),
title=title,
description=description,
examples=examples,
cache_examples=True,
examples_per_page=2,
enable_queue=enable_queue).launch()`
It was working fine a year ago.
This is the error I am getting
ValueError: Unknown layer: 'KerasLayer'. Please ensure you are using a
keras.utils.custom_object_scope
and that this object is included in the scope. See https://www.tensorflow.org/guide/keras/save_and_serialize#registering_the_custom_object for details.Please Help!!!!
Beta Was this translation helpful? Give feedback.
All reactions