mirror of
https://github.com/easydiffusion/easydiffusion.git
synced 2025-03-26 06:49:42 +01:00
Downloaded images named with their correct prompt and settings
This commit is contained in:
parent
188894c837
commit
dc402f5f0e
@ -323,9 +323,14 @@ function showImages(reqBody, res, outputContainer, livePreview) {
|
||||
if(typeof res != 'object') return
|
||||
res.output.reverse()
|
||||
res.output.forEach((result, index) => {
|
||||
const imageData = result?.data || result?.path + '?t=' + new Date().getTime()
|
||||
const imageWidth = reqBody.width
|
||||
const imageHeight = reqBody.height
|
||||
const imageData = result?.data || result?.path + '?t=' + new Date().getTime(),
|
||||
imageSeed = result?.seed,
|
||||
imagePrompt = req.prompt,
|
||||
imageInferenceSteps = req.num_inference_steps,
|
||||
imageGuidanceScale = req.guidance_scale,
|
||||
imageWidth = req.width,
|
||||
imageHeight = req.height;
|
||||
|
||||
if (!imageData.includes('/')) {
|
||||
// res contained no data for the image, stop execution
|
||||
setStatus('request', 'invalid image', 'error')
|
||||
@ -350,6 +355,12 @@ function showImages(reqBody, res, outputContainer, livePreview) {
|
||||
imageElem.src = imageData
|
||||
imageElem.width = parseInt(imageWidth)
|
||||
imageElem.height = parseInt(imageHeight)
|
||||
imageElem.setAttribute('data-seed', imageSeed)
|
||||
imageElem.setAttribute('data-prompt', imagePrompt)
|
||||
imageElem.setAttribute('data-steps', imageInferenceSteps)
|
||||
imageElem.setAttribute('data-guidance', imageGuidanceScale)
|
||||
|
||||
|
||||
const imageInfo = imageItemElem.querySelector('.imgItemInfo')
|
||||
imageInfo.style.visibility = (livePreview ? 'hidden' : 'visible')
|
||||
|
||||
@ -412,9 +423,12 @@ function getSaveImageHandler(imageItemElem, outputFormat) {
|
||||
const imageElem = imageItemElem.querySelector('img')
|
||||
const imgData = imageElem.src
|
||||
const imageSeed = imageElem.getAttribute('data-seed')
|
||||
const imagePrompt = imageElem.getAttribute('data-prompt')
|
||||
const imageInferenceSteps = imageElem.getAttribute('data-steps')
|
||||
const imageGuidanceScale = imageElem.getAttribute('data-guidance')
|
||||
|
||||
const imgDownload = document.createElement('a')
|
||||
imgDownload.download = createFileName(imageSeed, outputFormat)
|
||||
imgDownload.download = createFileName(imagePrompt, imageSeed, imageInferenceSteps, imageGuidanceScale, outputFormat)
|
||||
imgDownload.href = imgData
|
||||
imgDownload.click()
|
||||
}
|
||||
@ -942,13 +956,13 @@ function permute(arr) {
|
||||
|
||||
// create a file name with embedded prompt and metadata
|
||||
// for easier cateloging and comparison
|
||||
function createFileName(seed, outputFormat) {
|
||||
function createFileName(prompt, seed, steps, guidance, outputFormat) {
|
||||
|
||||
// Most important information is the prompt
|
||||
let underscoreName = lastPromptUsed.replace(/[^a-zA-Z0-9]/g, '_')
|
||||
let underscoreName = prompt.replace(/[^a-zA-Z0-9]/g, '_')
|
||||
underscoreName = underscoreName.substring(0, 100)
|
||||
const steps = numInferenceStepsField.value
|
||||
const guidance = guidanceScaleField.value
|
||||
//const steps = numInferenceStepsField.value
|
||||
//const guidance = guidanceScaleField.value
|
||||
|
||||
// name and the top level metadata
|
||||
let fileName = `${underscoreName}_Seed-${seed}_Steps-${steps}_Guidance-${guidance}`
|
||||
|
Loading…
Reference in New Issue
Block a user