Skip to main content

A Python package for Graph Intellectual Property Protection

Project description

PyGIP

PyPI - Version Build Status License PyPI - Downloads Issues Pull Requests Stars GitHub forks

PyGIP is a Python library designed for experimenting with graph-based model extraction attacks and defenses. It provides a modular framework to implement and test attack and defense strategies on graph datasets.

How to Cite

If you find it useful, please considering cite the following work:

@article{li2025intellectual,
  title={Intellectual Property in Graph-Based Machine Learning as a Service: Attacks and Defenses},
  author={Li, Lincan and Shen, Bolin and Zhao, Chenxi and Sun, Yuxiang and Zhao, Kaixiang and Pan, Shirui and Dong, Yushun},
  journal={arXiv preprint arXiv:2508.19641},
  year={2025}
}

Installation

PyGIP supports both CPU and GPU environments. Make sure you have Python installed (version >= 3.8, <3.13).

Base Installation

First, install the core package:

pip install PyGIP

This will install PyGIP with minimal dependencies.

CPU Version

pip install "PyGIP[torch,dgl]" \
  --index-url https://download.pytorch.org/whl/cpu \
  --extra-index-url https://pypi.org/simple \
  -f https://data.dgl.ai/wheels/repo.html

GPU Version (CUDA 12.1)

pip install "PyGIP[torch,dgl]" \
  --index-url https://download.pytorch.org/whl/cu121 \
  --extra-index-url https://pypi.org/simple \
  -f https://data.dgl.ai/wheels/torch-2.3/cu121/repo.html

Quick Start

Here’s a simple example to launch a Model Extraction Attack using PyGIP:

from datasets import Cora
from models.attack import ModelExtractionAttack0

# Load the Cora dataset
dataset = Cora()

# Initialize the attack with a sampling ratio of 0.25
mea = ModelExtractionAttack0(dataset, 0.25)

# Execute the attack
mea.attack()

This code loads the Cora dataset, initializes a basic model extraction attack (ModelExtractionAttack0), and runs the attack with a specified sampling ratio.

And a simple example to run a Defense method against Model Extraction Attack:

from datasets import Cora
from models.defense import RandomWM

# Load the Cora dataset
dataset = Cora()

# Initialize the attack with a sampling ratio of 0.25
med = RandomWM(dataset, 0.25)

# Execute the defense
med.defend()

which runs the Random Watermarking Graph to defend against MEA.

If you want to use cuda, please set environment variable:

export PYGIP_DEVICE=cuda:0

Implementation & Contributors Guideline

Refer to Implementation Guideline

Refer to Contributors Guideline

License

BSD 2-Clause License

Contact

For questions or contributions, please contact blshen@fsu.edu.

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

pygip-1.1.0.tar.gz (487.7 kB view details)

Uploaded Source

Built Distribution

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

pygip-1.1.0-py3-none-any.whl (531.9 kB view details)

Uploaded Python 3

File details

Details for the file pygip-1.1.0.tar.gz.

File metadata

  • Download URL: pygip-1.1.0.tar.gz
  • Upload date:
  • Size: 487.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.11

File hashes

Hashes for pygip-1.1.0.tar.gz
Algorithm Hash digest
SHA256 6180145bde78efe3ad7e34a30416205330c373b32bc6437bc84958302317ba26
MD5 e639d7f3c45f200cd6f30da9794420e4
BLAKE2b-256 dab5b7dfb1e15a83c92b9e1d1d8cfccddc7fd676bfb72884f0bd42e0c9eefe30

See more details on using hashes here.

File details

Details for the file pygip-1.1.0-py3-none-any.whl.

File metadata

  • Download URL: pygip-1.1.0-py3-none-any.whl
  • Upload date:
  • Size: 531.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.11

File hashes

Hashes for pygip-1.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 7c28798974839cdc70308c53a4d437ce91cfb9d3563ad36beefc9183972b448e
MD5 5c95f1aaae03dff3f6982ef3d2820597
BLAKE2b-256 a0c9a8a9f40aeea6cdb4019d88cd52436e34e2b77d3d56eca9a927780bf5add7

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