| |
| |
|
|
| |
|
|
|
|
| import numpy as np |
| import tensorflow_datasets as tfds |
| import tensorflow as tf |
| import tensorflow_hub as hub |
| import sklearn |
| import random |
| from glob import glob |
| import matplotlib.pyplot as plt |
| import requests |
|
|
|
|
| |
|
|
|
|
| print("TF version:", tf.__version__) |
| print("Hub version:", hub.__version__) |
| print("GPU is", "available" if tf.config.list_physical_devices('GPU') else "NOT AVAILABLE") |
|
|
|
|
| |
|
|
|
|
|
|
| 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 = "Classifier" |
| Description = "Model,used :- Efficient Net B7,fine tuned on dataset 'https://www.kaggle.com/datasets/iamsouravbanerjee/animal-image-dataset-90-different-animals'" |
|
|
| gr.Interface(fn=classify_image, |
| title = title, |
| description = Description, |
|
|
| inputs=gr.Image(shape=(600, 600)), |
| outputs=gr.Label(num_top_classes=3), |
| examples=["data/animals/animals/antelope/0a37838e99.jpg", "data/animals/animals/starfish/0a63e965c2.jpg"]).launch(share=True) |
|
|
|
|