Downloads · 30 days
1
2% of all-time downloads
NSH0407/pcam-densenet121-cnn
pcam-densenet121-cnn is a machine learning model from NSH0407. Use it for the machine learning task on the model card, and read the license before you ship it in a product. It is set up for keras.
This repository contains a TensorFlow/Keras DenseNet121-based CNN trained on the PatchCamelyon (PCam) dataset for binary histopathology image classification (tumor vs. normal).
Downloads · 30 days
1
2% of all-time downloads
All-time downloads
50
Public
Repo size
147 MB
Likes
0
Public
Click a slice to open those files.
.keras147 MB · 100%
From the Hugging Face model README
This repository contains a TensorFlow/Keras DenseNet121-based CNN trained on the PatchCamelyon (PCam) dataset for binary histopathology image classification (tumor vs. normal).
This model corresponds to fold 0, which performed best in a 3-fold ensemble.
tf.keras.applications.DenseNet121The file pcam_advanced_ensemble_model0_best.keras is a full Keras model (architecture + weights).
from huggingface_hub import hf_hub_download
import tensorflow as tf
from tensorflow.keras.applications.densenet import preprocess_input
import numpy as np
# Download model file from the Hub
model_path = hf_hub_download(
repo_id="NSH0407/pcam-densenet121-cnn",
filename="pcam_advanced_ensemble_model0_best.keras"
)
# Load model (note custom_objects for preprocess_input)
model = tf.keras.models.load_model(
model_path,
custom_objects={"preprocess_input": preprocess_input}
)
# img: np.array of shape (96, 96, 3), values in [0, 255] or [0.0, 255.0]
img = ... # TODO: load your own image here
x = np.expand_dims(img.astype("float32"), axis=0)
x = preprocess_input(x)
prob = float(model.predict(x)[0, 0])
print("Tumor probability:", prob)