amotile / stable-diffusion-studio

An animation focused workflow frontend for Stable Diffusion
MIT License
477 stars 31 forks source link

Data Replace is not a function #11

Closed mischaschaub closed 1 year ago

mischaschaub commented 1 year ago

Get this strange feedback "data replace is not a function" when I try to render a picture. Never happened before. Have reinstalled webui and reinstalled stable-dffusion-studio and restarted the PC. So any hint would be useful...

Loading AUTOMATIC1111 config from: http://localhost:7860/config Socket listening on ws://localhost:4001/ Server listening on http://localhost:4000/ Prompt: fantasy landscape TypeError: data.replace is not a function at Object. (C:\snapshot\stable-diffusion-backend\dist\process-handler.js:87:47) at step (C:\snapshot\stable-diffusion-backend\dist\process-handler.js:44:23) at Object.next (C:\snapshot\stable-diffusion-backend\dist\process-handler.js:25:53) at C:\snapshot\stable-diffusion-backend\dist\process-handler.js:19:71 at new Promise () at C:\snapshot\stable-diffusion-backend\dist\process-handler.js:15:12 at Object.saveBase64 (C:\snapshot\stable-diffusion-backend\dist\process-handler.js:81:20) at Object. (C:\snapshot\stable-diffusion-backend\dist\process\index.js:55:56) at step (C:\snapshot\stable-diffusion-backend\dist\process\index.js:33:23) at Object.next (C:\snapshot\stable-diffusion-backend\dist\process\index.js:14:53)

sungam94 commented 1 year ago

In process-handler.ts use this:

    const saver: FileSaver = {
        async saveBase64(name, data) {
            let location = getFileLocation(name, '.png');
            var base64Data = fs.readFileSync(data.name, 'base64');
            await fs.outputFile(location.stored, base64Data, 'base64');
            return location.access
        },
        async saveJson(name, data) {
            let location = getFileLocation(name, '.json');
            await fs.outputJSON(location.stored, data, {spaces: 2});
            return location.access
        }
    }
MichaelCarychao commented 1 year ago

Thanks @sungam94 that did the trick.

mischaschaub commented 1 year ago

In process-handler.ts use this:

    const saver: FileSaver = {
        async saveBase64(name, data) {
            let location = getFileLocation(name, '.png');
            var base64Data = fs.readFileSync(data.name, 'base64');
            await fs.outputFile(location.stored, base64Data, 'base64');
            return location.access
        },
        async saveJson(name, data) {
            let location = getFileLocation(name, '.json');
            await fs.outputJSON(location.stored, data, {spaces: 2});
            return location.access
        }
    }

Sorry that I am slow - could you explain for a layman, please?

Inscape-Matt commented 1 year ago

Hi, super cool thing you made. Sadly, having the same issue here.

Where can I find process-handler.ts? Searching turns up nothing. Thanks!!

mischaschaub commented 1 year ago

I am getting a bit desperate about this issue. So I set up a completely fresh windows 10 and installed only the webui and stable and I still get the same silly mistake. And this after having run this beauty of an app for several days before, with great pleasure and success. So any help would be truly welcome!

Pipazoul commented 1 year ago

the file process-handler.ts is located in the the backend server under stable-diffusion-backend/src/process-handler.ts

Starting line 67 replace the following lines

 const saver: FileSaver = {
        async saveBase64(name, data) {
            let location = getFileLocation(name, '.png');
            const base64Data = data.replace(/^data:image\/png;base64,/, "");
            await fs.outputFile(location.stored, base64Data, 'base64');
            return location.access
        },
        async saveJson(name, data) {
            let location = getFileLocation(name, '.json');
            await fs.outputJSON(location.stored, data, {spaces: 2});
            return location.access
        }
    }

With thoses

  const saver: FileSaver = {
        async saveBase64(name, data) {
            let location = getFileLocation(name, '.png');
            var base64Data = fs.readFileSync(data.name, 'base64');
            await fs.outputFile(location.stored, base64Data, 'base64');
            return location.access
        },
        async saveJson(name, data) {
            let location = getFileLocation(name, '.json');
            await fs.outputJSON(location.stored, data, {spaces: 2});
            return location.access
        }
    }
amotile commented 1 year ago

Thanks for providing the workaround. I solved it in a different way now but: Newest release should have solved this.