A library for easy creation of ANN and CNN models with integrated visualization tools
Project description
ArcoAI
ArcoAI is a Python library designed for building artificial neural networks (ANNs) and convolutional neural networks (CNNs) with ease. It provides tools for quick and flexible model creation and visualization, streamlining the development process for both beginners and experienced practitioners in deep learning. It also integrates state-of-the-art model interpretability techniques like Grad-CAM, SmoothGrad, and Integrated Gradients.
Installation
1. Clone the repository
Go ahed and download ArcoAI through PIP.
pip install arcoai
2. Create a virtual environment (Just do it pls)
To avoid conflicts with other packages, you can create a virtual environment for this project.
python3 -m venv venv
source venv/bin/activate # On Windows use `venv\Scripts\activate`
3. Install dependencies
Use pip to install all required dependencies listed in requirements.txt.
# Might not work for tensorflow, if not just install by itself
pip install -r requirements.txt
Getting Started
Once the package is installed, you can begin creating and training your own neural networks with just a few lines of code. Below are basic steps to get started with creating an ANN and CNN.
Example - Create and Train an ANN
from arcoai.models import ANN
from arcoai.datasets import load_dataset
# Load dataset (e.g., MNIST)
train_data, test_data = load_dataset('mnist')
# Initialize ANN model
model = ANN(input_size=784, hidden_layers=[128, 64], output_size=10)
# Compile model
model.compile(optimizer='adam', loss='categorical_crossentropy', metrics=['accuracy'])
# Train the model
model.train(train_data, epochs=10)
# Evaluate the model
accuracy = model.evaluate(test_data)
print(f"Test Accuracy: {accuracy}%")
Example - Create and Train a CNN
from arcoai.models import CNN
from arcoai.datasets import load_dataset
# Load dataset (e.g., CIFAR-10)
train_data, test_data = load_dataset('cifar10')
# Initialize CNN model
model = CNN(input_shape=(32, 32, 3), num_classes=10)
# Compile model
model.compile(optimizer='adam', loss='categorical_crossentropy', metrics=['accuracy'])
# Train the model
model.train(train_data, epochs=10)
# Evaluate the model
accuracy = model.evaluate(test_data)
print(f"Test Accuracy: {accuracy}%")
Model Architectures
ArcoAI includes several pre-built architectures for quick experimentation with different types of models.
1. DenseNet
DenseNet is a CNN architecture where each layer receives input from all previous layers. It's known for its high accuracy and efficiency in terms of parameters.
2. ResNet
ResNet (Residual Network) is a deep CNN that uses skip connections, enabling the training of very deep models. This helps mitigate vanishing gradients.
3. VGG
VGG is a CNN that consists of very deep layers with small 3x3 convolution filters. This architecture is popular for image classification tasks.
You can easily import and use these models from the arcoai.models package:
from arcoai.models import ResNet, VGG, DenseNet
Visualization Tools
ArcoAI comes with several powerful model interpretation tools (from Arcoson's gradientvis), which help visualize and understand the predictions made by your models.
1. Grad-CAM
Grad-CAM (Gradient-weighted Class Activation Mapping) helps visualize which regions of an image were important for the model's prediction.
from arcoai.visualization import GradCAM
# Initialize GradCAM
gradcam = GradCAM(model, target_class=0)
# Generate heatmap
heatmap = gradcam.generate_heatmap(input_image)
gradcam.show_heatmap(heatmap)
2. SmoothGrad
SmoothGrad is a technique to visualize the importance of different parts of an image by generating multiple noisy versions of the image.
from arcoai.visualization import SmoothGrad
# Initialize SmoothGrad
smoothgrad = SmoothGrad(model)
# Generate noise-based visualization
visualization = smoothgrad.generate_visualization(input_image)
smoothgrad.show_visualization(visualization)
3. Integrated Gradients
Integrated Gradients is a method that provides insights into the parts of an image that most influence the model's predictions.
from arcoai.visualization import IntegratedGradients
# Initialize IntegratedGradients
integrated_gradients = IntegratedGradients(model)
# Compute attributions
attributions = integrated_gradients.compute_attributions(input_image)
integrated_gradients.show_attributions(attributions)
Examples
You can find example scripts for both ANN and CNN in the examples/ directory. These examples include basic training routines for MNIST, CIFAR-10, and other datasets.
To run an example:
python examples/example_ann.py
python examples/example_cnn.py
License
This project is licensed under the MIT License - see the LICENSE file for details.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file arcoai-0.1.1.tar.gz.
File metadata
- Download URL: arcoai-0.1.1.tar.gz
- Upload date:
- Size: 13.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8e454f7902fe52e2af2e42fdf55d7e8f5711d97bf345396c8722b418e95d0646
|
|
| MD5 |
2431956b4f6afd076633cf91e52b82d8
|
|
| BLAKE2b-256 |
ca5c975c8ca2dc74abbd1ad6f813be6522595409b7e8aa4a5b95ce0cdbcd7250
|
File details
Details for the file arcoai-0.1.1-py3-none-any.whl.
File metadata
- Download URL: arcoai-0.1.1-py3-none-any.whl
- Upload date:
- Size: 13.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e64b252353f95fcbf247f6da858c25fd7ac2dfdb3f8dfeee27718b4aa9d1200a
|
|
| MD5 |
db46648117303e0008a2631aa4c94c5c
|
|
| BLAKE2b-256 |
e620e9336f660a8aab0583f29816884b4cb1ee996741cd7e67ef1602ab892678
|