Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add model preview feature #2211

Open
wants to merge 16 commits into
base: main
Choose a base branch
from

Conversation

MindOfMatter
Copy link
Contributor

@MindOfMatter MindOfMatter commented Feb 8, 2024

#2029

image

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 tool

Tested until 2 week ago from my dev branch of fork project :
MindOfMatter/Fooocus-MindOfMatter-Edition#14

@mashb1t mashb1t added the Size M medium change, isolated, testing with care label Feb 9, 2024
@HelloLaohe
Copy link

I added a redraw script to the script, which allows the main model to use preview images. This makes it more intuitive. However, some of them are online images. After debugging offline images, I can share them with everyone.
屏幕截图 06-05-2024 10 06 02

@mashb1t mashb1t added this to the v2.5.0 milestone Jun 5, 2024
@mashb1t mashb1t removed this from the v2.5.0 milestone Jul 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Size M medium change, isolated, testing with care
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants