return seed
This commit is contained in:
@@ -50,17 +50,19 @@ export default async function inpaint(
|
||||
fd.append('sizeLimit', sizeLimit)
|
||||
}
|
||||
|
||||
const res = await fetch(`${API_ENDPOINT}/inpaint`, {
|
||||
method: 'POST',
|
||||
body: fd,
|
||||
}).then(async r => {
|
||||
if (r.ok) {
|
||||
return r.blob()
|
||||
try {
|
||||
const res = await fetch(`${API_ENDPOINT}/inpaint`, {
|
||||
method: 'POST',
|
||||
body: fd,
|
||||
})
|
||||
if (res.ok) {
|
||||
const blob = await res.blob()
|
||||
const seed = res.headers.get('x-seed')
|
||||
return { blob: URL.createObjectURL(blob), seed }
|
||||
}
|
||||
} catch {
|
||||
throw new Error('Something went wrong on server side.')
|
||||
})
|
||||
|
||||
return URL.createObjectURL(res)
|
||||
}
|
||||
}
|
||||
|
||||
export function switchModel(name: string) {
|
||||
|
||||
@@ -35,6 +35,7 @@ import {
|
||||
isSDState,
|
||||
propmtState,
|
||||
runManuallyState,
|
||||
seedState,
|
||||
settingState,
|
||||
toastState,
|
||||
} from '../../store/Atoms'
|
||||
@@ -86,6 +87,7 @@ export default function Editor(props: EditorProps) {
|
||||
const { file } = props
|
||||
const promptVal = useRecoilValue(propmtState)
|
||||
const settings = useRecoilValue(settingState)
|
||||
const [seedVal, setSeed] = useRecoilState(seedState)
|
||||
const croperRect = useRecoilValue(croperState)
|
||||
const [toastVal, setToastState] = useRecoilState(toastState)
|
||||
const [isInpainting, setIsInpainting] = useRecoilState(isInpaintingState)
|
||||
@@ -220,8 +222,12 @@ export default function Editor(props: EditorProps) {
|
||||
if (!res) {
|
||||
throw new Error('empty response')
|
||||
}
|
||||
const { blob, seed } = res
|
||||
if (seed) {
|
||||
setSeed(parseInt(seed, 10))
|
||||
}
|
||||
const newRender = new Image()
|
||||
await loadImage(newRender, res)
|
||||
await loadImage(newRender, blob)
|
||||
const newRenders = [...renders, newRender]
|
||||
setRenders(newRenders)
|
||||
draw(newRender, [])
|
||||
|
||||
@@ -44,7 +44,7 @@ function NumberInputSetting(props: NumberInputSettingProps) {
|
||||
<NumberInput
|
||||
allowFloat={allowFloat}
|
||||
style={{ width: `${width}${widthUnit}` }}
|
||||
value={`${value}`}
|
||||
value={value}
|
||||
disabled={disable}
|
||||
onValue={onValue}
|
||||
/>
|
||||
|
||||
@@ -1,4 +1,9 @@
|
||||
import React, { FormEvent, InputHTMLAttributes, useState } from 'react'
|
||||
import React, {
|
||||
FormEvent,
|
||||
InputHTMLAttributes,
|
||||
useEffect,
|
||||
useState,
|
||||
} from 'react'
|
||||
import TextInput from './Input'
|
||||
|
||||
interface NumberInputProps extends InputHTMLAttributes<HTMLInputElement> {
|
||||
@@ -12,6 +17,10 @@ const NumberInput = React.forwardRef<HTMLInputElement, NumberInputProps>(
|
||||
const { value, allowFloat, onValue, ...itemProps } = props
|
||||
const [innerValue, setInnerValue] = useState(value)
|
||||
|
||||
useEffect(() => {
|
||||
setInnerValue(value)
|
||||
}, [value])
|
||||
|
||||
const handleOnInput = (evt: FormEvent<HTMLInputElement>) => {
|
||||
const target = evt.target as HTMLInputElement
|
||||
let val = target.value
|
||||
|
||||
@@ -270,6 +270,18 @@ export const settingState = atom<Settings>({
|
||||
effects: [localStorageEffect(ROOT_STATE_KEY)],
|
||||
})
|
||||
|
||||
export const seedState = selector({
|
||||
key: 'seed',
|
||||
get: ({ get }) => {
|
||||
const settings = get(settingState)
|
||||
return settings.sdSeed
|
||||
},
|
||||
set: ({ get, set }, newValue: any) => {
|
||||
const settings = get(settingState)
|
||||
set(settingState, { ...settings, sdSeed: newValue })
|
||||
},
|
||||
})
|
||||
|
||||
export const hdSettingsState = selector({
|
||||
key: 'hdSettings',
|
||||
get: ({ get }) => {
|
||||
|
||||
Reference in New Issue
Block a user