How to make Image Generation Tool by AI For Free

in this article we will discuss to built an image generator tool by the help of AI, we will use several libraires of python to built this tool.

What is an Image Generator

An Image generation tool is used to generate images online by the help of Ai.

There are Meany ai platforms which provides image generation service like Open Ai.

Image generation tool works based on given prompt, by user , A prompt is a written description of an image which user want to generate like, "A beautiful girl wearing red skirt, long curly hairs, fair color, black shoes, slim back, sharp jaw line, bold figure " if you provides this prompt the ai will generate a detailed image of a girl. and you may get result like this.

how to make image generator toll by Open Source AI.

to make an Image Generator by Open Source you have to make your account on Hugging Face and you have to get Free API from Hugging Face we will use this API as Endpoint to generate images.

Now we will choose an Text to image generation model and check his integration API documentation his limits etc, there we will check in integration section by clicking on Deploy and You may get this type of Code

"async function query(data) {

const response = await fetch(

"https://api-inference.huggingface.co/models/black-forest-labs/FLUX.1-dev",

{

headers: {

Authorization: "Bearer hf_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"

"Content-Type": "application/json",

},

method: "POST",

body: JSON.stringify(data),

}

);

const result = await response.blob();

return result;

}

query({"inputs": "Astronaut riding a horse"}).then((response) => {

// Use image

});"

in this Code you have top replace your API key which you have generated on Hugging Faces.

After replacing your hugging face API You can test this model interface.

Now we need to create Image generator

after finding perfect model we have to create Image generator tool, we will give prompt to chatGPT to create an Image generator, and chat GPT will provide you some Scripts Like App.py, and now you have to create a directory (with your Application Name) and save that files on this directory and open that folder in VS Code,

After That you have to create virtual environment and install dependencies and import required library in this .env folder and test your script, sometimes is runs in a flask server and we will use HTM, and JD combination to display data on frontend and python for Backend, after successful testing of application You can deploy it in online server like AWS. this ids an Application created to Image Genration.

Some Images Generated By this Tool