Hitmare

Stable diffusion webui API log files

Oct 19th, 2023 (edited)
193
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!

Add the following to your start parameters, where you have added the --api :
--api-log

now open the file stable-diffusion-webui/modules/api/api.py

logging for txt2img:
go to line 364 . there should be the following lines:

        send_images = args.pop('send_images', True)
        args.pop('save_images', None)

beneath those line add the following. Keep in mind to copy&paste as well the 8 spaces in front of every line!

        # writing daily log file for txt2img 
        logfolder = "logs"
        if not os.path.exists(logfolder):
            os.makedirs(logfolder)
        apilogtxt2imgfile = open(f"{datetime.date.today()}-txt2img.txt", "a")
        apilogtxt2imgtext = f"[{datetime.datetime.now()}] Prompt: {txt2imgreq.prompt} | Negative prompt: {txt2imgreq.negative_prompt} | Steps: {txt2imgreq.steps} | Size: {txt2imgreq.width}x{txt2imgreq.height} | CFG: {txt2imgreq.cfg_scale}\n"
        apilogtxt2imgfile.write(apilogtxt2imgtext)

it should now look something like this:

        send_images = args.pop('send_images', True)
        args.pop('save_images', None)
        # writing daily log file for txt2img 
        logfolder = "logs"
        if not os.path.exists(logfolder):
            os.makedirs(logfolder)
        apilogtxt2imgfile = open(f"{datetime.date.today()}-txt2img.txt", "a")
        apilogtxt2imgtext = f"[{datetime.datetime.now()}] Prompt: {txt2imgreq.prompt} | Negative prompt: {txt2imgreq.negative_prompt} | Steps: {txt2imgreq.steps} | Size: {txt2imgreq.width}x{txt2imgreq.height} | CFG: {txt2imgreq.cfg_scale}\n"
        apilogtxt2imgfile.write(apilogtxt2imgtext)

logging for img2img:

go to line 427 . there should be the following lines:

        send_images = args.pop('send_images', True)
        args.pop('save_images', None)

beneath those line add the following. Keep in mind to copy&paste as well the 8 spaces in front of every line!

        # writing daily log file for img2img 
        logfolder = "logs"
        if not os.path.exists(logfolder):
            os.makedirs(logfolder)
        apilogimg2imgfile = open(f"{datetime.date.today()}-img2img.txt", "a")
        apilogimg2imgtext = f"[{datetime.datetime.now()}] Prompt: {img2imgreq.prompt} | Negative prompt: {img2imgreq.negative_prompt} | Steps: {img2imgreq.steps} | Size: {img2imgreq.width}x{img2imgreq.height} | CFG: {img2imgreq.cfg_scale} | Denoising: {img2imgreq.denoising_strength}\n"
        apilogimg2imgfile.write(apilogimg2imgtext)

it should now look something like this:

        send_images = args.pop('send_images', True)
        args.pop('save_images', None)
        # writing daily log file for img2img 
        logfolder = "logs"
        if not os.path.exists(logfolder):
            os.makedirs(logfolder)
        apilogimg2imgfile = open(f"{datetime.date.today()}-img2img.txt", "a")
        apilogimg2imgtext = f"[{datetime.datetime.now()}] Prompt: {img2imgreq.prompt} | Negative prompt: {img2imgreq.negative_prompt} | Steps: {img2imgreq.steps} | Size: {img2imgreq.width}x{img2imgreq.height} | CFG: {img2imgreq.cfg_scale} | Denoising: {img2imgreq.denoising_strength}\n"
        apilogimg2imgfile.write(apilogimg2imgtext)

restart your SD to make the changes to work.

A logfile will now be created in your stable-diffusion-webui folder

Add Comment
Please, Sign In to add comment