pollinations.ai: (https://pollinations.ai/)
This is a WRAPPER designed for easy text-image generation.
# Linux/macOS
python3 -m pip install -U pollinations.ai
# Windows
py -3 -m pip install -U pollinations.ai
import pollinations.ai as ai
model: ai.Image = ai.Image()
image: ai.ImageObject = model.generate(
prompt='lion feasting on prey',
model='pixart',
width=1024,
height=1024,
seed=711144046
).save()
print(image.prompt, image.url)
# >>> lion feasting on prey https://image.pollinations.ai/prompt/lion%20feasting%20on%20prey?model=pixart&width=1024&height=1024&seed=711144046
Chatting with text generative ai model:
import pollinations.ai as ai
model: ai.Text = ai.Text()
response: str = model.chat(prompt='What is the meaning of life?')
Setting model filter:
import pollinations.ai as ai
image_generator: ai.Image = ai.Image()
image_generator.set_filter(ai.BANNED_WORDS)
# If any word from a prompt is in the filter it will return an exception.
Batch sample and generation:
import pollinations.ai as ai
batch: list = ai.sample_batch(size=5)
image_generator: ai.Image = ai.Image()
image_generator.generate_batch(prompts=batch, save=True) # OPTIONAL: path # OPTIONAL: naming = 'counter' | naming = 'prompt'
# image_generator.generate_batch(prompts=batch, save=True, path='somefolder', naming='prompt')