| |
| |
|
|
| |
|
|
|
|
| import numpy as np |
| import tensorflow as tf |
|
|
| import sklearn |
| import random |
| import matplotlib.pyplot as plt |
| import requests |
|
|
|
|
| |
|
|
|
|
|
|
| |
|
|
|
|
|
|
| inception_net = tf.keras.applications.EfficientNetB7() |
|
|
|
|
| |
|
|
|
|
| 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 |
|
|
|
|
| |
|
|
|
|
| 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() |
|
|
|
|