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.
To install BananaGan, you can use pip:
pip install bananagan
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()
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 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.
This project is licensed under the MIT License.