-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(ui): add dynamic prompts to t2i tab
- add param accordion for dynamic prompts - update graphs
- Loading branch information
1 parent
9cfac41
commit 6390af2
Showing
29 changed files
with
479 additions
and
576 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
45 changes: 45 additions & 0 deletions
45
invokeai/frontend/web/src/features/dynamicPrompts/components/ParamDynamicPromptsCollapse.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
import { createSelector } from '@reduxjs/toolkit'; | ||
import { stateSelector } from 'app/store/store'; | ||
import { useAppDispatch, useAppSelector } from 'app/store/storeHooks'; | ||
import { defaultSelectorOptions } from 'app/store/util/defaultMemoizeOptions'; | ||
import IAICollapse from 'common/components/IAICollapse'; | ||
import { useCallback } from 'react'; | ||
import { isEnabledToggled } from '../store/slice'; | ||
import ParamDynamicPromptsMaxPrompts from './ParamDynamicPromptsMaxPrompts'; | ||
import ParamDynamicPromptsCombinatorial from './ParamDynamicPromptsCombinatorial'; | ||
import { Flex } from '@chakra-ui/react'; | ||
|
||
const selector = createSelector( | ||
stateSelector, | ||
(state) => { | ||
const { isEnabled } = state.dynamicPrompts; | ||
|
||
return { isEnabled }; | ||
}, | ||
defaultSelectorOptions | ||
); | ||
|
||
const ParamDynamicPromptsCollapse = () => { | ||
const dispatch = useAppDispatch(); | ||
const { isEnabled } = useAppSelector(selector); | ||
|
||
const handleToggleIsEnabled = useCallback(() => { | ||
dispatch(isEnabledToggled()); | ||
}, [dispatch]); | ||
|
||
return ( | ||
<IAICollapse | ||
isOpen={isEnabled} | ||
onToggle={handleToggleIsEnabled} | ||
label="Dynamic Prompts" | ||
withSwitch | ||
> | ||
<Flex sx={{ gap: 2, flexDir: 'column' }}> | ||
<ParamDynamicPromptsMaxPrompts /> | ||
<ParamDynamicPromptsCombinatorial /> | ||
</Flex> | ||
</IAICollapse> | ||
); | ||
}; | ||
|
||
export default ParamDynamicPromptsCollapse; |
36 changes: 36 additions & 0 deletions
36
.../frontend/web/src/features/dynamicPrompts/components/ParamDynamicPromptsCombinatorial.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import { useAppDispatch, useAppSelector } from 'app/store/storeHooks'; | ||
import { combinatorialToggled } from '../store/slice'; | ||
import { createSelector } from '@reduxjs/toolkit'; | ||
import { defaultSelectorOptions } from 'app/store/util/defaultMemoizeOptions'; | ||
import { useCallback } from 'react'; | ||
import { stateSelector } from 'app/store/store'; | ||
import IAISwitch from 'common/components/IAISwitch'; | ||
|
||
const selector = createSelector( | ||
stateSelector, | ||
(state) => { | ||
const { combinatorial } = state.dynamicPrompts; | ||
|
||
return { combinatorial }; | ||
}, | ||
defaultSelectorOptions | ||
); | ||
|
||
const ParamDynamicPromptsCombinatorial = () => { | ||
const { combinatorial } = useAppSelector(selector); | ||
const dispatch = useAppDispatch(); | ||
|
||
const handleChange = useCallback(() => { | ||
dispatch(combinatorialToggled()); | ||
}, [dispatch]); | ||
|
||
return ( | ||
<IAISwitch | ||
label="Combinatorial Generation" | ||
isChecked={combinatorial} | ||
onChange={handleChange} | ||
/> | ||
); | ||
}; | ||
|
||
export default ParamDynamicPromptsCombinatorial; |
53 changes: 53 additions & 0 deletions
53
...eai/frontend/web/src/features/dynamicPrompts/components/ParamDynamicPromptsMaxPrompts.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
import { useAppDispatch, useAppSelector } from 'app/store/storeHooks'; | ||
import IAISlider from 'common/components/IAISlider'; | ||
import { maxPromptsChanged, maxPromptsReset } from '../store/slice'; | ||
import { createSelector } from '@reduxjs/toolkit'; | ||
import { defaultSelectorOptions } from 'app/store/util/defaultMemoizeOptions'; | ||
import { useCallback } from 'react'; | ||
import { stateSelector } from 'app/store/store'; | ||
|
||
const selector = createSelector( | ||
stateSelector, | ||
(state) => { | ||
const { maxPrompts } = state.dynamicPrompts; | ||
const { min, sliderMax, inputMax } = | ||
state.config.sd.dynamicPrompts.maxPrompts; | ||
|
||
return { maxPrompts, min, sliderMax, inputMax }; | ||
}, | ||
defaultSelectorOptions | ||
); | ||
|
||
const ParamDynamicPromptsMaxPrompts = () => { | ||
const { maxPrompts, min, sliderMax, inputMax } = useAppSelector(selector); | ||
const dispatch = useAppDispatch(); | ||
|
||
const handleChange = useCallback( | ||
(v: number) => { | ||
dispatch(maxPromptsChanged(v)); | ||
}, | ||
[dispatch] | ||
); | ||
|
||
const handleReset = useCallback(() => { | ||
dispatch(maxPromptsReset()); | ||
}, [dispatch]); | ||
|
||
return ( | ||
<IAISlider | ||
label="Max Prompts" | ||
min={min} | ||
max={sliderMax} | ||
value={maxPrompts} | ||
onChange={handleChange} | ||
sliderNumberInputProps={{ max: inputMax }} | ||
withSliderMarks | ||
withInput | ||
inputReadOnly | ||
withReset | ||
handleReset={handleReset} | ||
/> | ||
); | ||
}; | ||
|
||
export default ParamDynamicPromptsMaxPrompts; |
1 change: 1 addition & 0 deletions
1
invokeai/frontend/web/src/features/dynamicPrompts/store/selectors.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
// |
50 changes: 50 additions & 0 deletions
50
invokeai/frontend/web/src/features/dynamicPrompts/store/slice.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
import { PayloadAction, createSlice } from '@reduxjs/toolkit'; | ||
import { RootState } from 'app/store/store'; | ||
|
||
export interface DynamicPromptsState { | ||
isEnabled: boolean; | ||
maxPrompts: number; | ||
combinatorial: boolean; | ||
} | ||
|
||
export const initialDynamicPromptsState: DynamicPromptsState = { | ||
isEnabled: false, | ||
maxPrompts: 100, | ||
combinatorial: true, | ||
}; | ||
|
||
const initialState: DynamicPromptsState = initialDynamicPromptsState; | ||
|
||
export const dynamicPromptsSlice = createSlice({ | ||
name: 'dynamicPrompts', | ||
initialState, | ||
reducers: { | ||
maxPromptsChanged: (state, action: PayloadAction<number>) => { | ||
state.maxPrompts = action.payload; | ||
}, | ||
maxPromptsReset: (state) => { | ||
state.maxPrompts = initialDynamicPromptsState.maxPrompts; | ||
}, | ||
combinatorialToggled: (state) => { | ||
state.combinatorial = !state.combinatorial; | ||
}, | ||
isEnabledToggled: (state) => { | ||
state.isEnabled = !state.isEnabled; | ||
}, | ||
}, | ||
extraReducers: (builder) => { | ||
// | ||
}, | ||
}); | ||
|
||
export const { | ||
isEnabledToggled, | ||
maxPromptsChanged, | ||
maxPromptsReset, | ||
combinatorialToggled, | ||
} = dynamicPromptsSlice.actions; | ||
|
||
export default dynamicPromptsSlice.reducer; | ||
|
||
export const dynamicPromptsSelector = (state: RootState) => | ||
state.dynamicPrompts; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.