From df9c29f019e117bd40b20e38898c2be01a1257b6 Mon Sep 17 00:00:00 2001 From: Robin Fernandes Date: Wed, 11 Oct 2023 13:25:49 +1100 Subject: [PATCH] Add new section for raw schedule export, so you can use schedules in ComfyUI (via FizzleDorf's schedule nodes), or just paste them directly in Deforum --- src/ParseqUI.js | 17 ++++++ src/components/KeyframeDialogs.tsx | 1 + src/components/ParseqGrid.tsx | 2 +- src/components/RawSchedules.tsx | 84 ++++++++++++++++++++++++++++++ 4 files changed, 103 insertions(+), 1 deletion(-) create mode 100644 src/components/RawSchedules.tsx diff --git a/src/ParseqUI.js b/src/ParseqUI.js index b7b30f1..f2f5a76 100644 --- a/src/ParseqUI.js +++ b/src/ParseqUI.js @@ -29,6 +29,7 @@ import SupportParseq from './components/SupportParseq' import { UserAuthContextProvider } from "./UserAuthContext"; import { AudioWaveform } from './components/AudioWaveform'; import { ExpandableSection } from './components/ExpandableSection'; +import RawSchedules from './components/RawSchedules' import { FieldSelector } from "./components/FieldSelector"; import { InitialisationStatus } from "./components/InitialisationStatus"; import { AddKeyframesDialog, BulkEditDialog, DeleteKeyframesDialog, MergeKeyframesDialog } from './components/KeyframeDialogs'; @@ -1334,6 +1335,15 @@ const ParseqUI = (props) => { }, [displayedFields, showFlatSparklines, renderedData, managedFields, handleClickedSparkline, sparklineData, theme]); + // Raw Schedules ------------------------ + + const rawSchedules = useMemo(() => { + return renderedData + ? + : <>; + + }, [renderedData, managedFields]); + // Raw output ------------------------ @@ -1699,6 +1709,13 @@ const ParseqUI = (props) => { + + + + {rawSchedules} + + + diff --git a/src/components/KeyframeDialogs.tsx b/src/components/KeyframeDialogs.tsx index cd9c706..ebdb90f 100644 --- a/src/components/KeyframeDialogs.tsx +++ b/src/components/KeyframeDialogs.tsx @@ -471,6 +471,7 @@ export const BulkEditDialog: FC = ({ timeSeries: timeSeries, variableMap: new Map([['prev_computed_value', 0]]), computed_values: [], + cadence: 1, } parse(newValue).invoke(dummyContext); } catch (e: any) { diff --git a/src/components/ParseqGrid.tsx b/src/components/ParseqGrid.tsx index 4cdd713..dc6046e 100644 --- a/src/components/ParseqGrid.tsx +++ b/src/components/ParseqGrid.tsx @@ -208,7 +208,7 @@ export const ParseqGrid = forwardRef(({ rangeSelection, onSelectRange, onGridRea && !isValidNumber(params.data[field]) && renderedData && renderedData.rendered_frames - ) { + && renderedData.rendered_frames[frame]) { const renderedValue = renderedData.rendered_frames[frame][field]; return isValidNumber(renderedValue) ? `(${renderedValue})` : ''; } else { diff --git a/src/components/RawSchedules.tsx b/src/components/RawSchedules.tsx new file mode 100644 index 0000000..3a9672e --- /dev/null +++ b/src/components/RawSchedules.tsx @@ -0,0 +1,84 @@ +import { MenuItem, Stack, TextField, Typography } from '@mui/material'; +import * as React from 'react'; +import { useState } from 'react'; +import { RenderedData } from '../ParseqUI'; + +type RawSchedulesProps = { + renderedData: RenderedData; + managedFields: string[]; +} + +export default function RawSchedules({ renderedData, managedFields }: RawSchedulesProps) { + + const [selectedField, setSelectedField] = useState(managedFields ? managedFields[0] : ''); + const [variant, setVariant] = useState<'delta' | 'absolute'>('delta'); + + + const rawSchedule = React.useMemo(() => { + + if (['Prompt', 'PositivePrompt', 'NegativePrompt'].includes(selectedField)) { + return renderedData?.rendered_frames + ?.map(frame => { + const fullPrompt = frame['deforum_prompt']; + const promptPiece = selectedField === 'Prompt' ? fullPrompt + : selectedField === 'PositivePrompt' ? fullPrompt.split('--neg')[0] + : fullPrompt.split('--neg')[1]; + return `"${frame['frame']}": "${promptPiece}"` + }) + ?.join(",\n"); + } else { + return renderedData?.rendered_frames + ?.map(frame => `${frame['frame']}: (${frame[selectedField + (variant === 'delta' ? '_delta' : '')]})`) + ?.join(', '); + } + + }, [renderedData, selectedField, variant]); + + return ( + + + setSelectedField(e.target.value)} + select + size='small' + > + {managedFields?.map(f => {f})} + Full prompt + Positive prompt + Negative prompt + + setVariant(e.target.value as 'delta' | 'absolute')} + select + size='small' + > + Delta values + Absolute values + + + {rawSchedule && selectedField && event.target.select()} + rows={4} + InputProps={{ style: { fontFamily: 'Monospace', fontSize: '0.75em' } }} + value={rawSchedule} + variant="filled" + /> + } + + You use this schedule directly in Deforum, or in ComfyUI using FizzNodes. + + + + + ); +} \ No newline at end of file