Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Python code that leverages a language model (such as LLaMA) to generate images featuring basic shapes in 2D or 3D. The script randomly selects shapes, colors, and areas to create diverse visuals. It continuously generates images based on AI-generated code, validates them, and provides feedback for iterative improvements.

License

Notifications You must be signed in to change notification settings

jaypatel15406/Ollama-Adaptive-Image-Code-Gen

Repository files navigation

🦙 Ollama Adaptive Image Code Gen 🧠

Fun Fact : - LLMs can sometimes “hallucinate” information, which means they might generate details that sound plausible but are made up. It’s like when someone tells a creative but fictional story and you’re unsure if they’re joking or serious!


Project WorkFlow and What it actually do 😏

  1. Please refer 'Control Flow Diagram' of Application before moving ahead 👇

OLLaMa Image Adaptive Code Gen WorkFlow

  1. What Does this application actually do ❔

    1. First, it initiates the LLaMa 3.1 8B LLM Model using ollama. You can also change the LLM model if you want to by editing the path config/config.json ([For Using Model within Python Code]) and entrypoint.sh ([For Pulling ModelFiles]).

    2. Then, the LLM model chooses: Dimension, Shape, Color, and Area. It then generates the Python code for drawing an Image with the same specifications. The generated code will be stored at the path: oLLaMa_generated_code_dir/generated_code.py.

    3. Then, it will install all the dependencies required before executing generated_code.py. After the successful installation of the necessary modules, it will execute generated_code.py.

    4. The Generated Code is also sent back to the LLM Model for verification to ensure all Specifications mentioned in the image are met. If the verification is successful, the execution will stop with Exit Code: 0. Otherwise, it will Rectify the Generated Code and repeat all the steps from Step No. iii mentioned above.

Just a small catch 🙈 : This application is totally Asynchronous in nature.


Application Setup Guidelines 📑

  1. Dependency Installations

    • Make an virtual enviorment and install all the necessary components to run the 'Application'
    virtualenv venv
    
    • Activate your virtual enviorment
    - For MacOS:
        source venv/bin/activate
    
    - For Windows:
        venv\Scripts\activate.bat
    
    • Install all the necessary ingredients from requirements.txt file:
    pip3 install -r requirements.txt
    

To Learn More About virtualenv: Click Here

  1. Project setup and Containarization

    • Start 'Docker Desktop' application and open terminal in your 'Working directory' [Where docker-compose.yaml and Dockerfile is located]. Then run below given command to 'Build' an oLLaMa Image
    docker compose build
    
    • After completion of the 'Image Building' process. It's time to compose up LLM in our Local System using:
    docker compose up
    
    • NOTE: Compose up process might upto 20 - 25 Mins. first time. Because it will download all the respective ModelFiles.

For Download guide of Docker Desktop For MacOS: Click Here

For Download guide of Docker Desktop For Windows: Click Here

For Download guide of Docker Desktop for Linux: Click Here

  1. Congratulations 😎, If you reach this step, you're just one step away from running 'Adaptive Image Code Gen LLM' on your local system

    • Let's Press the trigger of an LLM Application by running below command:
    python3 main.py
    

Future Work Enhancements:

  1. We can add a new layer of Image Verification by integrating the LLaVa LLM Model. This model can verify the image with respect to its Contexts and Prompts, which will enhance the Accuracy of the current WorkFlow.

  2. After achieving the results mentioned above, if we obtain satisfactory accuracy, we might integrate Multiple Shapes and Multiple Colors plotting.


To Contribute to the Project:

  1. Choose any open issue from here.
  2. Comment on the Issue: Can I work on this? and Start Exploring it.
  3. Make changes to your Fork and Send a PR.

To Create a PR (Pull Request):

For Creating Valid PR Successfully. Kindly follow Guide: https://help.github.com/articles/creating-a-pull-request/

To Send a PR, Follow Rules Carefully !!

Otherwise your PR will be Closed:

  1. For Appropriate PR, follow Title Format: Fixes #IssueNo : Name of the Issue

For any Doubts related to the Issues, such as understanding Issue better etc., Comment Down your Queries on the Respective Issue.

About

Python code that leverages a language model (such as LLaMA) to generate images featuring basic shapes in 2D or 3D. The script randomly selects shapes, colors, and areas to create diverse visuals. It continuously generates images based on AI-generated code, validates them, and provides feedback for iterative improvements.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published