autogen/notebook/agentchat_dalle_and_gpt4v.i...

644 lines
903 KiB
Plaintext
Raw Permalink Normal View History

{
"cells": [
{
"cell_type": "markdown",
"id": "2c75da30",
"metadata": {},
"source": [
"# Agent Chat with Multimodal Models: DALLE and GPT-4V\n",
"\n",
"Requires: OpenAI V1. "
]
},
{
"cell_type": "markdown",
"id": "5f51914c",
"metadata": {},
"source": [
"### Before everything starts, install AutoGen with the `lmm` option\n",
"```bash\n",
"pip install \"pyautogen[lmm]>=0.2.3\"\n",
"```"
]
},
{
"cell_type": "code",
"execution_count": 1,
"id": "67d45964",
"metadata": {},
"outputs": [],
"source": [
"import json\n",
"import os\n",
"import pdb\n",
"import random\n",
"import re\n",
"import time\n",
"from typing import Any, Callable, Dict, List, Optional, Tuple, Type, Union\n",
"\n",
"import matplotlib.pyplot as plt\n",
"import PIL\n",
"import requests\n",
"from diskcache import Cache\n",
"from openai import OpenAI\n",
"from PIL import Image\n",
"from termcolor import colored\n",
"\n",
"import autogen\n",
"from autogen import Agent, AssistantAgent, ConversableAgent, UserProxyAgent\n",
"from autogen.agentchat.contrib.img_utils import _to_pil, get_image_data, get_pil_image, gpt4v_formatter\n",
"from autogen.agentchat.contrib.multimodal_conversable_agent import MultimodalConversableAgent"
]
},
{
"cell_type": "code",
"execution_count": 2,
"id": "b1db6f5d",
"metadata": {},
"outputs": [],
"source": [
"config_list_4v = autogen.config_list_from_json(\n",
" \"OAI_CONFIG_LIST\",\n",
" filter_dict={\n",
" \"model\": [\"gpt-4-vision-preview\"],\n",
" },\n",
")\n",
"\n",
"config_list_gpt4 = autogen.config_list_from_json(\n",
" \"OAI_CONFIG_LIST\",\n",
" filter_dict={\n",
" \"model\": [\"gpt-4\", \"gpt-4-0314\", \"gpt4\", \"gpt-4-32k\", \"gpt-4-32k-0314\", \"gpt-4-32k-v0314\"],\n",
" },\n",
")\n",
"\n",
"config_list_dalle = autogen.config_list_from_json(\n",
" \"OAI_CONFIG_LIST\",\n",
" filter_dict={\n",
" \"model\": [\"dalle\"],\n",
" },\n",
")\n",
"\n",
"gpt4_llm_config = {\"config_list\": config_list_gpt4, \"cache_seed\": 42}"
]
},
{
"cell_type": "markdown",
"id": "54de3579",
"metadata": {},
"source": [
"The `config_list_dalle` should be something like:\n",
"\n",
"```python\n",
"[\n",
" {\n",
" 'model': 'dalle',\n",
" 'api_key': 'Your API Key here',\n",
" 'api_version': '2024-02-01'\n",
" }\n",
"]\n",
" ```"
]
},
{
"cell_type": "markdown",
"id": "24850276",
"metadata": {},
"source": [
"## Helper Functions\n",
"\n",
"We first create a warpper for DALLE call, make the "
]
},
{
"cell_type": "code",
"execution_count": 3,
"id": "34a5e2f7",
"metadata": {},
"outputs": [],
"source": [
"def dalle_call(client: OpenAI, model: str, prompt: str, size: str, quality: str, n: int) -> str:\n",
" \"\"\"\n",
" Generate an image using OpenAI's DALL-E model and cache the result.\n",
"\n",
" This function takes a prompt and other parameters to generate an image using OpenAI's DALL-E model.\n",
" It checks if the result is already cached; if so, it returns the cached image data. Otherwise,\n",
" it calls the DALL-E API to generate the image, stores the result in the cache, and then returns it.\n",
"\n",
" Args:\n",
" client (OpenAI): The OpenAI client instance for making API calls.\n",
" model (str): The specific DALL-E model to use for image generation.\n",
" prompt (str): The text prompt based on which the image is generated.\n",
" size (str): The size specification of the image. TODO: This should allow specifying landscape, square, or portrait modes.\n",
" quality (str): The quality setting for the image generation.\n",
" n (int): The number of images to generate.\n",
"\n",
" Returns:\n",
" str: The image data as a string, either retrieved from the cache or newly generated.\n",
"\n",
" Note:\n",
" - The cache is stored in a directory named '.cache/'.\n",
" - The function uses a tuple of (model, prompt, size, quality, n) as the key for caching.\n",
" - The image data is obtained by making a secondary request to the URL provided by the DALL-E API response.\n",
" \"\"\"\n",
" # Function implementation...\n",
" cache = Cache(\".cache/\") # Create a cache directory\n",
" key = (model, prompt, size, quality, n)\n",
" if key in cache:\n",
" return cache[key]\n",
"\n",
" # If not in cache, compute and store the result\n",
" response = client.images.generate(\n",
" model=model,\n",
" prompt=prompt,\n",
" size=size,\n",
" quality=quality,\n",
" n=n,\n",
" )\n",
" image_url = response.data[0].url\n",
" img_data = get_image_data(image_url)\n",
" cache[key] = img_data\n",
"\n",
" return img_data"
]
},
{
"cell_type": "markdown",
"id": "76f4f43d",
"metadata": {},
"source": [
"Here is a helper function to extract image from a DALLE agent. We will show the DALLE agent later."
]
},
{
"cell_type": "code",
"execution_count": 4,
"id": "8fee2643",
"metadata": {},
"outputs": [],
"source": [
"def extract_img(agent: Agent) -> PIL.Image:\n",
" \"\"\"\n",
" Extracts an image from the last message of an agent and converts it to a PIL image.\n",
"\n",
" This function searches the last message sent by the given agent for an image tag,\n",
" extracts the image data, and then converts this data into a PIL (Python Imaging Library) image object.\n",
"\n",
" Parameters:\n",
" agent (Agent): An instance of an agent from which the last message will be retrieved.\n",
"\n",
" Returns:\n",
" PIL.Image: A PIL image object created from the extracted image data.\n",
"\n",
" Note:\n",
" - The function assumes that the last message contains an <img> tag with image data.\n",
" - The image data is extracted using a regular expression that searches for <img> tags.\n",
" - It's important that the agent's last message contains properly formatted image data for successful extraction.\n",
" - The `_to_pil` function is used to convert the extracted image data into a PIL image.\n",
" - If no <img> tag is found, or if the image data is not correctly formatted, the function may raise an error.\n",
" \"\"\"\n",
" last_message = agent.last_message()[\"content\"]\n",
"\n",
" if isinstance(last_message, str):\n",
" img_data = re.findall(\"<img (.*)>\", last_message)[0]\n",
" elif isinstance(last_message, list):\n",
" # The GPT-4V format, where the content is an array of data\n",
" assert isinstance(last_message[0], dict)\n",
" img_data = last_message[0][\"image_url\"][\"url\"]\n",
"\n",
" pil_img = get_pil_image(img_data)\n",
" return pil_img"
]
},
{
"cell_type": "markdown",
"id": "3af86569",
"metadata": {},
"source": [
"## The DALLE Agent"
]
},
{
"cell_type": "code",
"execution_count": 5,
"id": "5558caa2",
"metadata": {},
"outputs": [],
"source": [
"class DALLEAgent(ConversableAgent):\n",
" def __init__(self, name, llm_config: dict, **kwargs):\n",
" super().__init__(name, llm_config=llm_config, **kwargs)\n",
"\n",
" try:\n",
" config_list = llm_config[\"config_list\"]\n",
" api_key = config_list[0][\"api_key\"]\n",
" except Exception as e:\n",
" print(\"Unable to fetch API Key, because\", e)\n",
" api_key = os.getenv(\"OPENAI_API_KEY\")\n",
" self._dalle_client = OpenAI(api_key=api_key)\n",
" self.register_reply([Agent, None], DALLEAgent.generate_dalle_reply)\n",
"\n",
" def send(\n",
" self,\n",
" message: Union[Dict, str],\n",
" recipient: Agent,\n",
" request_reply: Optional[bool] = None,\n",
" silent: Optional[bool] = False,\n",
" ):\n",
" # override and always \"silent\" the send out message;\n",
" # otherwise, the print log would be super long!\n",
" super().send(message, recipient, request_reply, silent=True)\n",
"\n",
" def generate_dalle_reply(self, messages: Optional[List[Dict]], sender: \"Agent\", config):\n",
" \"\"\"Generate a reply using OpenAI DALLE call.\"\"\"\n",
" client = self._dalle_client if config is None else config\n",
" if client is None:\n",
" return False, None\n",
" if messages is None:\n",
" messages = self._oai_messages[sender]\n",
"\n",
" prompt = messages[-1][\"content\"]\n",
" # TODO: integrate with autogen.oai. For instance, with caching for the API call\n",
" img_data = dalle_call(\n",
" client=client,\n",
" model=\"dall-e-3\",\n",
" prompt=prompt,\n",
" size=\"1024x1024\", # TODO: the size should be flexible, deciding landscape, square, or portrait mode.\n",
" quality=\"standard\",\n",
" n=1,\n",
" )\n",
"\n",
" img_data = _to_pil(img_data) # Convert to PIL image\n",
"\n",
" # Return the OpenAI message format\n",
" return True, {\"content\": [{\"type\": \"image_url\", \"image_url\": {\"url\": img_data}}]}"
]
},
{
"cell_type": "markdown",
"id": "dd3f9e56",
"metadata": {},
"source": [
"## Simple Example: Call directly from User"
]
},
{
"cell_type": "code",
"execution_count": 6,
"id": "d4095796",
"metadata": {
"scrolled": false
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"\u001b[33mUser_proxy\u001b[0m (to Dalle):\n",
"\n",
"Create an image with black background, a happy robot is showing a sign with \"I Love AutoGen\".\n",
"\n",
"--------------------------------------------------------------------------------\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"/home/beibinli/autogen/autogen/agentchat/user_proxy_agent.py:83: UserWarning: Using None to signal a default code_execution_config is deprecated. Use {} to use default or False to disable code execution.\n",
" super().__init__(\n",
"/home/beibinli/autogen/autogen/agentchat/conversable_agent.py:954: UserWarning: Cannot extract summary using last_msg: 'list' object has no attribute 'replace'\n",
" warnings.warn(f\"Cannot extract summary using last_msg: {e}\", UserWarning)\n"
]
},
{
"data": {
"text/plain": [
"ChatResult(chat_id=None, chat_history=[{'content': 'Create an image with black background, a happy robot is showing a sign with \"I Love AutoGen\".', 'role': 'assistant'}, {'content': [{'type': 'image_url', 'image_url': {'url': <PIL.PngImagePlugin.PngImageFile image mode=RGB size=1024x1024 at 0x7F8EB52561C0>}}], 'role': 'user'}], summary='', cost=({'total_cost': 0}, {'total_cost': 0}), human_input=[])"
]
},
"execution_count": 6,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"dalle = DALLEAgent(name=\"Dalle\", llm_config={\"config_list\": config_list_dalle})\n",
"\n",
"user_proxy = UserProxyAgent(\n",
" name=\"User_proxy\", system_message=\"A human admin.\", human_input_mode=\"NEVER\", max_consecutive_auto_reply=0\n",
")\n",
"\n",
"# Ask the question with an image\n",
"user_proxy.initiate_chat(\n",
" dalle,\n",
" message=\"\"\"Create an image with black background, a happy robot is showing a sign with \"I Love AutoGen\".\"\"\",\n",
")"
]
},
{
"cell_type": "code",
"execution_count": 7,
"id": "c77ae209",
"metadata": {
"scrolled": false
},
"outputs": [
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAYUAAAGFCAYAAAASI+9IAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjcuMSwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy/bCgiHAAAACXBIWXMAAA9hAAAPYQGoP6dpAAEAAElEQVR4nOz9abBtyXXfB/5W5j7nDm+s9+rVjJonAIUZJA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gars0UcJQUpfgW7bvepUjSK2lbzQ9jGNglCqpFHBYCc5tPkGQdw09620ZhS5lH5XuUIFP7UysG+e/YATPYEBLfxzP4GceCgRfo3h7IxEYsyClVzEA8IDQhCYZzmMwj1ewUXu4927WA3PBsMnpE0UXcaNYVbmOIWrEnjZeNRrlJ9E8Wd1uC0AOxnaRpBB4/uvAwSihZQJdsWtWXvVtOUCnPydvjJZrhDJOjVGe1RSG5G+2aO8lXdfgQDiWq6M01FpQ1V/yA46d5LwHZ/ZcgV7LWOTXMoSzUlqbTopVw7YKBlfgCQ3sb6bG28Y6pCD2m199cNcFQAqPfm5M1BuZqHTDuozD9TQlQdULTPUkGhfS/v6X4VA0+aCclaqXQtwhHNhKldW387KtcqR6Dwp1L6CloFgnaHMbjGXGTCmKLZ9kVQ3G5lcSagEIoGUSNKijYQurYQpIJLfbZ+N1DATFP1fTieJnU3bGP8dH9Gk/JtqVofwHPLzmxtKXonMZ1ZmjDv1+tEY6C/WMxsU1e/MX/vz5C6ia2DR2XGtT7x99IlS4EW8lqYtqNh3zZjRKbxHHKPTvpksfm599smU+umrcpsvUbZ/ej
"text/plain": [
"<Figure size 640x480 with 1 Axes>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"img = extract_img(dalle)\n",
"\n",
"plt.imshow(img)\n",
"plt.axis(\"off\") # Turn off axis numbers\n",
"plt.show()"
]
},
{
"cell_type": "markdown",
"id": "0e59f055",
"metadata": {},
"source": [
"## Example With Critics: Iterate several times to improve"
]
},
{
"cell_type": "code",
"execution_count": 8,
"id": "72214592",
"metadata": {},
"outputs": [],
"source": [
"class DalleCreator(AssistantAgent):\n",
" def __init__(self, n_iters=2, **kwargs):\n",
" \"\"\"\n",
" Initializes a DalleCreator instance.\n",
"\n",
" This agent facilitates the creation of visualizations through a collaborative effort among\n",
" its child agents: dalle and critics.\n",
"\n",
" Parameters:\n",
" - n_iters (int, optional): The number of \"improvement\" iterations to run. Defaults to 2.\n",
" - **kwargs: keyword arguments for the parent AssistantAgent.\n",
" \"\"\"\n",
" super().__init__(**kwargs)\n",
" self.register_reply([Agent, None], reply_func=DalleCreator._reply_user, position=0)\n",
" self._n_iters = n_iters\n",
"\n",
" def _reply_user(self, messages=None, sender=None, config=None):\n",
" if all((messages is None, sender is None)):\n",
" error_msg = f\"Either {messages=} or {sender=} must be provided.\"\n",
" logger.error(error_msg) # noqa: F821\n",
" raise AssertionError(error_msg)\n",
"\n",
" if messages is None:\n",
" messages = self._oai_messages[sender]\n",
"\n",
" img_prompt = messages[-1][\"content\"]\n",
"\n",
" ## Define the agents\n",
" self.critics = MultimodalConversableAgent(\n",
" name=\"Critics\",\n",
" system_message=\"\"\"You need to improve the prompt of the figures you saw.\n",
"How to create a figure that is better in terms of color, shape, text (clarity), and other things.\n",
"Reply with the following format:\n",
"\n",
"CRITICS: the image needs to improve...\n",
"PROMPT: here is the updated prompt!\n",
"\n",
"\"\"\",\n",
" llm_config={\"config_list\": config_list_4v, \"max_tokens\": 1000},\n",
" human_input_mode=\"NEVER\",\n",
" max_consecutive_auto_reply=3,\n",
" )\n",
"\n",
" self.dalle = DALLEAgent(\n",
" name=\"Dalle\", llm_config={\"config_list\": config_list_dalle}, max_consecutive_auto_reply=0\n",
" )\n",
"\n",
" # Data flow begins\n",
" self.send(message=img_prompt, recipient=self.dalle, request_reply=True)\n",
" img = extract_img(self.dalle)\n",
" plt.imshow(img)\n",
" plt.axis(\"off\") # Turn off axis numbers\n",
" plt.show()\n",
" print(\"Image PLOTTED\")\n",
"\n",
" for i in range(self._n_iters):\n",
" # Downsample the image s.t. GPT-4V can take\n",
" img = extract_img(self.dalle)\n",
" smaller_image = img.resize((128, 128), Image.Resampling.LANCZOS)\n",
" smaller_image.save(\"result.png\")\n",
"\n",
" self.msg_to_critics = f\"\"\"Here is the prompt: {img_prompt}.\n",
" Here is the figure <img result.png>.\n",
" Now, critic and create a prompt so that DALLE can give me a better image.\n",
" Show me both \"CRITICS\" and \"PROMPT\"!\n",
" \"\"\"\n",
" self.send(message=self.msg_to_critics, recipient=self.critics, request_reply=True)\n",
" feedback = self._oai_messages[self.critics][-1][\"content\"]\n",
" img_prompt = re.findall(\"PROMPT: (.*)\", feedback)[0]\n",
"\n",
" self.send(message=img_prompt, recipient=self.dalle, request_reply=True)\n",
" img = extract_img(self.dalle)\n",
" plt.imshow(img)\n",
" plt.axis(\"off\") # Turn off axis numbers\n",
" plt.show()\n",
" print(f\"Image {i} PLOTTED\")\n",
"\n",
" return True, \"result.jpg\""
]
},
{
"cell_type": "code",
"execution_count": 9,
"id": "d5883009",
"metadata": {
"scrolled": false
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"\u001b[33mUser\u001b[0m (to DALLE Creator!):\n",
"\n",
"Create an image with black background, a happy robot is showing a sign with \"I Love AutoGen\".\n",
"\n",
"--------------------------------------------------------------------------------\n",
"\u001b[33mDALLE Creator!\u001b[0m (to Dalle):\n",
"\n",
"Create an image with black background, a happy robot is showing a sign with \"I Love AutoGen\".\n",
"\n",
"--------------------------------------------------------------------------------\n"
]
},
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAYUAAAGFCAYAAAASI+9IAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjcuMSwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy/bCgiHAAAACXBIWXMAAA9hAAAPYQGoP6dpAAEAAElEQVR4nOz9abBtyXXfB/5W5j7nDm+s9+rVjJonAIUZJAgOEsBBJCWaEtuSg1K3bUXLjrbD6oi221+6vzii3V+62z3YIUfYlttty5Yt2W6RFEUKIglQIkHMUxWGQhVqQs3Tm+94zs5c/SFzZa597n0ASFNtvKqbwKt7zj57585h5fqvKVeKqipH5agclaNyVI4KEP7nbsBROSpH5agclR+ecgQKR+WoHJWjclRaOQKFo3JUjspROSqtHIHCUTkqR+WoHJVWjkDhqByVo3JUjkorR6BwVI7KUTkqR6WVI1A4KkflqByVo9LKESgclaNyVI7KUWll+EFvDC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ZcgV7LWOTXMoSzUlqbTopVw7YKBlfgCQ3sb6bG28Y6pCD2m199cNcFQAqPfm5M1BuZqHTDuozD9TQlQdULTPUkGhfS/v6X4VA0+aCclaqXQtwhHNhKldW387KtcqR6Dwp1L6CloFgnaHMbjGXGTCmKLZ9kVQ3G5lcSagEIoGUSNKijYQurYQpIJLfbZ+N1DATFP1fTieJnU3bGP8dH9Gk/JtqVofwHPLzmxtKXonMZ1ZmjDv1+tEY6C/WMxsU1e/MX/vz5C6ia2DR2XGtT7x99IlS4EW8lqYtqNh3zZjRKbxHHKPTvpksfm599smU+umrcpsvUbZ/ej
"text/plain": [
"<Figure size 640x480 with 1 Axes>"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"Image PLOTTED\n",
"\u001b[33mDALLE Creator!\u001b[0m (to Critics):\n",
"\n",
"Here is the prompt: Create an image with black background, a happy robot is showing a sign with \"I Love AutoGen\"..\n",
" Here is the figure <image>.\n",
" Now, critic and create a prompt so that DALLE can give me a better image.\n",
" Show me both \"CRITICS\" and \"PROMPT\"!\n",
" \n",
"\n",
"--------------------------------------------------------------------------------\n",
"\u001b[33mCritics\u001b[0m (to DALLE Creator!):\n",
"\n",
"CRITICS: The image needs to improve in the following aspects:\n",
"\n",
"1. Lighting: The robot and the sign could benefit from additional lighting to enhance details and textures, ensuring that they stand out more against the black background.\n",
"2. Legibility: The text on the sign could be more prominent and the font size increased for better readability. Additionally, a contrasting color could be used for the text to ensure it pops against the background.\n",
"3. Robot's Expression: While the robot appears happy, its expression could be made more apparent with clearer facial features or more exaggerated happiness indicators in its body language or facial features.\n",
"4. Composition: The robot and the sign could be positioned in a way that creates a more dynamic composition, keeping the viewers eye engaged.\n",
"5. Resolution: A higher resolution would make the image sharper, improving the overall quality and detail.\n",
"\n",
"PROMPT: Create a high-resolution image with a richly detailed, happy robot made of shiny metal, standing center frame against a stark black background. The robot is holding up a large, rectangular sign with rounded corners that reads \"I ❤️ AutoGen\" in bold, white sans-serif font, with the heart symbol in a vivid red color. The sign should be well-lit with a soft glow that highlights the text and makes it stand out. Ensure the robot's features clearly convey joy, perhaps through a broad smile and posture conveying enthusiasm. The composition should be balanced and visually appealing, with an intelligent use of space that guides the viewer's attention to the robot and the sign.\n",
"\n",
"--------------------------------------------------------------------------------\n",
"\u001b[33mDALLE Creator!\u001b[0m (to Dalle):\n",
"\n",
"Create a high-resolution image with a richly detailed, happy robot made of shiny metal, standing center frame against a stark black background. The robot is holding up a large, rectangular sign with rounded corners that reads \"I ❤️ AutoGen\" in bold, white sans-serif font, with the heart symbol in a vivid red color. The sign should be well-lit with a soft glow that highlights the text and makes it stand out. Ensure the robot's features clearly convey joy, perhaps through a broad smile and posture conveying enthusiasm. The composition should be balanced and visually appealing, with an intelligent use of space that guides the viewer's attention to the robot and the sign.\n",
"\n",
"--------------------------------------------------------------------------------\n"
]
},
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAYUAAAGFCAYAAAASI+9IAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjcuMSwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy/bCgiHAAAACXBIWXMAAA9hAAAPYQGoP6dpAAEAAElEQVR4nOz9Z7AlyZUeCH7HI+Kqp1LLUllaAVUQDaABNApaE83uZguKniFpTY6RtjO2Y7s7y/kxs7Njtmu7tJlZDm25OzNGTRrJacolW5KtgO4G0N3VDaCAQqFUlshKnfnk1RHhZ3+4Ou4R976XWdW2+yO96uW9N8LF8ePHv++4CA9iZsadcCfcCXfCnXAnAFD/vxbgTrgT7oQ74U74/59whxTuhDvhTrgT7gQf7pDCnXAn3Al3wp3gwx1SuBPuhDvhTrgTfLhDCnfCnXAn3Al3gg93SOFOuBPuhDvhTvDhDincCXfCnXAn3Ak+3CGFO+FOuBPuhDvBh/ygEbu9Q6jmYwAMJgLdTmkEgMV3EAgMtp+AvU8EMPs45rv99HlJCRiwOdyWXK2iNvMPwvsKNL4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2leomNMaTTAg6LKM4m3QEjJXWkQghTRRu5wuc+9D781f/qvwYdPo3vvfAqrl27htlsinJeoq5qVFUFrbXxBGHma1mH3UcM+DlvRQRtb2itQRQ+wQxSAJihLOg4eQ1+UfgOAJY48rxAURQoOjl6vQKDXg/9fhe9bgcdRcgJQD1DOZ1gvLeL7e0d7G5u4caVa7h55Rq2NrewNxpibzTCeDrGbDZHqc2UVSjLakoCY9TW8af7LtPHzWkqFm1
"text/plain": [
"<Figure size 640x480 with 1 Axes>"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"Image 0 PLOTTED\n",
"\u001b[33mDALLE Creator!\u001b[0m (to Critics):\n",
"\n",
"Here is the prompt: Create a high-resolution image with a richly detailed, happy robot made of shiny metal, standing center frame against a stark black background. The robot is holding up a large, rectangular sign with rounded corners that reads \"I ❤️ AutoGen\" in bold, white sans-serif font, with the heart symbol in a vivid red color. The sign should be well-lit with a soft glow that highlights the text and makes it stand out. Ensure the robot's features clearly convey joy, perhaps through a broad smile and posture conveying enthusiasm. The composition should be balanced and visually appealing, with an intelligent use of space that guides the viewer's attention to the robot and the sign..\n",
" Here is the figure <image>.\n",
" Now, critic and create a prompt so that DALLE can give me a better image.\n",
" Show me both \"CRITICS\" and \"PROMPT\"!\n",
" \n",
"\n",
"--------------------------------------------------------------------------------\n",
"\u001b[33mCritics\u001b[0m (to DALLE Creator!):\n",
"\n",
"CRITICS: The image could be improved in the following ways:\n",
"\n",
"1. Color Contrast: The overall color contrast between the robot and the sign could be enhanced to make the elements more distinct from one another.\n",
"2. Clarity and Details: The details of the robot's material and structure could be made sharper and more intricate to accentuate its shiny metal look.\n",
"3. Sign's Design: The design of the sign could be simplified by using negative space more effectively, ensuring the message \"I ❤️ AutoGen\" is instantly recognizable and stands out more.\n",
"4. Lighting and Shadows: The lighting could be diversified to cast subtle shadows, which would add depth and volume, making the image more three-dimensional.\n",
"5. Emotion and Posture: The robot's expression and posture could be exaggerated further to emphasize its joyfulness and the message it is conveying.\n",
"6. Background: While the background is appropriately black, adding a subtle texture or gradient could give the image more depth without distracting from the main subject.\n",
"\n",
"PROMPT: Generate a high-resolution 3D rendering of an exuberant, animated-style robot constructed from glossy, reflective metal surfaces. It stands in the center of a pure black background with a soft, radial gradient to provide subtle depth. The robot is displaying a sizable sign with prominent \"I ❤️ AutoGen\" lettering in a bold, white, sans-serif font, the heart being a luminous red, creating a stark, elegant contrast. Incorporate adequate lighting from multiple angles to cast dynamic, gentle shadows around the robot, enhancing its dimensional appearance. Ensure that the robot's facial features and stance radiate delight, featuring an exaggerated smile and arms raised in a victorious, welcoming gesture. The sign should be backlit with a soft halo effect, making it vibrant and eye-catching. The overall composition must be striking yet harmonious, drawing attention to both the robots delighted demeanor and the message it presents.\n",
"\n",
"--------------------------------------------------------------------------------\n",
"\u001b[33mDALLE Creator!\u001b[0m (to Dalle):\n",
"\n",
"Generate a high-resolution 3D rendering of an exuberant, animated-style robot constructed from glossy, reflective metal surfaces. It stands in the center of a pure black background with a soft, radial gradient to provide subtle depth. The robot is displaying a sizable sign with prominent \"I ❤️ AutoGen\" lettering in a bold, white, sans-serif font, the heart being a luminous red, creating a stark, elegant contrast. Incorporate adequate lighting from multiple angles to cast dynamic, gentle shadows around the robot, enhancing its dimensional appearance. Ensure that the robot's facial features and stance radiate delight, featuring an exaggerated smile and arms raised in a victorious, welcoming gesture. The sign should be backlit with a soft halo effect, making it vibrant and eye-catching. The overall composition must be striking yet harmonious, drawing attention to both the robots delighted demeanor and the message it presents.\n",
"\n",
"--------------------------------------------------------------------------------\n"
]
},
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAYUAAAGFCAYAAAASI+9IAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjcuMSwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy/bCgiHAAAACXBIWXMAAA9hAAAPYQGoP6dpAAEAAElEQVR4nOy9d7xtyVEe+lWvvfeJN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L76hxIBoZID8TgCZlZ46V3ouDMpMMmirKpKROvCoBnM35i52VsXWITI8uNEkUs7MrSsspFqQnZ0tdkkQAU3nmc75npGyW7lurEqR4ZWjBULvL8rCthvAeBbWlbO8RCKYbJBpavLdWlwngJH7J6G7ktdDCt90pCo0Y18skOAVPBz+5QylxX+7caFm3Hpu1yIaOXijS7h8fQU7AF5Jby4qHL4j0aI7NbfCri7JZuVj6lIepOUy69tOnteLUV5szLBnKB0ntRCAO6bK7J3GjZbaXIyCIbo8tISKRcAWDSGPxvcbm8UdxGbrgMLGW80eWMpgKytt5EyYGoVcn8HRW8Cc8IuhlC1+6buhf4nqGw0KDvggxoR4+5jF6EJJME6FyTfU95NGQbniJ9RGlOJ4uvhBfcUDkiFG+0UnmPQfhRkj9D3rush8zVaA8LHW0VHmZyoMCbG28rrG0jyuZZyVPJM030yy+Xu9OQeuEiE63hLKFY1dTsKYHtRe6GjEbHu+AtK6182al5xbNLweQUHoeJ5q7a2AYpDUAu/Hma3croSl/m0fW8K9+Shi4jhS73y0RJY/BBmJMSigJ2GySCQY8OgA1gpb6IRFdKrJcXoEypJ6XGgLop2XrwZFdZCyhIzpYuoSoppx12kAtraCzG5UMFsQj1TBM
"text/plain": [
"<Figure size 640x480 with 1 Axes>"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"Image 1 PLOTTED\n",
"\u001b[33mDALLE Creator!\u001b[0m (to User):\n",
"\n",
"result.jpg\n",
"\n",
"--------------------------------------------------------------------------------\n"
]
},
{
"data": {
"text/plain": [
"ChatResult(chat_id=None, chat_history=[{'content': 'Create an image with black background, a happy robot is showing a sign with \"I Love AutoGen\".', 'role': 'assistant'}, {'content': 'result.jpg', 'role': 'user'}], summary='result.jpg', cost=({'total_cost': 0}, {'total_cost': 0}), human_input=[])"
]
},
"execution_count": 9,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"creator = DalleCreator(\n",
" name=\"DALLE Creator!\",\n",
" max_consecutive_auto_reply=0,\n",
" system_message=\"Help me coordinate generating image\",\n",
" llm_config=gpt4_llm_config,\n",
")\n",
"\n",
"user_proxy = UserProxyAgent(name=\"User\", human_input_mode=\"NEVER\", max_consecutive_auto_reply=0)\n",
"\n",
"user_proxy.initiate_chat(\n",
" creator, message=\"\"\"Create an image with black background, a happy robot is showing a sign with \"I Love AutoGen\".\"\"\"\n",
")"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3 (ipykernel)",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.9.16"
}
},
"nbformat": 4,
"nbformat_minor": 5
}