mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-02-09 17:40:09 +00:00
Support models metadata in node properties (#2754)
This commit is contained in:
@@ -16,6 +16,7 @@ import { st } from '@/i18n'
|
||||
import type { ComfyNodeDef } from '@/schemas/apiSchema'
|
||||
import {
|
||||
type ComfyWorkflowJSON,
|
||||
type ModelFile,
|
||||
type NodeId,
|
||||
validateComfyWorkflow
|
||||
} from '@/schemas/comfyWorkflowSchema'
|
||||
@@ -1042,13 +1043,16 @@ export class ComfyApp {
|
||||
useWorkflowService().beforeLoadNewGraph()
|
||||
|
||||
const missingNodeTypes: MissingNodeType[] = []
|
||||
const missingModels = []
|
||||
const missingModels: ModelFile[] = []
|
||||
await useExtensionService().invokeExtensionsAsync(
|
||||
'beforeConfigureGraph',
|
||||
graphData,
|
||||
missingNodeTypes
|
||||
// TODO: missingModels
|
||||
)
|
||||
|
||||
const embeddedModels: ModelFile[] = []
|
||||
|
||||
for (let n of graphData.nodes) {
|
||||
// Patch T2IAdapterLoader to ControlNetLoader since they are the same node now
|
||||
if (n.type == 'T2IAdapterLoader') n.type = 'ControlNetLoader'
|
||||
@@ -1061,13 +1065,28 @@ export class ComfyApp {
|
||||
missingNodeTypes.push(n.type)
|
||||
n.type = sanitizeNodeName(n.type)
|
||||
}
|
||||
|
||||
// Collect models metadata from node
|
||||
if (n.properties?.models?.length)
|
||||
embeddedModels.push(...n.properties.models)
|
||||
}
|
||||
|
||||
// Merge models from the workflow's root-level 'models' field
|
||||
const workflowSchemaV1Models = graphData.models
|
||||
if (workflowSchemaV1Models?.length)
|
||||
embeddedModels.push(...workflowSchemaV1Models)
|
||||
|
||||
const getModelKey = (model: ModelFile) => model.url || model.hash
|
||||
const validModels = embeddedModels.filter(getModelKey)
|
||||
const uniqueModels = _.uniqBy(validModels, getModelKey)
|
||||
|
||||
if (
|
||||
graphData.models &&
|
||||
uniqueModels.length &&
|
||||
useSettingStore().get('Comfy.Workflow.ShowMissingModelsWarning')
|
||||
) {
|
||||
const modelStore = useModelStore()
|
||||
for (const m of graphData.models) {
|
||||
await modelStore.loadModelFolders()
|
||||
for (const m of uniqueModels) {
|
||||
const modelFolder = await modelStore.getLoadedModelFolder(m.directory)
|
||||
// @ts-expect-error
|
||||
if (!modelFolder) m.directory_invalid = true
|
||||
|
||||
Reference in New Issue
Block a user