diff --git a/Video_Killed_The_Radio_Star_Defusion.ipynb b/Video_Killed_The_Radio_Star_Defusion.ipynb index dfbe566..78caf2e 100644 --- a/Video_Killed_The_Radio_Star_Defusion.ipynb +++ b/Video_Killed_The_Radio_Star_Defusion.ipynb @@ -266,7 +266,13 @@ "workspace.active_project = project_name\n", "\n", "with open('config.yaml','w') as fp:\n", - " OmegaConf.save(config=workspace, f=fp.name)" + " OmegaConf.save(config=workspace, f=fp.name)\n", + "\n", + "# reset workspace\n", + "if 'df' in locals():\n", + " del df\n", + "if 'df_regen' in locals():\n", + " del df_regen" ] }, { @@ -560,6 +566,10 @@ " 'bool': {'type': 'tickCross'}\n", "}\n", "\n", + "# reset workspace\n", + "if 'df_regen' in locals():\n", + " del df_regen\n", + "\n", "df = pd.DataFrame(prompt_starts).rename(\n", " columns={\n", " 'ts':'Timestamp (sec)',\n", @@ -570,6 +580,8 @@ "if 'td' in df:\n", " del df['td']\n", "\n", + "df['override_prompt'] = ''\n", + "\n", "df_pre = copy.deepcopy(df)\n", "pn.widgets.Tabulator(df, formatters=tabulator_formatters)\n" ] @@ -637,6 +649,7 @@ " for i, rec in enumerate(prompt_starts):\n", " rec['ts'] = float(df.loc[i,'Timestamp (sec)'])\n", " rec['prompt'] = df.loc[i,'Lyric']\n", + " rec['override_prompt'] = df.loc[i,'override_prompt']\n", " \n", " # ...actually, I think the above code might not do anything\n", " # probably need to checkpoint prompt_starts into the storyboard on disk.\n", @@ -709,7 +722,7 @@ "\n", "d_ = dict(\n", " _=''\n", - " , theme_prompt = \"deepdream, mural designed by a local artist\" # @param {type:'string'}\n", + " , theme_prompt = \"deepdeam, mural designed by a local artist\" # @param {type:'string'}\n", " , height = 512 # @param {type:'integer'}\n", " , width = 512 # @param {type:'integer'}\n", " , display_frames_as_we_get_them = True # @param {type:'boolean'}\n", @@ -754,6 +767,9 @@ " regen=True\n", " if regen:\n", " rec['frame0_fpath'] = None\n", + " rec['prompt'] = df_regen.loc[i, 'Lyric']\n", + " rec['override_prompt'] = df_regen.loc[i, 'override_prompt']\n", + " print(rec)\n", " archive_images(i, root=root)\n", " print(\"archival process complete\")\n", "\n", @@ -767,14 +783,22 @@ "\n", "print(\"Ensuring each prompt has an associated image\")\n", "for idx, rec in enumerate(prompt_starts):\n", - " print(\n", - " f\"[{idx} | {rec['ts']}] - {rec['prompt']}\"\n", - " )\n", " lyric = rec['prompt']\n", " prompt = f\"{lyric}, {theme_prompt}\"\n", + " override = rec.get('override_prompt','').strip()\n", + " if override:\n", + " print('override prompt detected')\n", + " prompt = override\n", + " print(\n", + " f\"\\n[{idx} | {rec['ts']}] - {lyric} - {prompt}\"\n", + " )\n", + " \n", " if prompt_lag and (idx > 0):\n", " rec_prev = prompt_starts[idx -1]\n", - " prompt = f\"{rec_prev['prompt']}, {prompt}\"\n", + " prev_prompt = rec_prev['override_prompt']\n", + " if not prev_prompt:\n", + " prev_prompt = rec_prev['prompt']\n", + " prompt = f\"{prev_prompt}, {prompt}\"\n", " if rec.get('frame0_fpath') is None:\n", " init_image = list(get_image_for_prompt(\n", " prompt,\n", @@ -812,7 +836,7 @@ "# flag regens #\n", "###############\n", "\n", - "df_regen = pd.DataFrame(prompt_starts)[['ts','prompt']].rename(\n", + "df_regen = pd.DataFrame(prompt_starts)[['ts','prompt','override_prompt']].rename(\n", " columns={\n", " 'ts':'Timestamp (sec)',\n", " 'prompt':'Lyric',\n", @@ -822,7 +846,7 @@ "df_regen['keep'] = True\n", "\n", "# move the \"keep\" column to the front\n", - "df_regen= df_regen[['keep', 'Timestamp (sec)', 'Lyric']]\n", + "df_regen= df_regen[['keep', 'Timestamp (sec)', 'Lyric', 'override_prompt']]\n", "\n", "pn.widgets.Tabulator(\n", " df_regen,\n", @@ -982,8 +1006,12 @@ " curr_variation_count = len(images_fpaths)\n", " print(curr_variation_count)\n", " if curr_variation_count < n_variations:\n", + " # to do: \n", + " # * prompt lag\n", " lyric = rec['prompt']\n", " prompt = f\"{lyric}, {theme_prompt}\"\n", + " if rec.get('override_prompt'):\n", + " prompt = rec['override_prompt']\n", "\n", " init_image = Image.open(rec['frame0_fpath'])\n", " # next line is here to permit user to specify more variations for a specific entry\n", @@ -1029,9 +1057,14 @@ "from subprocess import Popen, PIPE\n", "\n", "from omegaconf import OmegaConf\n", - "from prefetch_generator import BackgroundGenerator\n", "from tqdm.autonotebook import tqdm\n", "\n", + "try:\n", + " from prefetch_generator import BackgroundGenerator\n", + "except:\n", + " !pip install prefetch_generator \n", + " from prefetch_generator import BackgroundGenerator\n", + "\n", "from vktrs.tsp import (\n", " tsp_permute_frames,\n", " batched_tsp_permute_frames,\n",