fix ISMask in sd
This commit is contained in:
@@ -121,6 +121,9 @@ export default function Editor() {
|
|||||||
// only used while interactive segmentation is on
|
// only used while interactive segmentation is on
|
||||||
const [tmpInteractiveSegMask, setTmpInteractiveSegMask] =
|
const [tmpInteractiveSegMask, setTmpInteractiveSegMask] =
|
||||||
useState<HTMLImageElement | null>(null)
|
useState<HTMLImageElement | null>(null)
|
||||||
|
const [prevInteractiveSegMask, setPrevInteractiveSegMask] = useState<
|
||||||
|
HTMLImageElement | null | undefined
|
||||||
|
>(null)
|
||||||
|
|
||||||
const [clicks, setClicks] = useRecoilState(interactiveSegClicksState)
|
const [clicks, setClicks] = useRecoilState(interactiveSegClicksState)
|
||||||
|
|
||||||
@@ -264,7 +267,7 @@ export default function Editor() {
|
|||||||
if (file === undefined) {
|
if (file === undefined) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
const useCustomMask = customMask !== undefined
|
const useCustomMask = customMask !== undefined && customMask !== null
|
||||||
const useMaskImage = maskImage !== undefined && maskImage !== null
|
const useMaskImage = maskImage !== undefined && maskImage !== null
|
||||||
// useLastLineGroup 的影响
|
// useLastLineGroup 的影响
|
||||||
// 1. 使用上一次的 mask
|
// 1. 使用上一次的 mask
|
||||||
@@ -375,6 +378,7 @@ export default function Editor() {
|
|||||||
drawOnCurrentRender([])
|
drawOnCurrentRender([])
|
||||||
}
|
}
|
||||||
setIsInpainting(false)
|
setIsInpainting(false)
|
||||||
|
setPrevInteractiveSegMask(maskImage)
|
||||||
setTmpInteractiveSegMask(null)
|
setTmpInteractiveSegMask(null)
|
||||||
setInteractiveSegMask(null)
|
setInteractiveSegMask(null)
|
||||||
},
|
},
|
||||||
@@ -396,10 +400,14 @@ export default function Editor() {
|
|||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
emitter.on(EVENT_PROMPT, () => {
|
emitter.on(EVENT_PROMPT, () => {
|
||||||
if (hadDrawSomething()) {
|
if (hadDrawSomething() || interactiveSegMask) {
|
||||||
runInpainting()
|
runInpainting(false, undefined, interactiveSegMask)
|
||||||
} else if (lastLineGroup.length !== 0) {
|
} else if (lastLineGroup.length !== 0) {
|
||||||
runInpainting(true)
|
// 使用上一次手绘的 mask 生成
|
||||||
|
runInpainting(true, undefined, prevInteractiveSegMask)
|
||||||
|
} else if (prevInteractiveSegMask) {
|
||||||
|
// 使用上一次 IS 的 mask 生成
|
||||||
|
runInpainting(false, undefined, prevInteractiveSegMask)
|
||||||
} else {
|
} else {
|
||||||
setToastState({
|
setToastState({
|
||||||
open: true,
|
open: true,
|
||||||
@@ -413,7 +421,13 @@ export default function Editor() {
|
|||||||
return () => {
|
return () => {
|
||||||
emitter.off(EVENT_PROMPT)
|
emitter.off(EVENT_PROMPT)
|
||||||
}
|
}
|
||||||
}, [hadDrawSomething, runInpainting, promptVal])
|
}, [
|
||||||
|
hadDrawSomething,
|
||||||
|
runInpainting,
|
||||||
|
promptVal,
|
||||||
|
interactiveSegMask,
|
||||||
|
prevInteractiveSegMask,
|
||||||
|
])
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
emitter.on(EVENT_CUSTOM_MASK, (data: any) => {
|
emitter.on(EVENT_CUSTOM_MASK, (data: any) => {
|
||||||
@@ -1037,7 +1051,7 @@ export default function Editor() {
|
|||||||
useHotKey(
|
useHotKey(
|
||||||
'i',
|
'i',
|
||||||
() => {
|
() => {
|
||||||
if (!isInteractiveSeg) {
|
if (!isInteractiveSeg && isOriginalLoaded) {
|
||||||
setIsInteractiveSeg(true)
|
setIsInteractiveSeg(true)
|
||||||
if (interactiveSegMask !== null) {
|
if (interactiveSegMask !== null) {
|
||||||
setShowInteractiveSegModal(true)
|
setShowInteractiveSegModal(true)
|
||||||
@@ -1045,7 +1059,7 @@ export default function Editor() {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
{},
|
{},
|
||||||
[isInteractiveSeg, interactiveSegMask]
|
[isInteractiveSeg, interactiveSegMask, isOriginalLoaded]
|
||||||
)
|
)
|
||||||
|
|
||||||
// Standard Hotkeys for Brush Size
|
// Standard Hotkeys for Brush Size
|
||||||
@@ -1366,7 +1380,7 @@ export default function Editor() {
|
|||||||
toolTip="Interactive Segmentation"
|
toolTip="Interactive Segmentation"
|
||||||
tooltipPosition="top"
|
tooltipPosition="top"
|
||||||
icon={<CursorArrowRaysIcon />}
|
icon={<CursorArrowRaysIcon />}
|
||||||
disabled={isInteractiveSeg || isInpainting}
|
disabled={isInteractiveSeg || isInpainting || !isOriginalLoaded}
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
setIsInteractiveSeg(true)
|
setIsInteractiveSeg(true)
|
||||||
if (interactiveSegMask !== null) {
|
if (interactiveSegMask !== null) {
|
||||||
|
|||||||
@@ -142,6 +142,7 @@ const SidePanel = () => {
|
|||||||
|
|
||||||
<SettingBlock
|
<SettingBlock
|
||||||
title="Match Histograms"
|
title="Match Histograms"
|
||||||
|
desc="Match the inpainting result histogram to the source image histogram, will improves the inpainting quality for some images."
|
||||||
input={
|
input={
|
||||||
<Switch
|
<Switch
|
||||||
checked={setting.sdMatchHistograms}
|
checked={setting.sdMatchHistograms}
|
||||||
|
|||||||
Reference in New Issue
Block a user