course-demos/Auth-Image-Classification
1
1import requests2import tensorflow as tf3 4import gradio as gr5 6inception_net = tf.keras.applications.MobileNetV2() # load the model7 8# Download human-readable labels for ImageNet.9response = requests.get("https://git.io/JJkYN")10labels = response.text.split("\n")11 12 13def classify_image(inp):14 inp = inp.reshape((-1, 224, 224, 3))15 inp = tf.keras.applications.mobilenet_v2.preprocess_input(inp)16 prediction = inception_net.predict(inp).flatten()17 return {labels[i]: float(prediction[i]) for i in range(1000)}18 19 20image = gr.Image()21label = gr.Label(num_top_classes=3)22 23title="Gradio Image Classifiction + interpretation Example"24gr.Interface(25 fn=classify_image, inputs=image, outputs=label, interpretation="default",title=title26).launch(enable_queue=False, auth=("admin", "pass1234"))27 