Skip to main content

bforbuntyai

Run GenAI experiments in a few lines instead of hundreds.

from bforbuntyai import GAN, dataset
gan = GAN(dataset.FashionMNIST())
gan.train(epochs=50)
gan.generate(n=25)

Installation

# Core (no heavy ML libs)
pip install bforbuntyai

# With PyTorch (GAN, DCGAN, cGAN, VAE, Pix2Pix)
pip install "bforbuntyai[torch]"

# With TensorFlow (AutoEncoder)
pip install "bforbuntyai[tensorflow]"

# With HuggingFace (TextGenerator, TextFineTuner, ImageCaptioner, EthicalEvaluator)
pip install "bforbuntyai[transformers]"

# With Stable Diffusion
pip install "bforbuntyai[diffusers]"

# With ethical evaluation
pip install "bforbuntyai[ethics]"

# Everything at once
pip install "bforbuntyai[all]"

HuggingFace Authentication

Some models (Stable Diffusion gated versions, private datasets) require a HuggingFace token.

from bforbuntyai import auth

auth.login()                    # interactive browser prompt
auth.login(token="hf_...")      # explicit token
auth.whoami()                   # check who is logged in
auth.logout()

# Or pass token directly to any model
sd = StableDiffusion(token="hf_...")
data = dataset.HuggingFace("private/dataset", token="hf_...")

Token is also auto-read from the HF_TOKEN or HUGGINGFACE_HUB_TOKEN environment variable.

Models & Datasets

AutoEncoder (TensorFlow)

from bforbuntyai import AutoEncoder, dataset

ae = AutoEncoder(dataset.MNIST(), encoding_dim=64)
ae.train(epochs=50)
ae.visualize()              # original vs reconstructed grid
ae.save("ae.keras")

GAN — Vanilla (PyTorch)

from bforbuntyai import GAN, dataset

gan = GAN(dataset.FashionMNIST(), latent_dim=100)
gan.train(epochs=50)
gan.generate(n=25)
gan.save("gan.pth")

DCGAN — Convolutional GAN (PyTorch)

from bforbuntyai import DCGAN, dataset

dcgan = DCGAN(dataset.MNIST())
dcgan.train(epochs=20)
dcgan.generate(n=25)

Conditional GAN (PyTorch)

from bforbuntyai import ConditionalGAN, dataset

cgan = ConditionalGAN(dataset.MNIST(), num_classes=10)
cgan.train(epochs=50)
cgan.generate_class(labels=[0, 1, 2, 3, 4, 5, 6, 7, 8, 9])

VAE — Variational AutoEncoder (PyTorch)

from bforbuntyai import VAE, dataset

vae = VAE(dataset.MNIST(), latent_dim=2)
vae.train(epochs=20)
vae.visualize()              # reconstructions
vae.visualize_latent()       # 2-D scatter plot of latent space
vae.interpolate(img_a, img_b, steps=10)    # morph between images

Pix2Pix Image Translation (PyTorch)

from bforbuntyai import Pix2Pix, dataset

p2p = Pix2Pix(dataset.Edges2Shoes())      # auto-downloads ~1.5 GB
p2p.train(epochs=5)
p2p.visualize()              # input edge | generated photo | real photo

GPT-2 Text Generation

from bforbuntyai import TextGenerator

gen = TextGenerator(model_name="gpt2")
gen.generate("Once upon a time", max_tokens=100, num_return=3)

GPT-2 Fine-tuning

from bforbuntyai import TextFineTuner, dataset

data = dataset.HuggingFace("amazon_polarity", split="train[:200]")
tuner = TextFineTuner(dataset=data)
tuner.train(epochs=3)
tuner.generate("This product is")
tuner.save("./my-gpt2")

Stable Diffusion

from bforbuntyai import StableDiffusion, auth

auth.login()    # required for some model versions
sd = StableDiffusion()
sd.generate("A sunset over mountains, 4K photo", n=4, steps=20)

BLIP Image Captioning

from bforbuntyai import ImageCaptioner

cap = ImageCaptioner()
cap.caption("photo.jpg")
cap.caption("https://example.com/image.jpg")
cap.visualize(["img1.jpg", "img2.jpg", "img3.jpg"])

Ethical Evaluation

from bforbuntyai import EthicalEvaluator

ev = EthicalEvaluator()
ev.evaluate("Some text to check for toxicity and bias")
ev.evaluate_batch(["text one", "text two", "text three"])

Supported Datasets

Dataset Class Used by
MNIST dataset.MNIST() AutoEncoder, GAN, DCGAN, cGAN, VAE
Fashion-MNIST dataset.FashionMNIST() GAN, DCGAN, VAE
CIFAR-10 dataset.CIFAR10() AutoEncoder
HuggingFace dataset.HuggingFace("name", split="...") TextFineTuner
Edges2Shoes dataset.Edges2Shoes() Pix2Pix
Custom folder dataset.Custom("path/", image_size=64) Any image model

Common API

Every model shares the same interface:

Method Description
.train(epochs=...) Train the model, returns self for chaining
.generate(n=...) Generate samples
.visualize() Plot results with matplotlib
.save(path) Save model weights
.load(path) Load model weights

Cache

Downloaded datasets and models are cached at ~/.bforbuntyai/cache/.

Metadata

Release files for bforbuntyai 0.2.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for bforbuntyai 0.2.2
File Size Uploaded
bforbuntyai-0.2.2.tar.gz 29.9 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for bforbuntyai 0.2.2
File Interpreter ABI Platform
bforbuntyai-0.2.2-py3-none-any.whl Python 3 none any Details

Total release size: 66.4 kB

Release files / bforbuntyai-0.2.2.tar.gz

Download URL bforbuntyai-0.2.2.tar.gz
Size 29.9 kB
Tags Source
SHA-256 checksum
How to use checksums
cbec06dd09004c530ae1ce7cdc699a8d6e16fb7a2a8ba970b5c6b0b08ecda84e
BLAKE2b-256 checksum
How to use checksums
1e667bb7e1b90abe53f84ac6b5281284074ca4cdd12916ffa88615d35450ee99
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.11.9

Release files / bforbuntyai-0.2.2-py3-none-any.whl

Download URL bforbuntyai-0.2.2-py3-none-any.whl
Size 36.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
0af22a636c1e2749e5485c34c24c3d25a16b4d4ad393538c1b056903a813d2ee
BLAKE2b-256 checksum
How to use checksums
ef5caec6670a59827cf12ee9de064f3d20900f6a739f60cf8dc120e893d3d571
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.11.9

Release history Release notifications | RSS feed

This release

0.2.2 This release

2 release files

0.2.1

2 release files

0.2.0

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page