Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
lllyasviel/Fooocus#2029
Overview
This PR introduces a significant update to the model preview functionality in the application. The update allows for dynamic generation of model previews based on the last successful image generation attempt. This feature enhances the user experience by providing more relevant and up-to-date previews for models and configurations.
Key Changes
Dynamic Model Preview Generation:
Previews are now generated based on the last successful image attempt, offering a more accurate representation of the current model configuration.
Supports checkpoints and loras models.
Preview Management via JSON:
Previews are managed through preview_log.json files located in the models/checkpoints and models/loras directories.
The JSON files map model filenames to their latest preview images in the output folder.
UI Integration and Tooltip Enhancement:
The UI dynamically loads and displays these previews.
Tooltips are updated to show the latest previews or model filenames.
Configurable via config.py:
New settings in config.py allow for enabling/disabling the cleanup and addition of model previews.
The feature can be controlled via use_cleanup_model_previews and use_add_model_previews settings.
JavaScript and CSS Enhancements:
Refactored JavaScript code for handling model and style previews.
CSS updates for better display and interaction with the new preview functionality.
Error Handling and Debugging:
Added verbose debug outputs for better tracking and resolution of issues.
Ensures robust handling of file existence and JSON data integrity.
Configuration and Usage
Enabling/Disabling Feature:
In config.py, set use_cleanup_model_previews and use_add_model_previews to True or False as needed.
Adding Previews:
Previews are automatically added to the preview_log.json file after each successful generation.
Preview Cleanup:
On app start, the feature cleans up any non-existent outputs referenced in the JSON file.
UI Display:
Previews are displayed in the UI, offering a real-time glimpse of the model's output capabilities.
Additional Notes
First Version Limitation:
In the initial version, an app restart may be required to reflect changes in the previews.
Future Enhancements:
Plans to further refine the feature, including real-time updates without the need for a restart.
How to Test
Generating Images:
Use the application to generate images and observe the automatic update of previews in the UI.
JSON File Updates:
Check preview_log.json files for the correct mapping of model names to the latest image paths.
UI Interaction:
Hover over model names in the UI to see updated previews or tooltips.