mirror of
https://github.com/easydiffusion/easydiffusion.git
synced 2025-02-18 03:11:10 +01:00
Report errors if Stable Diffusion failed to generate an image
This commit is contained in:
parent
c1c876e12d
commit
83e3288177
31
index.html
31
index.html
@ -119,6 +119,12 @@ async function makeImage() {
|
|||||||
|
|
||||||
let outputMsg = document.querySelector('#outputMsg')
|
let outputMsg = document.querySelector('#outputMsg')
|
||||||
|
|
||||||
|
function logError(msg, res) {
|
||||||
|
outputMsg.innerHTML = '<span style="color: red">Error: ' + msg + '</span>'
|
||||||
|
console.log('request error', res)
|
||||||
|
setStatus('request', 'error', 'error')
|
||||||
|
}
|
||||||
|
|
||||||
let reqBody = {
|
let reqBody = {
|
||||||
prompt: document.querySelector('#prompt').value,
|
prompt: document.querySelector('#prompt').value,
|
||||||
num_outputs: document.querySelector('#num_outputs').value,
|
num_outputs: document.querySelector('#num_outputs').value,
|
||||||
@ -139,18 +145,23 @@ async function makeImage() {
|
|||||||
},
|
},
|
||||||
body: JSON.stringify(reqBody)
|
body: JSON.stringify(reqBody)
|
||||||
})
|
})
|
||||||
res = await res.json()
|
|
||||||
|
|
||||||
if (res.status !== 'succeeded') {
|
if (res.status != 200) {
|
||||||
if (res.detail !== undefined) {
|
logError('Stable Diffusion had an error: ' + await res.text() + '. This happens some times. Maybe modify the prompt or seed a bit?', res)
|
||||||
outputMsg.innerHTML = 'Error: ' + res.detail[0].msg + " in " + JSON.stringify(res.detail[0].loc)
|
|
||||||
} else {
|
|
||||||
outputMsg.innerHTML = 'Error: ' + res
|
|
||||||
}
|
|
||||||
outputMsg.innerHTML = '<span style="color: red">' + outputMsg.innerHTML + '</span>'
|
|
||||||
console.log('request error', res)
|
|
||||||
setStatus('request', 'error', 'error')
|
|
||||||
res = undefined
|
res = undefined
|
||||||
|
} else {
|
||||||
|
res = await res.json()
|
||||||
|
|
||||||
|
if (res.status !== 'succeeded') {
|
||||||
|
let msg = ''
|
||||||
|
if (res.detail !== undefined) {
|
||||||
|
msg = res.detail[0].msg + " in " + JSON.stringify(res.detail[0].loc)
|
||||||
|
} else {
|
||||||
|
msg = res
|
||||||
|
}
|
||||||
|
logError(msg, res)
|
||||||
|
res = undefined
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.log('request error', e)
|
console.log('request error', e)
|
||||||
|
1
main.py
1
main.py
@ -49,7 +49,6 @@ async def image(req : ImageRequest):
|
|||||||
del data['input']['seed']
|
del data['input']['seed']
|
||||||
|
|
||||||
res = requests.post(PREDICT_URL, json=data)
|
res = requests.post(PREDICT_URL, json=data)
|
||||||
print(res)
|
|
||||||
return res.json()
|
return res.json()
|
||||||
|
|
||||||
@app.get('/ding.mp3')
|
@app.get('/ding.mp3')
|
||||||
|
Loading…
Reference in New Issue
Block a user