mirror of
https://github.com/invoke-ai/InvokeAI
synced 2024-08-30 20:32:17 +00:00
fix(ui): use revised metadata model types
We can also totally remove the fetch logic because we store the same model data in state now.
This commit is contained in:
parent
437a413ca3
commit
4c417adc82
@ -1,16 +1,14 @@
|
||||
import type { RootState } from 'app/store/store';
|
||||
import { selectValidControlNets } from 'features/controlAdapters/store/controlAdaptersSlice';
|
||||
import { fetchModelConfigWithTypeGuard } from 'features/metadata/util/modelFetchingHelpers';
|
||||
import type {
|
||||
CollectInvocation,
|
||||
ControlNetInvocation,
|
||||
CoreMetadataInvocation,
|
||||
NonNullableGraph,
|
||||
} from 'services/api/types';
|
||||
import { isControlNetModelConfig } from 'services/api/types';
|
||||
|
||||
import { CONTROL_NET_COLLECT } from './constants';
|
||||
import { getModelMetadataField, upsertMetadata } from './metadata';
|
||||
import { upsertMetadata } from './metadata';
|
||||
|
||||
export const addControlNetToLinearGraph = async (
|
||||
state: RootState,
|
||||
@ -27,10 +25,6 @@ export const addControlNetToLinearGraph = async (
|
||||
}
|
||||
);
|
||||
|
||||
// const metadataAccumulator = graph.nodes[METADATA_ACCUMULATOR] as
|
||||
// | MetadataAccumulatorInvocation
|
||||
// | undefined;
|
||||
|
||||
const controlNetMetadata: CoreMetadataInvocation['controlnets'] = [];
|
||||
|
||||
if (validControlNets.length) {
|
||||
@ -95,10 +89,8 @@ export const addControlNetToLinearGraph = async (
|
||||
|
||||
graph.nodes[controlNetNode.id] = controlNetNode as ControlNetInvocation;
|
||||
|
||||
const modelConfig = await fetchModelConfigWithTypeGuard(model.key, isControlNetModelConfig);
|
||||
|
||||
controlNetMetadata.push({
|
||||
control_model: getModelMetadataField(modelConfig),
|
||||
control_model: model,
|
||||
control_weight: weight,
|
||||
control_mode: controlMode,
|
||||
begin_step_percent: beginStepPct,
|
||||
|
@ -1,16 +1,14 @@
|
||||
import type { RootState } from 'app/store/store';
|
||||
import { selectValidIPAdapters } from 'features/controlAdapters/store/controlAdaptersSlice';
|
||||
import { fetchModelConfigWithTypeGuard } from 'features/metadata/util/modelFetchingHelpers';
|
||||
import type {
|
||||
CollectInvocation,
|
||||
CoreMetadataInvocation,
|
||||
IPAdapterInvocation,
|
||||
NonNullableGraph,
|
||||
} from 'services/api/types';
|
||||
import { isIPAdapterModelConfig } from 'services/api/types';
|
||||
|
||||
import { IP_ADAPTER_COLLECT } from './constants';
|
||||
import { getModelMetadataField, upsertMetadata } from './metadata';
|
||||
import { upsertMetadata } from './metadata';
|
||||
|
||||
export const addIPAdapterToLinearGraph = async (
|
||||
state: RootState,
|
||||
@ -67,11 +65,9 @@ export const addIPAdapterToLinearGraph = async (
|
||||
|
||||
graph.nodes[ipAdapterNode.id] = ipAdapterNode;
|
||||
|
||||
const modelConfig = await fetchModelConfigWithTypeGuard(model.key, isIPAdapterModelConfig);
|
||||
|
||||
ipAdapterMetdata.push({
|
||||
weight: weight,
|
||||
ip_adapter_model: getModelMetadataField(modelConfig),
|
||||
ip_adapter_model: model,
|
||||
begin_step_percent: beginStepPct,
|
||||
end_step_percent: endStepPct,
|
||||
image: ipAdapterNode.image,
|
||||
|
@ -1,16 +1,14 @@
|
||||
import type { RootState } from 'app/store/store';
|
||||
import { selectValidT2IAdapters } from 'features/controlAdapters/store/controlAdaptersSlice';
|
||||
import { fetchModelConfigWithTypeGuard } from 'features/metadata/util/modelFetchingHelpers';
|
||||
import {
|
||||
type CollectInvocation,
|
||||
type CoreMetadataInvocation,
|
||||
isT2IAdapterModelConfig,
|
||||
type NonNullableGraph,
|
||||
type T2IAdapterInvocation,
|
||||
import type {
|
||||
CollectInvocation,
|
||||
CoreMetadataInvocation,
|
||||
NonNullableGraph,
|
||||
T2IAdapterInvocation,
|
||||
} from 'services/api/types';
|
||||
|
||||
import { T2I_ADAPTER_COLLECT } from './constants';
|
||||
import { getModelMetadataField, upsertMetadata } from './metadata';
|
||||
import { upsertMetadata } from './metadata';
|
||||
|
||||
export const addT2IAdaptersToLinearGraph = async (
|
||||
state: RootState,
|
||||
@ -89,13 +87,11 @@ export const addT2IAdaptersToLinearGraph = async (
|
||||
|
||||
graph.nodes[t2iAdapterNode.id] = t2iAdapterNode;
|
||||
|
||||
const modelConfig = await fetchModelConfigWithTypeGuard(t2iAdapter.model.key, isT2IAdapterModelConfig);
|
||||
|
||||
t2iAdapterMetadata.push({
|
||||
begin_step_percent: beginStepPct,
|
||||
end_step_percent: endStepPct,
|
||||
resize_mode: resizeMode,
|
||||
t2i_adapter_model: getModelMetadataField(modelConfig),
|
||||
t2i_adapter_model: t2iAdapter.model,
|
||||
weight: weight,
|
||||
image: t2iAdapterNode.image,
|
||||
});
|
||||
|
@ -1,7 +1,5 @@
|
||||
import type { RootState } from 'app/store/store';
|
||||
import { fetchModelConfigWithTypeGuard } from 'features/metadata/util/modelFetchingHelpers';
|
||||
import type { ModelMetadataField, NonNullableGraph } from 'services/api/types';
|
||||
import { isVAEModelConfig } from 'services/api/types';
|
||||
import type { NonNullableGraph } from 'services/api/types';
|
||||
|
||||
import {
|
||||
CANVAS_IMAGE_TO_IMAGE_GRAPH,
|
||||
@ -25,7 +23,7 @@ import {
|
||||
TEXT_TO_IMAGE_GRAPH,
|
||||
VAE_LOADER,
|
||||
} from './constants';
|
||||
import { getModelMetadataField, upsertMetadata } from './metadata';
|
||||
import { upsertMetadata } from './metadata';
|
||||
|
||||
export const addVAEToGraph = async (
|
||||
state: RootState,
|
||||
@ -151,8 +149,6 @@ export const addVAEToGraph = async (
|
||||
}
|
||||
|
||||
if (vae) {
|
||||
const modelConfig = await fetchModelConfigWithTypeGuard(vae.key, isVAEModelConfig);
|
||||
const vaeMetadata: ModelMetadataField = getModelMetadataField(modelConfig);
|
||||
upsertMetadata(graph, { vae: vaeMetadata });
|
||||
upsertMetadata(graph, { vae });
|
||||
}
|
||||
};
|
||||
|
@ -1,5 +1,6 @@
|
||||
import type { JSONObject } from 'common/types';
|
||||
import type { AnyModelConfig, CoreMetadataInvocation, ModelMetadataField, NonNullableGraph } from 'services/api/types';
|
||||
import type { ModelIdentifierField } from 'features/nodes/types/common';
|
||||
import type { AnyModelConfig, CoreMetadataInvocation, NonNullableGraph } from 'services/api/types';
|
||||
|
||||
import { METADATA } from './constants';
|
||||
|
||||
@ -72,7 +73,7 @@ export const setMetadataReceivingNode = (graph: NonNullableGraph, nodeId: string
|
||||
});
|
||||
};
|
||||
|
||||
export const getModelMetadataField = ({ key, hash, name, base, type }: AnyModelConfig): ModelMetadataField => ({
|
||||
export const getModelMetadataField = ({ key, hash, name, base, type }: AnyModelConfig): ModelIdentifierField => ({
|
||||
key,
|
||||
hash,
|
||||
name,
|
||||
|
@ -141,9 +141,6 @@ export type ImageWatermarkInvocation = S['ImageWatermarkInvocation'];
|
||||
export type SeamlessModeInvocation = S['SeamlessModeInvocation'];
|
||||
export type CoreMetadataInvocation = S['CoreMetadataInvocation'];
|
||||
|
||||
// Metadata fields
|
||||
export type ModelMetadataField = S['ModelMetadataField'];
|
||||
|
||||
// ControlNet Nodes
|
||||
export type ControlNetInvocation = S['ControlNetInvocation'];
|
||||
export type T2IAdapterInvocation = S['T2IAdapterInvocation'];
|
||||
|
Loading…
Reference in New Issue
Block a user