-
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: add Tile Image Processor to Linear UI
- Loading branch information
1 parent
182e2fd
commit 3dc5566
Showing
11 changed files
with
277 additions
and
123 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
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
76 changes: 76 additions & 0 deletions
76
...eb/src/features/controlLayers/components/ControlAndIPAdapter/processors/TileProcessor.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,76 @@ | ||
import type { ComboboxOnChange } from '@invoke-ai/ui-library'; | ||
import { Combobox, CompositeNumberInput, CompositeSlider, FormControl, FormLabel } from '@invoke-ai/ui-library'; | ||
import { isTileProcessorMode, type TileProcessorMode } from 'features/controlAdapters/store/types'; | ||
import type { ProcessorComponentProps } from 'features/controlLayers/components/ControlAndIPAdapter/processors/types'; | ||
import { CA_PROCESSOR_DATA, type TileProcessorConfig } from 'features/controlLayers/util/controlAdapters'; | ||
import { memo, useCallback, useMemo } from 'react'; | ||
import { useTranslation } from 'react-i18next'; | ||
|
||
import ProcessorWrapper from './ProcessorWrapper'; | ||
|
||
type Props = ProcessorComponentProps<TileProcessorConfig>; | ||
const DEFAULTS = CA_PROCESSOR_DATA['tile_image_processor'].buildDefaults(); | ||
|
||
export const TileProcessor = memo(({ onChange, config }: Props) => { | ||
const { t } = useTranslation(); | ||
|
||
const tileModeOptions: { label: string; value: TileProcessorMode }[] = useMemo( | ||
() => [ | ||
{ label: t('controlnet.regular'), value: 'regular' }, | ||
{ label: t('controlnet.blur'), value: 'blur' }, | ||
{ label: t('controlnet.variation'), value: 'var' }, | ||
{ label: t('controlnet.super'), value: 'super' }, | ||
], | ||
[t] | ||
); | ||
|
||
const tileModeValue = useMemo(() => tileModeOptions.find((o) => o.value === config.mode), [tileModeOptions, config]); | ||
|
||
const handleTileModeChange = useCallback<ComboboxOnChange>( | ||
(v) => { | ||
if (!isTileProcessorMode(v?.value)) { | ||
return; | ||
} | ||
onChange({ ...config, mode: v.value }); | ||
}, | ||
[config, onChange] | ||
); | ||
|
||
const handleDownSamplingRateChanged = useCallback( | ||
(v: number) => { | ||
onChange({ ...config, down_sampling_rate: v }); | ||
}, | ||
[config, onChange] | ||
); | ||
|
||
return ( | ||
<ProcessorWrapper> | ||
<FormControl> | ||
<FormLabel m={0}>{t('controlnet.mode')}</FormLabel> | ||
<Combobox value={tileModeValue} options={tileModeOptions} onChange={handleTileModeChange} /> | ||
</FormControl> | ||
<FormControl> | ||
<FormLabel m={0}>{t('controlnet.downsamplingRate')}</FormLabel> | ||
<CompositeSlider | ||
value={config.down_sampling_rate} | ||
onChange={handleDownSamplingRateChanged} | ||
defaultValue={DEFAULTS.down_sampling_rate} | ||
min={0} | ||
max={5} | ||
step={0.1} | ||
marks | ||
/> | ||
<CompositeNumberInput | ||
value={config.down_sampling_rate} | ||
onChange={handleDownSamplingRateChanged} | ||
defaultValue={DEFAULTS.down_sampling_rate} | ||
min={0} | ||
max={5} | ||
step={0.1} | ||
/> | ||
</FormControl> | ||
</ProcessorWrapper> | ||
); | ||
}); | ||
|
||
TileProcessor.displayName = 'TileProcessor'; |
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
Oops, something went wrong.