classify / app.py
VikramxD's picture
Update app.py
3a5d2d1
#!/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()