Spaces:
Sleeping
Sleeping
Upload 3 files
Browse files- .gitattributes +1 -0
- app.py +34 -0
- bob_spaces.keras +3 -0
- requirements.txt +15 -0
.gitattributes
CHANGED
|
@@ -33,3 +33,4 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
|
| 33 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
| 34 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
| 35 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
|
|
|
|
|
| 33 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
| 34 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
| 35 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
| 36 |
+
bob_spaces.keras filter=lfs diff=lfs merge=lfs -text
|
app.py
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
+
import tensorflow as tf
|
| 3 |
+
import numpy as np
|
| 4 |
+
from PIL import Image
|
| 5 |
+
|
| 6 |
+
# Load your model
|
| 7 |
+
model = tf.keras.models.load_model('bob_spaces.keras')
|
| 8 |
+
|
| 9 |
+
|
| 10 |
+
# Define preprocessing and prediction
|
| 11 |
+
def predict(image):
|
| 12 |
+
# Preprocess image to match your model's expected input
|
| 13 |
+
image = image.resize((224, 224)) # Example size
|
| 14 |
+
image = np.array(image) / 255.0
|
| 15 |
+
image = np.expand_dims(image, axis=0)
|
| 16 |
+
|
| 17 |
+
# Make prediction
|
| 18 |
+
prediction = model.predict(image)
|
| 19 |
+
class_idx = np.argmax(prediction[0])
|
| 20 |
+
|
| 21 |
+
# Return as dictionary of class probabilities
|
| 22 |
+
return {str(i): float(prediction[0][i]) for i in range(len(prediction[0]))}
|
| 23 |
+
|
| 24 |
+
|
| 25 |
+
# Create Gradio interface
|
| 26 |
+
iface = gr.Interface(
|
| 27 |
+
fn=predict,
|
| 28 |
+
inputs=gr.Image(type="pil"),
|
| 29 |
+
outputs=gr.Label(num_top_classes=3),
|
| 30 |
+
title="Image Classifier",
|
| 31 |
+
description="Upload an image for classification"
|
| 32 |
+
)
|
| 33 |
+
|
| 34 |
+
iface.launch()
|
bob_spaces.keras
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:bc589cb5d7dd5c5197000a5b46c6d2ac96a50c2d55f494f0eeb5cb90c3237d27
|
| 3 |
+
size 29614459
|
requirements.txt
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{\rtf1\ansi\ansicpg1252\cocoartf2822
|
| 2 |
+
\cocoatextscaling0\cocoaplatform0{\fonttbl\f0\fswiss\fcharset0 Helvetica;}
|
| 3 |
+
{\colortbl;\red255\green255\blue255;}
|
| 4 |
+
{\*\expandedcolortbl;;}
|
| 5 |
+
\margl1440\margr1440\vieww11520\viewh8400\viewkind0
|
| 6 |
+
\pard\tx720\tx1440\tx2160\tx2880\tx3600\tx4320\tx5040\tx5760\tx6480\tx7200\tx7920\tx8640\pardirnatural\partightenfactor0
|
| 7 |
+
|
| 8 |
+
\f0\fs24 \cf0 tensorflow\
|
| 9 |
+
gradio\
|
| 10 |
+
pillow\
|
| 11 |
+
numpy\
|
| 12 |
+
\
|
| 13 |
+
\
|
| 14 |
+
\
|
| 15 |
+
}
|