Spaces:
Sleeping
Sleeping
Upload 4 files
Browse files- Dogs_vs_Cat.h5 +3 -0
- Dogs_vs_Cats.ipynb +0 -0
- app.py +39 -0
- requirements.txt +5 -0
Dogs_vs_Cat.h5
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:0cf39de911ef42ffafd82f8696162007d91b3f04b3eee6372a0ed1d5d08358c6
|
| 3 |
+
size 24025984
|
Dogs_vs_Cats.ipynb
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
app.py
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
+
import tensorflow as tf
|
| 3 |
+
import tf_keras as keras
|
| 4 |
+
import gradio as gr
|
| 5 |
+
import keras_cv
|
| 6 |
+
|
| 7 |
+
model = keras_cv.models.ImageClassifier.from_preset(
|
| 8 |
+
"efficientnetv2_b0_imagenet",
|
| 9 |
+
num_classes=2,
|
| 10 |
+
)
|
| 11 |
+
|
| 12 |
+
model.compile(loss="sparse_categorical_crossentropy",
|
| 13 |
+
optimizer=keras.optimizers.Adam(),
|
| 14 |
+
metrics=["accuracy"])
|
| 15 |
+
|
| 16 |
+
model.load_weights("model.h5")
|
| 17 |
+
|
| 18 |
+
title = "Food Vision 101"
|
| 19 |
+
|
| 20 |
+
|
| 21 |
+
description = f"""
|
| 22 |
+
Dogs VS Cats is a deep learning model that classifies dogs and cats into using a TensorFlow model with 70% accuracy.
|
| 23 |
+
The model utilizes transfer learning and fine-tuning techniques to achieve high performance
|
| 24 |
+
For the source code, you can visit the `Dogs_vs_Cats.ipynb` file.
|
| 25 |
+
"""
|
| 26 |
+
|
| 27 |
+
def perform_prediction(image, model=model,):
|
| 28 |
+
predictions = model(image)
|
| 29 |
+
|
| 30 |
+
predicted_class_index = tf.argmax(predictions[0]).numpy()
|
| 31 |
+
|
| 32 |
+
return ['cats','dogs'][predicted_class_index]
|
| 33 |
+
|
| 34 |
+
demo = gr.Interface(fn=perform_prediction,
|
| 35 |
+
inputs="image",
|
| 36 |
+
outputs=gr.Label(num_top_classes=3, label="Predictions"),
|
| 37 |
+
title=title,
|
| 38 |
+
description=description)
|
| 39 |
+
demo.launch()
|
requirements.txt
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
tensorflow
|
| 2 |
+
efficientnet
|
| 3 |
+
gradio
|
| 4 |
+
tf_keras
|
| 5 |
+
keras_cv
|