Skip to main content

Python library for generating synthetic images of banana diseases using Generative Adversarial Networks (GANs)

Project description

BananaGan

License: MIT

Description

BananaGan is a Python library for generating synthetic images of banana diseases using Generative Adversarial Networks (GANs). It provides a simple API to access the Pix2PixHd pre-trained models for different banana parts and disease types.

Installation

To install BananaGan, you can use pip:

pip install bananagan

Usage

Here are some examples of how to use BananaGan:

1. Generate an image of a pseudostem with Xanthomonas wilt:

from bananagan import *
from PIL import Image
from matplotlib import pyplot as plt

if __name__ == '__main__':
    image_path = "./../images/pseudostem-healthy.png"
    image_color = Image.open(image_path)
    model = BananaGan.get_model(PseudostemModels.xanthomonas_wilt)
    generated_image = model(input_image=image_color, block_size=13, c=1)

    fig = plt.figure(figsize=(10, 10))
    ax = fig.add_subplot(1, 2, 1)
    ax.imshow(image_color)
    ax.axis('off')
    ax.set_title('Original Image')

    ax = fig.add_subplot(1, 2, 2)
    ax.imshow(generated_image)
    ax.axis('off')
    ax.set_title('Generated Image')

    plt.tight_layout()
    plt.show()

Pseudostem with Xanthomonas wilt

2. Generate images with different parameters:

from bananagan import *
from PIL import Image
from matplotlib import pyplot as plt

if __name__ == '__main__':
    image_path = "./../images/pseudostem-healthy.png"
    image_color = Image.open(image_path)
    model = BananaGan.get_model(PseudostemModels.xanthomonas_wilt)

    images = []
    block_size = [3, 5, 7, 9, 11, 13]
    for bsz in block_size:
        generated_image = model(input_image=image_color, block_size=bsz, c=1)
        images.append(generated_image)

    fig = plt.figure(figsize=(10, 5))
    for i, generated_image in enumerate(images):
        ax = fig.add_subplot(1, len(images), i+1)
        ax.imshow(generated_image)
        ax.axis('off')
    plt.tight_layout()
    plt.show()

Pseudostem with Xanthomonas wilt

Available Models

Pseudostem Models:

  • PseudostemModels.healthy: Generates healthy pseudostems.
  • PseudostemModels.xanthomonas_wilt: Generates pseudostems with Xanthomonas wilt.
  • PseudostemModels.fusarium_wilt: Generates pseudostems with Fusarium wilt.

Rachis Models:

  • RachisModels.healthy: Generates healthy rachis.
  • RachisModels.banana_blood_disease: Generates rachis with banana blood disease.

License

This project is licensed under the MIT License.

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

bananagan-0.2.0.tar.gz (17.7 kB view hashes)

Uploaded Source

Built Distribution

bananagan-0.2.0-py3-none-any.whl (21.9 kB view hashes)

Uploaded Python 3

Supported by

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