A simple lightweight AI Image Generator from text description using Bing Image Creator (DALL-E 3)
Project description
Bing Create
This is a simple lightweight reverse engineered Bing Image Creator API made in python that allows you to quickly generate high quality AI images. This package was inspired by BingImageCreator package and the main goal is to make better version of it.
Advantages over the original package:
- Actively maintained
- Lightweight
- Easier to use
- Ability to specify the number of images to generate
- Termux support
- Complete code rewrite
You can use it from console\terminal or integrate it to your python project. To get started read the instructions below.
Installation
To install the package you can use pip:
pip install bing-create
or you can clone the repository and install it manually:
git clone https://github.com/Waenara/bing-create.git
cd bing_create
pip install .
Usage
Getting cookies
After installing the package as described above you will need to get your _U and SRCHHPGUSR cookies from Bing. You can do this by logging in to Bing, opening the developer tools (F12) and going to the console tab. Then you can run the following code:
console.log(`_U:\n${document.cookie.match(/(?:^|;\s*)_U=(.*?)(?:;|$)/)[1]}\n\nSRCHHPGUSR:\n${document.cookie.match(/(?:^|;\s*)SRCHHPGUSR=(.*?)(?:;|$)/)[1]}`)
This will output your _U and SRCHHPGUSR cookies.
Terminal\Console
If you are an average user you can use the package from the console\terminal. After you installed the package and got the cookies. use the following command to get help, or you may enter arguments from below to generate images:
bing-create
All arguments:
--u
- Your _U cookie--s
- Your SRCHHPGUSR cookie--prompt
- Description of images you want to generate--output
(Optional) - Path to directory where the images will be saved--number
(Optional, default: 4) - Number of images to generate--quiet
(Optional) - If present logging is disabled
Integration to your python project
If you are a developer you can integrate the package to your python project. Here is an example of how you can use the package:
Synchronous:
from bing_create.main import ImageGenerator
# Create an instance of the ImageGenerator class
generator = ImageGenerator(
auth_cookie_u='Your _U cookie',
auth_cookie_srchhpgusr='Your SRCHHPGUSR cookie'
)
# Generate 5 images from a text prompt
images = generator.generate(
prompt='A cute cat',
num_images=5
)
# Save the images to the directory called 'output'
generator.save(
images=images,
output_dir='output'
)
Asynchronous:
import asyncio
from bing_create.main import AsyncImageGenerator
async def main():
# Create an instance of the AsyncImageGenerator class
generator = AsyncImageGenerator(
auth_cookie_u='Your _U cookie',
auth_cookie_srchhpgusr='Your SRCHHPGUSR cookie'
)
# Generate 5 images from a text prompt
images = await generator.generate(
prompt='A cute cat',
num_images=5
)
# Save the images to the directory called 'output'
await generator.save(
images=images,
output_dir='output'
)
asyncio.run(main())
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
Built Distribution
Hashes for bing_create-0.0.6-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8d0909b1cc33c911caaed036500828d0aed652f9c387b17f45326ab971fc662b |
|
MD5 | 3afcc5aa824de99ba6cb83efe50cd691 |
|
BLAKE2b-256 | c156832a3e6f529649e826306e8056e9aba054ae7844f2c24f5d5b2b93822d5d |