The most powerful and modular diffusion model GUI, api and backend with a graph/nodes interface. The fastest local inference engine in the world.
Load workflow from latent file.
comfyanonymous62a371e12b47
diff --git a/nodes.py b/nodes.pyindex 7b450df38..3c61cd2ec 100644--- a/nodes.py+++ b/nodes.py@@ -274,7 +274,7 @@ class SaveLatent:if prompt is not None:prompt_info = json.dumps(prompt)- metadata = {"workflow": prompt_info}+ metadata = {"prompt": prompt_info}if extra_pnginfo is not None:for x in extra_pnginfo:metadata[x] = json.dumps(extra_pnginfo[x])diff --git a/web/scripts/app.js b/web/scripts/app.jsindex ef3b44c83..97b7c8d31 100644--- a/web/scripts/app.js+++ b/web/scripts/app.js@@ -2,7 +2,7 @@ import { ComfyWidgets } from "./widgets.js";import { ComfyUI, $el } from "./ui.js";import { api } from "./api.js";import { defaultGraph } from "./defaultGraph.js";-import { getPngMetadata, importA1111 } from "./pnginfo.js";+import { getPngMetadata, importA1111, getLatentMetadata } from "./pnginfo.js";/*** @typedef {import("types/comfy").ComfyExtension} ComfyExtension@@ -1308,6 +1308,11 @@ export class ComfyApp {this.loadGraphData(JSON.parse(reader.result));};reader.readAsText(file);+ } else if (file.name?.endsWith(".latent")) {+ const info = await getLatentMetadata(file);+ if (info.workflow) {+ this.loadGraphData(JSON.parse(info.workflow));+ }}}diff --git a/web/scripts/pnginfo.js b/web/scripts/pnginfo.jsindex 209b562a6..8ddb7a1c5 100644--- a/web/scripts/pnginfo.js+++ b/web/scripts/pnginfo.js@@ -47,6 +47,22 @@ export function getPngMetadata(file) {});}+export function getLatentMetadata(file) {+ return new Promise((r) => {+ const reader = new FileReader();+ reader.onload = (event) => {+ const safetensorsData = new Uint8Array(event.target.result);+ const dataView = new DataView(safetensorsData.buffer);+ let header_size = dataView.getUint32(0, true);+ let offset = 8;+ let header = JSON.parse(String.fromCharCode(...safetensorsData.slice(offset, offset + header_size)));+ r(header.__metadata__);+ };++ reader.readAsArrayBuffer(file);+ });+}+export async function importA1111(graph, parameters) {const p = parameters.lastIndexOf("\nSteps:");if (p > -1) {diff --git a/web/scripts/ui.js b/web/scripts/ui.jsindex 77517aec1..2c9043d00 100644--- a/web/scripts/ui.js+++ b/web/scripts/ui.js@@ -465,7 +465,7 @@ export class ComfyUI {const fileInput = $el("input", {id: "comfy-file-input",type: "file",- accept: ".json,image/png",+ accept: ".json,image/png,.latent",style: { display: "none" },parent: document.body,onchange: () => {