Downloads · 30 days
0
CernovaAI/CANet-v1.3
CANet-v1.3 is a image classification model from CernovaAI. Use it when you need a label for an image. The card lists the license as mit.
This project focuses on the classification of cancer-related medical images using Convolutional Neural Networks (CNNs) implemented with TensorFlow/Keras. The dataset consists of cancer image samples (in this case from…
Downloads · 30 days
0
Access
Public
Updated Sep 4, 2025
Repo size
—
Likes
0
Public
Click a slice to open those files.
.png185 KB · 95%
From the Hugging Face model README
This project focuses on the classification of cancer-related medical images using Convolutional Neural Networks (CNNs) implemented with TensorFlow/Keras. The dataset consists of cancer image samples (in this case from the ALL folder under the Multi Cancer dataset on Kaggle). The model is trained to distinguish between different classes within the dataset using supervised learning.
Deep learning techniques, specifically CNN architectures, are applied to process and classify images automatically without manual feature extraction. This project demonstrates an end-to-end machine learning pipeline from data loading and preprocessing to model training, evaluation, saving, and prediction.
├── Multi Cancer Dataset
│ ├── ALL
│ │ ├── Class_1
│ │ ├── Class_2
│ │ ├── ...
│
├── model5.h5 # Trained CNN model saved in HDF5 format
├── cancer_classification.py # Main training & prediction script
├── README.md # Project documentation (this file)
To run this project, you need the following dependencies:
You can install the dependencies using:
pip install tensorflow numpy matplotlib
The dataset is organized in directory format where each folder represents a class label.
Example:
/ALL
/Class_1
image1.jpg
image2.jpg
/Class_2
image1.jpg
image2.jpg
Steps taken:
Rescaling Images – All images are normalized by scaling pixel values to the range [0,1].
Image Resizing – Every image is resized to 150x150 pixels to ensure uniform input size.
Data Augmentation – Implemented via ImageDataGenerator with:
rescale=1./255validation_split=0.1 (10% of data reserved for validation)This allows for efficient training and prevents overfitting.
train_datagen = ImageDataGenerator(rescale=1./255, validation_split=0.1)
The model is a Sequential CNN consisting of:
Conv2D + MaxPooling Layers:
Flatten Layer:
Dense Layers:
model = keras.Sequential([
layers.Conv2D(32, (3, 3), activation='relu', input_shape=(150, 150, 3)),
layers.MaxPooling2D(2, 2),
layers.Conv2D(64, (3, 3), activation='relu'),
layers.MaxPooling2D(2, 2),
layers.Conv2D(128, (3, 3), activation='relu'),
layers.MaxPooling2D(2, 2),
layers.Flatten(),
layers.Dense(512, activation='relu'),
layers.Dense(len(train_generator.class_indices), activation='softmax')
])
model.compile(loss='categorical_crossentropy',
optimizer='adam',
metrics=['accuracy'])
The model is trained for 10 epochs:
model.fit(train_generator,
validation_data=validation_generator,
epochs=10)
After training, the model is saved in .h5 format:
model.save("model5.h5")
This allows reusing the model later without retraining.
A custom guess() function is provided to make predictions on new images:
Steps:
def guess(image_path, model, class_indices):
img = load_img(image_path, target_size=(150, 150))
img_array = img_to_array(img) / 255.0
img_array = np.expand_dims(img_array, axis=0)
prediction = model.predict(img_array)
predicted_class = np.argmax(prediction)
class_labels = {v: k for k, v in class_indices.items()}
predicted_label = class_labels[predicted_class]
plt.imshow(img)
plt.title(f"model_guess: {predicted_label}")
plt.axis("off")
plt.show()
Example usage:
guess("test_image.jpg", model, train_generator.class_indices)
The training and validation accuracy/loss values are automatically logged.
These can be plotted using matplotlib to visualize performance trends.
Example metrics:
This project was developed as part of a medical image classification study using deep learning. It can be extended to other cancer types or generalized to different medical imaging problems such as X-ray, MRI, or CT scan analysis.
⚡ In summary: This project demonstrates how to build a deep learning pipeline for medical image classification with CNNs, using TensorFlow/Keras. It covers everything from data preprocessing to model training, saving, and prediction visualization.