Add a launch flag for --latent-preview-api to get image previews through json payload #4993
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.
IGNORE THIS PR: I figured it out and made a separate PR updating the websocket example. See #5016
I've been trying to make a super simple Gradio frontend for the family to use, that's also phone/tablet friendly but found it really needed previews. I was driving myself insane trying to figure out how to decode the binary stream on the client app, so I just added an option to base64 encode the images and send them through json.
Here's an example of the previews working with a Gradio frontend that runs ComfyUI API workflows:
And then the final output:
I should also note that it seems to trigger websocket timeouts a little more frequently than normal, but that would make sense with it hammering images through json. In my case, I just added a timeout to my app and if it does so, I can just click generate and it works again. Taesd previews also work, but since they are usually full size, it would mean more data to send.I think I solved the timeout errors I'd sometimes get and it turns out it was a kind of stupid mistake:
I wasn't using
ws.close()
at the end of my websocket call function to ComfyUI... Been slamming it with a bunch of generations and taesd previews, haven't had a websocket timeout since!All that being said, this is an opt-in type option that should have no effect on the rest of ComfyUI if you aren't specifically trying to use it. Ideally, I should also eventually add in a server option to throttle the rate it sends these images as well, but I'll have to look into how/where to put it.