Skip to main content

NeT2i (Network to Image) converts network traffic data into RGB images suitable for CNN-based anomaly detection.

Project description

NeT2I - Network to Image

NeT2I (Network to Image) is a Python tool for converting structured network traffic data into RGB images that can be used for anomaly detection via Convolutional Neural Networks (CNNs). It supports CSV inputs containing IP addresses, MAC addresses, numeric values, and string fields. These are automatically detected, processed, and encoded into image representations.


🔍 Key Features

  • Converts CSV-based network traffic into RGB images
  • Handles MAC addresses, IP addresses, integers, floats, and strings
  • Encodes numeric data using IEEE 754 float-to-byte representation for lossless recovery
  • Outputs RGB images for CNN model training or anomaly detection tasks
  • Includes type detection, data normalization, and image generation

📦 Requirements

Install the dependencies using:

pip install pillow numpy pandas

🚀 Getting Started

1. Prepare Your Data

Place your CSV file in the working directory and rename it to:

source_in2.csv

Each row in this file should represent one sample of network data. No headers are expected.


2. Run the Script

python net2i.py

This will:

  • Detect and map each column to its correct type (IP, MAC, float, etc.)
  • Convert each row into two RGB pixels per float-equivalent value
  • Create one .png image per row in the data/ directory
  • Generate a data_types.json file for decoding and debugging

🧠 How It Works

  • MAC Addresses are split into two hexadecimal chunks and treated as large integers.
  • IP Addresses are split into four octets, each converted to float.
  • Integers are first cast to float before encoding to RGB using struct.pack(), preserving their IEEE 754 byte format.
  • Strings are hashed to integers, then converted to floats and encoded similarly.

Each float is encoded into two RGB pixels (6 bytes) to avoid information loss.


📁 Output Structure

  • data/: Directory containing all generated RGB images (one per row)
  • data_types.json: Contains original and final column types after preprocessing
  • from_image.csv: Placeholder file for reverse decoding (optional, not yet included)

🧪 Example Use Case

Once converted, these RGB images can be fed into CNN models like ResNet, VGG, or custom classifiers for anomaly detection, intrusion detection, or network behavior classification tasks.


🛠️ Configuration

You can adjust these options at the top of the script:

INPUT_CSV = "source_in2.csv"
OUTPUT_DIR = "data"
IMAGE_SIZE = 150
TYPES_FILE = "data_types.json"
DECODED = "from_image.csv"

🧾 License

This project is licensed under the MIT License.


👥 Authors


🌐 Project Links

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

net2i-2.0.0.tar.gz (7.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

net2i-2.0.0-py3-none-any.whl (7.5 kB view details)

Uploaded Python 3

File details

Details for the file net2i-2.0.0.tar.gz.

File metadata

  • Download URL: net2i-2.0.0.tar.gz
  • Upload date:
  • Size: 7.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.10.11

File hashes

Hashes for net2i-2.0.0.tar.gz
Algorithm Hash digest
SHA256 8ddb2c7c55c6d5eec3c47eddb82cf1c3f722c26ef4722891ffd85796762afb29
MD5 87a78a0ca918a54a4d37421e62ea86e2
BLAKE2b-256 84c6dca73a78d908231dc31699c9f01e665cf251f2c2a8ed9ead650d1f5e8fc4

See more details on using hashes here.

File details

Details for the file net2i-2.0.0-py3-none-any.whl.

File metadata

  • Download URL: net2i-2.0.0-py3-none-any.whl
  • Upload date:
  • Size: 7.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.10.11

File hashes

Hashes for net2i-2.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 6b41693fa5ec483b52432a63d92da6a43351951a7999d5d7cc2dc347c3901d8e
MD5 a648a27f2a3722634fdf17750dea89fe
BLAKE2b-256 1ba5c9676e6712d2873e9fd2e16365f289a00754498689e1371127c8c4e248ac

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page