File size: 1,117 Bytes
0f576d2 383d983 0f576d2 3a5d2d1 0f576d2 9fc924d 0f576d2 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 |
#!/usr/bin/env python
# coding: utf-8
# In[82]:
import numpy as np
import tensorflow as tf
import sklearn
import random
import matplotlib.pyplot as plt
import requests
# In[83]:
# In[94]:
inception_net = tf.keras.applications.EfficientNetB7()
# In[100]:
import requests
response = requests.get("https://git.io/JJkYN")
labels = response.text.split("\n")
def classify_image(inp):
inp = inp.reshape((-1, 600, 600, 3))
inp = tf.keras.applications.efficientnet_v2.preprocess_input(inp)
prediction = inception_net.predict(inp).flatten()
confidences = {labels[i]: float(prediction[i]) for i in range(1000)}
return confidences
# In[107]:
import gradio as gr
title = "Simple Image Classifier"
Description = "A image classifier demo , using pretrained Efficient Net B7 and fine tuned on Animal Images dataset found on Kaggle ,tools used Tensorflow , PIL,numpy , sklearn"
gr.Interface(fn=classify_image,
title = title,
description = Description,
inputs=gr.Image(shape=(600, 600)),
outputs=gr.Label(num_top_classes=3),
).launch()
|