return seed
This commit is contained in:
parent
32854d40da
commit
3e4021ec0d
@ -50,17 +50,19 @@ export default async function inpaint(
|
|||||||
fd.append('sizeLimit', sizeLimit)
|
fd.append('sizeLimit', sizeLimit)
|
||||||
}
|
}
|
||||||
|
|
||||||
const res = await fetch(`${API_ENDPOINT}/inpaint`, {
|
try {
|
||||||
method: 'POST',
|
const res = await fetch(`${API_ENDPOINT}/inpaint`, {
|
||||||
body: fd,
|
method: 'POST',
|
||||||
}).then(async r => {
|
body: fd,
|
||||||
if (r.ok) {
|
})
|
||||||
return r.blob()
|
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.')
|
throw new Error('Something went wrong on server side.')
|
||||||
})
|
}
|
||||||
|
|
||||||
return URL.createObjectURL(res)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export function switchModel(name: string) {
|
export function switchModel(name: string) {
|
||||||
|
@ -35,6 +35,7 @@ import {
|
|||||||
isSDState,
|
isSDState,
|
||||||
propmtState,
|
propmtState,
|
||||||
runManuallyState,
|
runManuallyState,
|
||||||
|
seedState,
|
||||||
settingState,
|
settingState,
|
||||||
toastState,
|
toastState,
|
||||||
} from '../../store/Atoms'
|
} from '../../store/Atoms'
|
||||||
@ -86,6 +87,7 @@ export default function Editor(props: EditorProps) {
|
|||||||
const { file } = props
|
const { file } = props
|
||||||
const promptVal = useRecoilValue(propmtState)
|
const promptVal = useRecoilValue(propmtState)
|
||||||
const settings = useRecoilValue(settingState)
|
const settings = useRecoilValue(settingState)
|
||||||
|
const [seedVal, setSeed] = useRecoilState(seedState)
|
||||||
const croperRect = useRecoilValue(croperState)
|
const croperRect = useRecoilValue(croperState)
|
||||||
const [toastVal, setToastState] = useRecoilState(toastState)
|
const [toastVal, setToastState] = useRecoilState(toastState)
|
||||||
const [isInpainting, setIsInpainting] = useRecoilState(isInpaintingState)
|
const [isInpainting, setIsInpainting] = useRecoilState(isInpaintingState)
|
||||||
@ -220,8 +222,12 @@ export default function Editor(props: EditorProps) {
|
|||||||
if (!res) {
|
if (!res) {
|
||||||
throw new Error('empty response')
|
throw new Error('empty response')
|
||||||
}
|
}
|
||||||
|
const { blob, seed } = res
|
||||||
|
if (seed) {
|
||||||
|
setSeed(parseInt(seed, 10))
|
||||||
|
}
|
||||||
const newRender = new Image()
|
const newRender = new Image()
|
||||||
await loadImage(newRender, res)
|
await loadImage(newRender, blob)
|
||||||
const newRenders = [...renders, newRender]
|
const newRenders = [...renders, newRender]
|
||||||
setRenders(newRenders)
|
setRenders(newRenders)
|
||||||
draw(newRender, [])
|
draw(newRender, [])
|
||||||
|
@ -44,7 +44,7 @@ function NumberInputSetting(props: NumberInputSettingProps) {
|
|||||||
<NumberInput
|
<NumberInput
|
||||||
allowFloat={allowFloat}
|
allowFloat={allowFloat}
|
||||||
style={{ width: `${width}${widthUnit}` }}
|
style={{ width: `${width}${widthUnit}` }}
|
||||||
value={`${value}`}
|
value={value}
|
||||||
disabled={disable}
|
disabled={disable}
|
||||||
onValue={onValue}
|
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'
|
import TextInput from './Input'
|
||||||
|
|
||||||
interface NumberInputProps extends InputHTMLAttributes<HTMLInputElement> {
|
interface NumberInputProps extends InputHTMLAttributes<HTMLInputElement> {
|
||||||
@ -12,6 +17,10 @@ const NumberInput = React.forwardRef<HTMLInputElement, NumberInputProps>(
|
|||||||
const { value, allowFloat, onValue, ...itemProps } = props
|
const { value, allowFloat, onValue, ...itemProps } = props
|
||||||
const [innerValue, setInnerValue] = useState(value)
|
const [innerValue, setInnerValue] = useState(value)
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
setInnerValue(value)
|
||||||
|
}, [value])
|
||||||
|
|
||||||
const handleOnInput = (evt: FormEvent<HTMLInputElement>) => {
|
const handleOnInput = (evt: FormEvent<HTMLInputElement>) => {
|
||||||
const target = evt.target as HTMLInputElement
|
const target = evt.target as HTMLInputElement
|
||||||
let val = target.value
|
let val = target.value
|
||||||
|
@ -270,6 +270,18 @@ export const settingState = atom<Settings>({
|
|||||||
effects: [localStorageEffect(ROOT_STATE_KEY)],
|
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({
|
export const hdSettingsState = selector({
|
||||||
key: 'hdSettings',
|
key: 'hdSettings',
|
||||||
get: ({ get }) => {
|
get: ({ get }) => {
|
||||||
|
@ -26,7 +26,7 @@ try:
|
|||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
from flask import Flask, request, send_file, cli
|
from flask import Flask, request, send_file, cli, make_response
|
||||||
|
|
||||||
# Disable ability for Flask to display warning about using a development server in a production environment.
|
# Disable ability for Flask to display warning about using a development server in a production environment.
|
||||||
# https://gist.github.com/jerblack/735b9953ba1ab6234abb43174210d356
|
# https://gist.github.com/jerblack/735b9953ba1ab6234abb43174210d356
|
||||||
@ -112,14 +112,12 @@ def process():
|
|||||||
hd_strategy_crop_margin=form["hdStrategyCropMargin"],
|
hd_strategy_crop_margin=form["hdStrategyCropMargin"],
|
||||||
hd_strategy_crop_trigger_size=form["hdStrategyCropTrigerSize"],
|
hd_strategy_crop_trigger_size=form["hdStrategyCropTrigerSize"],
|
||||||
hd_strategy_resize_limit=form["hdStrategyResizeLimit"],
|
hd_strategy_resize_limit=form["hdStrategyResizeLimit"],
|
||||||
|
prompt=form["prompt"],
|
||||||
prompt=form['prompt'],
|
use_croper=form["useCroper"],
|
||||||
use_croper=form['useCroper'],
|
croper_x=form["croperX"],
|
||||||
croper_x=form['croperX'],
|
croper_y=form["croperY"],
|
||||||
croper_y=form['croperY'],
|
croper_height=form["croperHeight"],
|
||||||
croper_height=form['croperHeight'],
|
croper_width=form["croperWidth"],
|
||||||
croper_width=form['croperWidth'],
|
|
||||||
|
|
||||||
sd_strength=form["sdStrength"],
|
sd_strength=form["sdStrength"],
|
||||||
sd_steps=form["sdSteps"],
|
sd_steps=form["sdSteps"],
|
||||||
sd_guidance_scale=form["sdGuidanceScale"],
|
sd_guidance_scale=form["sdGuidanceScale"],
|
||||||
@ -153,10 +151,15 @@ def process():
|
|||||||
)
|
)
|
||||||
|
|
||||||
ext = get_image_ext(origin_image_bytes)
|
ext = get_image_ext(origin_image_bytes)
|
||||||
return send_file(
|
|
||||||
io.BytesIO(numpy_to_bytes(res_np_img, ext)),
|
response = make_response(
|
||||||
mimetype=f"image/{ext}",
|
send_file(
|
||||||
|
io.BytesIO(numpy_to_bytes(res_np_img, ext)),
|
||||||
|
mimetype=f"image/{ext}",
|
||||||
|
)
|
||||||
)
|
)
|
||||||
|
response.headers["X-Seed"] = str(config.sd_seed)
|
||||||
|
return response
|
||||||
|
|
||||||
|
|
||||||
@app.route("/model")
|
@app.route("/model")
|
||||||
@ -210,8 +213,12 @@ def main(args):
|
|||||||
device = torch.device(args.device)
|
device = torch.device(args.device)
|
||||||
input_image_path = args.input
|
input_image_path = args.input
|
||||||
|
|
||||||
model = ModelManager(name=args.model, device=device, hf_access_token=args.hf_access_token,
|
model = ModelManager(
|
||||||
callbacks=[diffuser_callback])
|
name=args.model,
|
||||||
|
device=device,
|
||||||
|
hf_access_token=args.hf_access_token,
|
||||||
|
callbacks=[diffuser_callback],
|
||||||
|
)
|
||||||
|
|
||||||
if args.gui:
|
if args.gui:
|
||||||
app_width, app_height = args.gui_size
|
app_width, app_height = args.gui_size
|
||||||
|
Loading…
Reference in New Issue
Block a user