{ "cells": [ { "cell_type": "code", "execution_count": 2, "id": "555dce1f-2f19-428c-bf46-7ad90e294d0e", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "3.9.16 | packaged by conda-forge | (main, Feb 1 2023, 21:38:11) \n", "[Clang 14.0.6 ]\n" ] } ], "source": [ "# use svg graphics, display inline\n", "%matplotlib inline\n", "%config InlineBackend.figure_format = 'svg'\n", "\n", "import glob\n", "import re\n", "import copy\n", "import sys\n", "\n", "# basic scientific computing imports\n", "import pandas as pd\n", "import numpy as np\n", "\n", "# ai\n", "from tqdm.notebook import tnrange, tqdm\n", "from langchain.chat_models import ChatOpenAI\n", "from langchain.chains import LLMChain\n", "from langchain.llms import OpenAI\n", "from langchain.prompts import PromptTemplate\n", "\n", "np.random.seed(42)\n", "\n", "# Don't usually do this but OpenAI an langchain throw lots of warnings\n", "import warnings\n", "warnings.filterwarnings(\"ignore\")\n", "\n", "print(sys.version)" ] }, { "cell_type": "markdown", "id": "3e17a345-8e99-42c3-843b-ea169f083271", "metadata": {}, "source": [ "# Objective\n", "Create a program that designs a creative family photoshoot for every US holiday\n", "\n", "# Steps\n", "- Generate a list of us holidays and dates\n", "- Generate a photoshoot for each holiday\n", "- Generate a midjourney prompt for each shoot\n", "- Generate a shopping list for each one" ] }, { "cell_type": "code", "execution_count": 3, "id": "052bdca9-78df-4626-a2cc-3cb3dbbcac08", "metadata": {}, "outputs": [], "source": [ "def convert_string_to_tuples(holiday_string):\n", " return [tuple(line.split(', ')) for line in holiday_string.split('\\n')]" ] }, { "cell_type": "code", "execution_count": 4, "id": "50507c02-905d-4d33-8ac1-fd1843b84dcd", "metadata": {}, "outputs": [ { "data": { "text/plain": [ "[('01/01', \"New Year's Day\"),\n", " ('01/18', 'Martin Luther King Jr. Day'),\n", " ('02/12', 'Lunar New Year (approximate date)'),\n", " ('02/14', \"Valentine's Day\"),\n", " ('03/17', \"St. Patrick's Day\"),\n", " ('04/04', 'Easter (approximate date)'),\n", " ('05/09', \"Mother's Day\"),\n", " ('05/31', 'Memorial Day'),\n", " ('06/19', 'Juneteenth'),\n", " ('06/20', \"Father's Day\"),\n", " ('07/04', 'Independence Day'),\n", " ('09/06', 'Labor Day'),\n", " ('10/11', 'Columbus Day'),\n", " ('10/31', 'Halloween'),\n", " ('11/11', 'Veterans Day'),\n", " ('11/25', 'Thanksgiving Day'),\n", " ('12/24', 'Christmas Eve'),\n", " ('12/25', 'Christmas Day'),\n", " ('',),\n", " ('South Korean Holidays:',),\n", " ('01/01', \"New Year's Day\"),\n", " ('03/01', 'Independence Movement Day'),\n", " ('05/05', \"Children's Day\"),\n", " ('06/06', 'Memorial Day'),\n", " ('08/15', 'Liberation Day'),\n", " ('09/20', 'Chuseok (approximate date)'),\n", " ('10/03', 'National Foundation Day'),\n", " ('10/09', 'Hangul Proclamation Day')]" ] }, "execution_count": 4, "metadata": {}, "output_type": "execute_result" } ], "source": [ "generate_holidays_prompt = '''\n", "Generate a list of all widely celebrated US holidays. Include unofficial but fun holidays like Halloween and Father's day.\n", "Be sure to include Lunar New Year (use an approximate date if necessary)\n", "Include a few major South Korean holidays as well.\n", "\n", "Example:\n", "01/01, New Year's Day\n", "10/31, Halloween\n", "\n", "List of Holidays:\n", "'''\n", "\n", "llm = OpenAI(model_name='gpt-4', temperature=0.4)\n", "holidays_string = llm(generate_holidays_prompt)\n", "holidays_data = convert_string_to_tuples(holidays_string)\n", "\n", "holidays_data" ] }, { "cell_type": "markdown", "id": "f35cc7ad-3d5d-4cb9-8af3-6f701caec9d7", "metadata": {}, "source": [ "### Clean up the list" ] }, { "cell_type": "code", "execution_count": 6, "id": "3058b057-3511-4c18-9e17-952891dfca43", "metadata": {}, "outputs": [], "source": [ "holidays_data = [x for x in holidays_data if '/' in x[0] and len(x) == 2]\n", "holidays_data.sort(key=lambda x: x[0])" ] }, { "cell_type": "markdown", "id": "3531a092-a46c-4dee-9dc1-5e078456cc98", "metadata": {}, "source": [ "### Generate the data" ] }, { "cell_type": "code", "execution_count": 8, "id": "699c05da-f976-4525-a987-900b1712cb04", "metadata": {}, "outputs": [ { "data": { "application/vnd.jupyter.widget-view+json": { "model_id": "d1074ee1c22c471cba1d2f53a19c8727", "version_major": 2, "version_minor": 0 }, "text/plain": [ " 0%| | 0/26 [00:00._completion_with_retry in 4.0 seconds as it raised APIConnectionError: Error communicating with OpenAI: ('Connection aborted.', TimeoutError(60, 'Operation timed out')).\n" ] } ], "source": [ "generate_shopping_list_prompt = '''\n", "### Task\n", "Generate a list of things a photographer would need to buy to put on the following photoshoot.\n", "\n", "### Photoshoot description\n", "{description}\n", "\n", "### Shopping list\n", "'''\n", "\n", "shopping_lists = []\n", "for shoot in tqdm(photoshoot_concepts):\n", " llm = OpenAI(model_name='gpt-3.5-turbo', temperature=0.4)\n", " shopping_list = llm(generate_shopping_list_prompt.format(description=shoot))\n", " shopping_lists.append(shopping_list)\n", " \n", "\n", "# shopping_lists[0]" ] }, { "cell_type": "code", "execution_count": 21, "id": "15ec7e8c-8298-4860-a2b1-0067b8cb3552", "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
dateholidaytitlephotoshoot_descriptionmidjourney_promptshopping_list
001/01New Year's DayBaby's First New Year's SparkleConcept: For this New Year's Day themed photos...Our star of the portrait, a 7-month-old baby g...1. White or light gray backdrop\\n2. Cute, whit...
101/01New Year's DayA New Year's Baby DreamConcept: For this New Year's Day themed photos...Our 7-month-old baby girl will be the star of ...1. Soft, pastel-colored canvas or printed fabr...
201/18Martin Luther King Jr. DayDreaming of a Brighter FutureConcept: This portrait photo will be a tribute...With a light blue sky background and fluffy wh...1. Light blue backdrop fabric\\n2. Soft, fluffy...
302/12Lunar New Year (approximate date)Baby Blossoms for Lunar New YearConcept: For this photoshoot, we will incorpor...Incorporating the Lunar New Year theme, we wil...1. Silk cherry blossoms\\n2. Small red lanterns...
402/14Valentine's DayCupid's Littlest LoveConcept: For this Valentine's Day themed photo...Transform your 7-month-old baby girl into a li...1. Soft, pastel pink backdrop\\n2. Tiny white h...
503/01Independence Movement DayLittle Lady LibertyConcept: For this Independence Movement Day th...Our little Lady Liberty photoshoot will captur...1. Soft, green onesie\\n2. Small, lightweight, ...
603/17St. Patrick's DayLuck of the Irish BabyConcept: For this St. Patrick's Day-themed pho...Surrounded by elements of Irish folklore and c...1. Soft, pastel green backdrop fabric or hand-...
704/04Easter (approximate date)Easter BlossomsConcept: For this Easter-themed photoshoot, th...Surrounded by the vibrant colors and symbols o...1. Camera\\n2. Lens (preferably a portrait lens...
805/05Children's DayBlooming Joy on Children's DayConcept: For this Children's Day-themed photos...Surrounded by a mini flower garden, our 7-mont...1. Canvas backdrop in soft shades of lavender ...
905/09Mother's DayMommy's Little FlowerConcept: For this Mother's Day themed photosho...\"Little Flower Blossom\"\\n\\nTransform the 7-mon...1. Light pastel-colored fabric for backdrop\\n2...
1005/31Memorial DayLittle PatriotConcept: For this Memorial Day-themed portrait...In a serene outdoor setting, a lush green park...1. Camera\\n2. Lens (preferably a portrait lens...
1106/06Memorial DayLittle PatriotConcept: For this Memorial Day-themed photosho...In a serene outdoor setting, such as a park or...1. Soft, navy blue blanket\\n2. Small American ...
1206/19JuneteenthFreedom's BlossomConcept: For this Juneteenth-inspired photosho...In honor of Juneteenth, we will capture the sp...1. Solid-colored backdrop in a soft shade of l...
1306/20Father's DayDaddy's Little HelperConcept: For this Father's Day-themed photosho...Capture the heartwarming bond between a father...1. Toy tools (hammer, wrench, screwdriver)\\n2....
1407/04Independence DayBaby FirecrackerConcept: For this Independence Day-themed phot...Capture the joy and excitement of Independence...1. White backdrop or American flag patterned b...
1508/15Liberation DayLittle Lady LibertyConcept: For this Liberation Day-themed photos...Transform the 7-month-old baby girl into a cha...1. Solid-colored backdrop in a soft shade of b...
1609/06Labor DayLittle Worker BeeConcept: For this Labor Day-themed photoshoot,...Transform the 7-month-old baby girl into a cut...1. Camera and lenses\\n2. Lighting equipment (s...
1709/20Chuseok (approximate date)Baby's First Chuseok: A Harvest Moon DreamConcept: For this Chuseok-inspired portrait ph...In this enchanting portrait photoshoot, we wil...1. Crescent moon prop (wood or foam)\\n2. Plush...
1810/03National Foundation DayLittle Builder of TomorrowConcept: For National Foundation Day, we will ...In a cozy, well-lit space, we will capture the...1. Age-appropriate and safe building blocks ma...
1910/09Hangul Proclamation DayLittle Princess of HangulConcept: For this Hangul Proclamation Day phot...Incorporating the beauty and significance of t...1. Soft, pastel-colored hanok backdrop\\n2. Tra...
2010/11Columbus DayLittle ExplorerConcept: For this Columbus Day-themed photosho...Transport the 7-month-old baby girl back in ti...1. Vintage-looking world map backdrop\\n2. Mini...
2110/31HalloweenLittle Pumpkin PrincessConcept: For this Halloween-themed portrait ph...Surrounded by the warm colors of autumn, our 7...1. Seamless, warm-toned brown or orange fabric...
2211/11Veterans DayLittle PatriotConcept: For this Veterans Day-themed photosho...In honor of Veterans Day, we will capture the ...1. American flag backdrop\\n2. White dress with...
2311/25Thanksgiving DayLittle Turkey's First ThanksgivingConcept: For this Thanksgiving-themed portrait...Capture the essence of \"Little Turkey's First ...1. Brown onesie or bodysuit with turkey face p...
2412/24Christmas EveA Starry Christmas EveConcept: For this Christmas Eve-themed photosh...In this magical Christmas Eve-themed photoshoo...1. Deep blue backdrop\\n2. Twinkling fairy ligh...
2512/25Christmas DaySanta's Little HelperConcept: For this charming Christmas Day portr...In this heartwarming Christmas Day portrait, w...1. Rustic wooden wall backdrop\\n2. Twinkling f...
\n", "
" ], "text/plain": [ " date holiday \\\n", "0 01/01 New Year's Day \n", "1 01/01 New Year's Day \n", "2 01/18 Martin Luther King Jr. Day \n", "3 02/12 Lunar New Year (approximate date) \n", "4 02/14 Valentine's Day \n", "5 03/01 Independence Movement Day \n", "6 03/17 St. Patrick's Day \n", "7 04/04 Easter (approximate date) \n", "8 05/05 Children's Day \n", "9 05/09 Mother's Day \n", "10 05/31 Memorial Day \n", "11 06/06 Memorial Day \n", "12 06/19 Juneteenth \n", "13 06/20 Father's Day \n", "14 07/04 Independence Day \n", "15 08/15 Liberation Day \n", "16 09/06 Labor Day \n", "17 09/20 Chuseok (approximate date) \n", "18 10/03 National Foundation Day \n", "19 10/09 Hangul Proclamation Day \n", "20 10/11 Columbus Day \n", "21 10/31 Halloween \n", "22 11/11 Veterans Day \n", "23 11/25 Thanksgiving Day \n", "24 12/24 Christmas Eve \n", "25 12/25 Christmas Day \n", "\n", " title \\\n", "0 Baby's First New Year's Sparkle \n", "1 A New Year's Baby Dream \n", "2 Dreaming of a Brighter Future \n", "3 Baby Blossoms for Lunar New Year \n", "4 Cupid's Littlest Love \n", "5 Little Lady Liberty \n", "6 Luck of the Irish Baby \n", "7 Easter Blossoms \n", "8 Blooming Joy on Children's Day \n", "9 Mommy's Little Flower \n", "10 Little Patriot \n", "11 Little Patriot \n", "12 Freedom's Blossom \n", "13 Daddy's Little Helper \n", "14 Baby Firecracker \n", "15 Little Lady Liberty \n", "16 Little Worker Bee \n", "17 Baby's First Chuseok: A Harvest Moon Dream \n", "18 Little Builder of Tomorrow \n", "19 Little Princess of Hangul \n", "20 Little Explorer \n", "21 Little Pumpkin Princess \n", "22 Little Patriot \n", "23 Little Turkey's First Thanksgiving \n", "24 A Starry Christmas Eve \n", "25 Santa's Little Helper \n", "\n", " photoshoot_description \\\n", "0 Concept: For this New Year's Day themed photos... \n", "1 Concept: For this New Year's Day themed photos... \n", "2 Concept: This portrait photo will be a tribute... \n", "3 Concept: For this photoshoot, we will incorpor... \n", "4 Concept: For this Valentine's Day themed photo... \n", "5 Concept: For this Independence Movement Day th... \n", "6 Concept: For this St. Patrick's Day-themed pho... \n", "7 Concept: For this Easter-themed photoshoot, th... \n", "8 Concept: For this Children's Day-themed photos... \n", "9 Concept: For this Mother's Day themed photosho... \n", "10 Concept: For this Memorial Day-themed portrait... \n", "11 Concept: For this Memorial Day-themed photosho... \n", "12 Concept: For this Juneteenth-inspired photosho... \n", "13 Concept: For this Father's Day-themed photosho... \n", "14 Concept: For this Independence Day-themed phot... \n", "15 Concept: For this Liberation Day-themed photos... \n", "16 Concept: For this Labor Day-themed photoshoot,... \n", "17 Concept: For this Chuseok-inspired portrait ph... \n", "18 Concept: For National Foundation Day, we will ... \n", "19 Concept: For this Hangul Proclamation Day phot... \n", "20 Concept: For this Columbus Day-themed photosho... \n", "21 Concept: For this Halloween-themed portrait ph... \n", "22 Concept: For this Veterans Day-themed photosho... \n", "23 Concept: For this Thanksgiving-themed portrait... \n", "24 Concept: For this Christmas Eve-themed photosh... \n", "25 Concept: For this charming Christmas Day portr... \n", "\n", " midjourney_prompt \\\n", "0 Our star of the portrait, a 7-month-old baby g... \n", "1 Our 7-month-old baby girl will be the star of ... \n", "2 With a light blue sky background and fluffy wh... \n", "3 Incorporating the Lunar New Year theme, we wil... \n", "4 Transform your 7-month-old baby girl into a li... \n", "5 Our little Lady Liberty photoshoot will captur... \n", "6 Surrounded by elements of Irish folklore and c... \n", "7 Surrounded by the vibrant colors and symbols o... \n", "8 Surrounded by a mini flower garden, our 7-mont... \n", "9 \"Little Flower Blossom\"\\n\\nTransform the 7-mon... \n", "10 In a serene outdoor setting, a lush green park... \n", "11 In a serene outdoor setting, such as a park or... \n", "12 In honor of Juneteenth, we will capture the sp... \n", "13 Capture the heartwarming bond between a father... \n", "14 Capture the joy and excitement of Independence... \n", "15 Transform the 7-month-old baby girl into a cha... \n", "16 Transform the 7-month-old baby girl into a cut... \n", "17 In this enchanting portrait photoshoot, we wil... \n", "18 In a cozy, well-lit space, we will capture the... \n", "19 Incorporating the beauty and significance of t... \n", "20 Transport the 7-month-old baby girl back in ti... \n", "21 Surrounded by the warm colors of autumn, our 7... \n", "22 In honor of Veterans Day, we will capture the ... \n", "23 Capture the essence of \"Little Turkey's First ... \n", "24 In this magical Christmas Eve-themed photoshoo... \n", "25 In this heartwarming Christmas Day portrait, w... \n", "\n", " shopping_list \n", "0 1. White or light gray backdrop\\n2. Cute, whit... \n", "1 1. Soft, pastel-colored canvas or printed fabr... \n", "2 1. Light blue backdrop fabric\\n2. Soft, fluffy... \n", "3 1. Silk cherry blossoms\\n2. Small red lanterns... \n", "4 1. Soft, pastel pink backdrop\\n2. Tiny white h... \n", "5 1. Soft, green onesie\\n2. Small, lightweight, ... \n", "6 1. Soft, pastel green backdrop fabric or hand-... \n", "7 1. Camera\\n2. Lens (preferably a portrait lens... \n", "8 1. Canvas backdrop in soft shades of lavender ... \n", "9 1. Light pastel-colored fabric for backdrop\\n2... \n", "10 1. Camera\\n2. Lens (preferably a portrait lens... \n", "11 1. Soft, navy blue blanket\\n2. Small American ... \n", "12 1. Solid-colored backdrop in a soft shade of l... \n", "13 1. Toy tools (hammer, wrench, screwdriver)\\n2.... \n", "14 1. White backdrop or American flag patterned b... \n", "15 1. Solid-colored backdrop in a soft shade of b... \n", "16 1. Camera and lenses\\n2. Lighting equipment (s... \n", "17 1. Crescent moon prop (wood or foam)\\n2. Plush... \n", "18 1. Age-appropriate and safe building blocks ma... \n", "19 1. Soft, pastel-colored hanok backdrop\\n2. Tra... \n", "20 1. Vintage-looking world map backdrop\\n2. Mini... \n", "21 1. Seamless, warm-toned brown or orange fabric... \n", "22 1. American flag backdrop\\n2. White dress with... \n", "23 1. Brown onesie or bodysuit with turkey face p... \n", "24 1. Deep blue backdrop\\n2. Twinkling fairy ligh... \n", "25 1. Rustic wooden wall backdrop\\n2. Twinkling f... " ] }, "execution_count": 21, "metadata": {}, "output_type": "execute_result" } ], "source": [ "df = (\n", " pd.DataFrame({\n", " 'date': [x[0] for x in holidays_data],\n", " 'holiday': [x[1] for x in holidays_data],\n", " 'photoshoot_description': photoshoot_concepts,\n", " 'midjourney_prompt': prompts,\n", " 'shopping_list': shopping_lists,\n", " })\n", " .assign(\n", " title=lambda d: d.photoshoot_description.str.split('\"', expand=True)[1],\n", " photoshoot_description=lambda d: d.photoshoot_description.str.split('\\n\\n', n=1, expand=True)[1]\n", " )\n", " [['date', 'holiday', 'title', 'photoshoot_description', 'midjourney_prompt', 'shopping_list']]\n", ")\n", "\n", "# df.sort_values('date').to_clipboard(sep='\\t', index=False)\n", "# df.to_excel()\n", "df" ] } ], "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 }