Illustrator¶
Illustrator is a superclient that allows you to create SVG illustrations from simple textual descriptions. Leveraging large language models (LLMs), it transforms your ideas into visuals. The quality of the generated illustrations is improved through inference-time reasoning and user feedback, ensuring precise and refined results.
Basic Usage¶
Here is a simple example of how to use Illustrator:
from switchai import SwitchAI, Illustrator
client = SwitchAI(provider="openai", model_name="gpt-4o")
illustrator = Illustrator(client)
illustrator.generate_illustration(
"Design a futuristic logo for my AI app with a sleek, modern aesthetic. "
"The logo should feature a black background with rounded corners for a "
"smooth and polished look. Inside, create a minimalist flower design that "
"embodies innovation and elegance. Use clean lines and subtle gradients or "
"highlights to give it a sophisticated, high-tech feel, while maintaining "
"simplicity and balance.",
output_path="logo.svg",
)
The above code generates an SVG file named logo.svg based on the description provided. For example, it might look like this:
Editor Mode¶
Illustrator also supports an editor mode, allowing you to interactively edit illustrations generated by the model. To enable this mode, set the editor_mode parameter to True. This mode allows you to provide feedback and request changes to the illustration while considering the context of the generated visuals.
Revision Steps¶
Illustrator supports a revision process that allows for the automatic refinement of generated illustrations. In this process, there are two agents: an author and a critic. The author is responsible for generating and modifying the illustration, while the critic provides feedback and requests changes. The author revises the illustration based on the critic’s feedback. This iterative process continues until the critic is satisfied with the illustration or the specified max_revision_steps is reached.
To use this feature, set the max_revision_steps parameter to the desired number of steps. You can also set it to a large number to allow revisions to continue until the critic is satisfied. Note that this feature requires the use of a vision LLM.
Image Reference¶
Illustrator supports providing a reference image to guide the model in generating illustrations. This can enhance the relevance of the output when using vision LLMs. To use a reference image, specify the image_reference parameter:
from switchai import SwitchAI, Illustrator
client = SwitchAI(provider="openai", model_name="gpt-4o")
illustrator = Illustrator(client)
illustrator.generate_illustration(
"Design a logo for a tech company with a modern, sleek aesthetic. "
"The logo should feature two intertwining, minimalistic rectangles, "
"similar to the reference image provided, with clean lines and a professional feel.",
output_path="logo.svg",
image_reference="path/to/image.jpg",
max_revision_steps=12,
editor_mode=True,
)
Here is the reference image and the generated illustration:
While LLMs are not primarily trained for tasks like illustration generation, the results can still be impressive, even with their current vision capabilities.
Illustrator can also generate illustrations based on a photo. For example, you can provide a sunset image, and the model will create an illustration inspired by it:
Final Notes¶
Generating and editing illustrations is an enjoyable and creative process. However, be mindful of the cost of API calls, as they can become expensive. We tested various models, each with its strengths and weaknesses. Since no model is perfect, you may need to experiment with different ones to achieve the best results.