RupertAvery / DiffusionToolkit

Metadata-indexer and Viewer for AI-generated images
MIT License
722 stars 44 forks source link

Support extracting metadata from fooocus log.html and appending to images #157

Open VictorZakharov opened 7 months ago

VictorZakharov commented 7 months ago

Is your feature request related to a problem? Please describe. The author of fooocus does not want to include metadata inside images. This makes me unable to publish to civitai, which requires metadata, at minimum the model itself. Otherwise image posts end up in limbo, and nobody will find them.

Describe the solution you'd like Fooocus does provide metadata in a separate file, log.html, which is present in every folder with gens. It would be great to have a tool to feed that metadata back into images and being able to publish and get feedback from civitai peers.

Describe alternatives you've considered Not using Fooocus.

Additional context The format of log.html is many blocks of html like this.

<div id="2023-12-13_07-22-12_6644_png">
<table><tr><td><img src="2023-12-13_07-22-12_6644.png" width=auto height=100% loading=lazy style="height:auto;max-width:512px" onerror="document.getElementById('2023-12-13_07-22-12_6644_png').style.display = 'none';"></img></p></td><td style="padding-left:10px;"><p>2023-12-13_07-22-12_6644.png</p>
<p>Prompt: <b>epic sports car night shot reflections, road</b></p>
<p>Negative Prompt: <b></b></p>
<p>Fooocus V2 Expansion: <b>epic sports car night shot reflections, road, modern, intricate, elegant, highly detailed, extremely sharp focus, fantastic composition, cinematic, fine classic, beautiful, full color, epic light, inspired, rich vivid colors, ambient background, dynamic, strong dramatic professional, glowing, perfect symmetry, atmosphere, best, imposing, clear, aesthetic, very inspirational, varied, creative</b></p>
<p>Styles: <b>['Fooocus V2', 'Fooocus Enhance', 'Fooocus Sharp']</b>, Performance: <b>Speed</b></p>
<p>Resolution: <b>(1024, 1024)</b>, Sharpness: <b>2</b></p>
<p>Guidance Scale: <b>1</b>, ADM Guidance: <b>(1.5, 0.8, 0.3)</b></p>
<p>Base Model: <b>turbovisionxlSuperFastXLBasedOnNew_tvxlV20Bakedvae.safetensors</b>, Refiner Model: <b>None</b></p>
<p>Refiner Switch: <b>0.5</b>, Sampler: <b>dpmpp_sde</b></p>
<p>Scheduler: <b>karras</b>, Seed: <b>3953053316333445986</b></p>
</td></tr></table><hr></div>
Aamir3d commented 6 months ago

I know, it's a big pain. Currently Diffusion toolkit doesn't do this, but the way to do it would be to use the LOG file from the folder where the images are saved in Fooocus , and open it in your browser - this opens the metadata and the relevant images. You can then manually paste metadata using Exiftool or something (if you really want to go this route) Else, use RuinedFooocus which does embed metadata.

curiousjp commented 5 months ago

DiffusionToolkit supports loading metadata from paired image/text files - the text files can be written in either the A1111 style or the Stable Diffusion style. This gist is a python script you can run from the same folder as the fooocus run.bat script which will read your logs and try to produce these text files in the A1111 style (or delete them if the image no longer exists).

It is not perfect because there isn't a 1:1 relationship between the fooocus and a1111 tags, but it does the job well enough for me, and lets me do prompt searching. It uses nothing outside of the standard library, so you can run it using the copy of embedded python that ships with the windows install of fooocus.