Downloads · 30 days
23
39% of all-time downloads
sdrfsh/alexnet-door-entry-classifier
alexnet-door-entry-classifier is a image classification model from sdrfsh. Use it when you need a label for an image. It is set up for keras. The card lists the license as mit.
AlexNet-style convolutional neural network that classifies whether a person is entering a door or just passing by it. Trained with TensorFlow/Keras as part of the Real-Time Activity and Intention Recognition project.
Downloads · 30 days
23
39% of all-time downloads
All-time downloads
59
Public
Repo size
1.4 GB
Likes
0
Public
Click a slice to open those files.
.keras700 MB · 100%
From the Hugging Face model README
AlexNet-style convolutional neural network that classifies whether a person is entering a door or just passing by it. Trained with TensorFlow/Keras as part of the Real-Time Activity and Intention Recognition project.
.keras format)0 - passing by the door1 - entering the doorEvaluated on a held-out, balanced test set of 1,120 images (560 per class):
| Metric | Value |
|---|---|
| Test accuracy | 98.84% |
| F1-score (passing by, 0) | 0.99 |
| F1-score (entering, 1) | 0.99 |
| Test loss | 0.0755 |
Confusion matrix:
| Pred: passing by | Pred: entering | |
|---|---|---|
| True: passing by | 548 | 12 |
| True: entering | 1 | 559 |
import keras
import numpy as np
from huggingface_hub import hf_hub_download
model_path = hf_hub_download(
repo_id="sdrfsh/alexnet-door-entry-classifier",
filename="alexnet.keras",
)
model = keras.models.load_model(model_path)
img = keras.utils.load_img("image.jpg", target_size=(227, 227))
x = np.expand_dims(keras.utils.img_to_array(img), axis=0)
probs = model.predict(x)
label = int(probs.argmax(axis=1)[0])
class_names = {0: "passing by", 1: "entering"}
print(f"Prediction: {class_names[label]} (confidence {probs.max():.2%})")
Full training code and the wider project (real-time inference pipeline, data preparation) are available in the GitHub repository: 👉 https://github.com/sdrfsh/realtime-activity-and-intention-recognition
This model can be used as a starting point and fine-tuned on other activity-recognition datasets (e.g., different actions, intentions, or interaction classes). The convolutional layers have learned general visual features from person/door scenes, so for a related task you can reuse them and retrain only the classification head, then optionally unfreeze the full network:
import keras
from keras import layers
from huggingface_hub import hf_hub_download
path = hf_hub_download("sdrfsh/alexnet-door-entry-classifier", "alexnet.keras")
base = keras.models.load_model(path)
NUM_CLASSES = 4 # number of classes in your dataset
# Reuse everything except the final classification layer
backbone = keras.Model(base.inputs, base.layers[-2].output)
backbone.trainable = False # stage 1: freeze the pretrained layers
model = keras.Sequential([
backbone,
layers.Dense(NUM_CLASSES, activation="softmax"),
])
model.compile(optimizer=keras.optimizers.Adam(1e-3),
loss="sparse_categorical_crossentropy", metrics=["accuracy"])
model.fit(train_ds, validation_data=val_ds, epochs=10)
# Stage 2 (optional): unfreeze and fine-tune the whole network at a low LR
backbone.trainable = True
model.compile(optimizer=keras.optimizers.Adam(1e-5),
loss="sparse_categorical_crossentropy", metrics=["accuracy"])
model.fit(train_ds, validation_data=val_ds, epochs=10)
Input images should be 227×227×3 with raw 0-255 pixel values, as with the base model.
If you use this model, please link back to the GitHub repository.