Merge branch 'main' into bugfix/run-on-3.9

This commit is contained in:
Lincoln Stein 2023-09-02 10:08:40 -04:00 committed by GitHub
commit 7763594839
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
14 changed files with 168 additions and 76 deletions

View File

@ -279,8 +279,8 @@ class SDXLCompelPromptInvocation(BaseInvocation, SDXLPromptInvocationBase):
crop_left: int = InputField(default=0, description="") crop_left: int = InputField(default=0, description="")
target_width: int = InputField(default=1024, description="") target_width: int = InputField(default=1024, description="")
target_height: int = InputField(default=1024, description="") target_height: int = InputField(default=1024, description="")
clip: ClipField = InputField(description=FieldDescriptions.clip, input=Input.Connection) clip: ClipField = InputField(description=FieldDescriptions.clip, input=Input.Connection, title="CLIP 1")
clip2: ClipField = InputField(description=FieldDescriptions.clip, input=Input.Connection) clip2: ClipField = InputField(description=FieldDescriptions.clip, input=Input.Connection, title="CLIP 2")
@torch.no_grad() @torch.no_grad()
def invoke(self, context: InvocationContext) -> ConditioningOutput: def invoke(self, context: InvocationContext) -> ConditioningOutput:

View File

@ -72,10 +72,10 @@ class CoreMetadata(BaseModelExcludeNull):
) )
refiner_steps: Optional[int] = Field(default=None, description="The number of steps used for the refiner") refiner_steps: Optional[int] = Field(default=None, description="The number of steps used for the refiner")
refiner_scheduler: Optional[str] = Field(default=None, description="The scheduler used for the refiner") refiner_scheduler: Optional[str] = Field(default=None, description="The scheduler used for the refiner")
refiner_positive_aesthetic_store: Optional[float] = Field( refiner_positive_aesthetic_score: Optional[float] = Field(
default=None, description="The aesthetic score used for the refiner" default=None, description="The aesthetic score used for the refiner"
) )
refiner_negative_aesthetic_store: Optional[float] = Field( refiner_negative_aesthetic_score: Optional[float] = Field(
default=None, description="The aesthetic score used for the refiner" default=None, description="The aesthetic score used for the refiner"
) )
refiner_start: Optional[float] = Field(default=None, description="The start value used for refiner denoising") refiner_start: Optional[float] = Field(default=None, description="The start value used for refiner denoising")
@ -160,11 +160,11 @@ class MetadataAccumulatorInvocation(BaseInvocation):
default=None, default=None,
description="The scheduler used for the refiner", description="The scheduler used for the refiner",
) )
refiner_positive_aesthetic_store: Optional[float] = InputField( refiner_positive_aesthetic_score: Optional[float] = InputField(
default=None, default=None,
description="The aesthetic score used for the refiner", description="The aesthetic score used for the refiner",
) )
refiner_negative_aesthetic_store: Optional[float] = InputField( refiner_negative_aesthetic_score: Optional[float] = InputField(
default=None, default=None,
description="The aesthetic score used for the refiner", description="The aesthetic score used for the refiner",
) )

View File

@ -250,13 +250,13 @@ class SDXLLoraLoaderInvocation(BaseInvocation):
lora: LoRAModelField = InputField(description=FieldDescriptions.lora_model, input=Input.Direct, title="LoRA") lora: LoRAModelField = InputField(description=FieldDescriptions.lora_model, input=Input.Direct, title="LoRA")
weight: float = InputField(default=0.75, description=FieldDescriptions.lora_weight) weight: float = InputField(default=0.75, description=FieldDescriptions.lora_weight)
unet: Optional[UNetField] = Field( unet: Optional[UNetField] = InputField(
default=None, description=FieldDescriptions.unet, input=Input.Connection, title="UNET" default=None, description=FieldDescriptions.unet, input=Input.Connection, title="UNet"
) )
clip: Optional[ClipField] = Field( clip: Optional[ClipField] = InputField(
default=None, description=FieldDescriptions.clip, input=Input.Connection, title="CLIP 1" default=None, description=FieldDescriptions.clip, input=Input.Connection, title="CLIP 1"
) )
clip2: Optional[ClipField] = Field( clip2: Optional[ClipField] = InputField(
default=None, description=FieldDescriptions.clip, input=Input.Connection, title="CLIP 2" default=None, description=FieldDescriptions.clip, input=Input.Connection, title="CLIP 2"
) )

View File

@ -50,6 +50,7 @@ class ModelProbe(object):
"StableDiffusionInpaintPipeline": ModelType.Main, "StableDiffusionInpaintPipeline": ModelType.Main,
"StableDiffusionXLPipeline": ModelType.Main, "StableDiffusionXLPipeline": ModelType.Main,
"StableDiffusionXLImg2ImgPipeline": ModelType.Main, "StableDiffusionXLImg2ImgPipeline": ModelType.Main,
"StableDiffusionXLInpaintPipeline": ModelType.Main,
"AutoencoderKL": ModelType.Vae, "AutoencoderKL": ModelType.Vae,
"ControlNetModel": ModelType.ControlNet, "ControlNetModel": ModelType.ControlNet,
} }

View File

@ -110,7 +110,7 @@ const CurrentImageButtons = (props: CurrentImageButtonsProps) => {
); );
const { metadata, workflow, isLoading } = useGetImageMetadataFromFileQuery( const { metadata, workflow, isLoading } = useGetImageMetadataFromFileQuery(
lastSelectedImage?.image_name ?? skipToken, lastSelectedImage ?? skipToken,
{ {
selectFromResult: (res) => ({ selectFromResult: (res) => ({
isLoading: res.isFetching, isLoading: res.isFetching,

View File

@ -52,7 +52,7 @@ const SingleSelectionMenuItems = (props: SingleSelectionMenuItemsProps) => {
const isCanvasEnabled = useFeatureStatus('unifiedCanvas').isFeatureEnabled; const isCanvasEnabled = useFeatureStatus('unifiedCanvas').isFeatureEnabled;
const { metadata, workflow, isLoading } = useGetImageMetadataFromFileQuery( const { metadata, workflow, isLoading } = useGetImageMetadataFromFileQuery(
imageDTO.image_name, imageDTO,
{ {
selectFromResult: (res) => ({ selectFromResult: (res) => ({
isLoading: res.isFetching, isLoading: res.isFetching,

View File

@ -101,13 +101,15 @@ const ImageMetadataActions = (props: Props) => {
onClick={handleRecallSeed} onClick={handleRecallSeed}
/> />
)} )}
{metadata.model !== undefined && metadata.model !== null && ( {metadata.model !== undefined &&
<ImageMetadataItem metadata.model !== null &&
label="Model" metadata.model.model_name && (
value={metadata.model.model_name} <ImageMetadataItem
onClick={handleRecallModel} label="Model"
/> value={metadata.model.model_name}
)} onClick={handleRecallModel}
/>
)}
{metadata.width && ( {metadata.width && (
<ImageMetadataItem <ImageMetadataItem
label="Width" label="Width"

View File

@ -27,15 +27,12 @@ const ImageMetadataViewer = ({ image }: ImageMetadataViewerProps) => {
// dispatch(setShouldShowImageDetails(false)); // dispatch(setShouldShowImageDetails(false));
// }); // });
const { metadata, workflow } = useGetImageMetadataFromFileQuery( const { metadata, workflow } = useGetImageMetadataFromFileQuery(image, {
image.image_name, selectFromResult: (res) => ({
{ metadata: res?.currentData?.metadata,
selectFromResult: (res) => ({ workflow: res?.currentData?.workflow,
metadata: res?.currentData?.metadata, }),
workflow: res?.currentData?.workflow, });
}),
}
);
return ( return (
<Flex <Flex

View File

@ -1,7 +1,9 @@
import { import {
SchedulerParam, SchedulerParam,
zBaseModel, zBaseModel,
zMainModel,
zMainOrOnnxModel, zMainOrOnnxModel,
zOnnxModel,
zSDXLRefinerModel, zSDXLRefinerModel,
zScheduler, zScheduler,
} from 'features/parameters/types/parameterSchemas'; } from 'features/parameters/types/parameterSchemas';
@ -769,12 +771,14 @@ export const zCoreMetadata = z
steps: z.number().int().nullish(), steps: z.number().int().nullish(),
scheduler: z.string().nullish(), scheduler: z.string().nullish(),
clip_skip: z.number().int().nullish(), clip_skip: z.number().int().nullish(),
model: zMainOrOnnxModel.nullish(), model: z
controlnets: z.array(zControlField).nullish(), .union([zMainModel.deepPartial(), zOnnxModel.deepPartial()])
.nullish(),
controlnets: z.array(zControlField.deepPartial()).nullish(),
loras: z loras: z
.array( .array(
z.object({ z.object({
lora: zLoRAModelField, lora: zLoRAModelField.deepPartial(),
weight: z.number(), weight: z.number(),
}) })
) )
@ -784,15 +788,15 @@ export const zCoreMetadata = z
init_image: z.string().nullish(), init_image: z.string().nullish(),
positive_style_prompt: z.string().nullish(), positive_style_prompt: z.string().nullish(),
negative_style_prompt: z.string().nullish(), negative_style_prompt: z.string().nullish(),
refiner_model: zSDXLRefinerModel.nullish(), refiner_model: zSDXLRefinerModel.deepPartial().nullish(),
refiner_cfg_scale: z.number().nullish(), refiner_cfg_scale: z.number().nullish(),
refiner_steps: z.number().int().nullish(), refiner_steps: z.number().int().nullish(),
refiner_scheduler: z.string().nullish(), refiner_scheduler: z.string().nullish(),
refiner_positive_aesthetic_store: z.number().nullish(), refiner_positive_aesthetic_score: z.number().nullish(),
refiner_negative_aesthetic_store: z.number().nullish(), refiner_negative_aesthetic_score: z.number().nullish(),
refiner_start: z.number().nullish(), refiner_start: z.number().nullish(),
}) })
.catchall(z.record(z.any())); .passthrough();
export type CoreMetadata = z.infer<typeof zCoreMetadata>; export type CoreMetadata = z.infer<typeof zCoreMetadata>;

View File

@ -1,4 +1,6 @@
import * as png from '@stevebel/png'; import * as png from '@stevebel/png';
import { logger } from 'app/logging/logger';
import { parseify } from 'common/util/serialize';
import { import {
ImageMetadataAndWorkflow, ImageMetadataAndWorkflow,
zCoreMetadata, zCoreMetadata,
@ -18,6 +20,11 @@ export const getMetadataAndWorkflowFromImageBlob = async (
const metadataResult = zCoreMetadata.safeParse(JSON.parse(rawMetadata)); const metadataResult = zCoreMetadata.safeParse(JSON.parse(rawMetadata));
if (metadataResult.success) { if (metadataResult.success) {
data.metadata = metadataResult.data; data.metadata = metadataResult.data;
} else {
logger('system').error(
{ error: parseify(metadataResult.error) },
'Problem reading metadata from image'
);
} }
} }
@ -26,6 +33,11 @@ export const getMetadataAndWorkflowFromImageBlob = async (
const workflowResult = zWorkflow.safeParse(JSON.parse(rawWorkflow)); const workflowResult = zWorkflow.safeParse(JSON.parse(rawWorkflow));
if (workflowResult.success) { if (workflowResult.success) {
data.workflow = workflowResult.data; data.workflow = workflowResult.data;
} else {
logger('system').error(
{ error: parseify(workflowResult.error) },
'Problem reading workflow from image'
);
} }
} }

View File

@ -60,9 +60,9 @@ export const addSDXLRefinerToGraph = (
if (metadataAccumulator) { if (metadataAccumulator) {
metadataAccumulator.refiner_model = refinerModel; metadataAccumulator.refiner_model = refinerModel;
metadataAccumulator.refiner_positive_aesthetic_store = metadataAccumulator.refiner_positive_aesthetic_score =
refinerPositiveAestheticScore; refinerPositiveAestheticScore;
metadataAccumulator.refiner_negative_aesthetic_store = metadataAccumulator.refiner_negative_aesthetic_score =
refinerNegativeAestheticScore; refinerNegativeAestheticScore;
metadataAccumulator.refiner_cfg_scale = refinerCFGScale; metadataAccumulator.refiner_cfg_scale = refinerCFGScale;
metadataAccumulator.refiner_scheduler = refinerScheduler; metadataAccumulator.refiner_scheduler = refinerScheduler;

View File

@ -341,8 +341,8 @@ export const useRecallParameters = () => {
refiner_cfg_scale, refiner_cfg_scale,
refiner_steps, refiner_steps,
refiner_scheduler, refiner_scheduler,
refiner_positive_aesthetic_store, refiner_positive_aesthetic_score,
refiner_negative_aesthetic_store, refiner_negative_aesthetic_score,
refiner_start, refiner_start,
} = metadata; } = metadata;
@ -403,21 +403,21 @@ export const useRecallParameters = () => {
if ( if (
isValidSDXLRefinerPositiveAestheticScore( isValidSDXLRefinerPositiveAestheticScore(
refiner_positive_aesthetic_store refiner_positive_aesthetic_score
) )
) { ) {
dispatch( dispatch(
setRefinerPositiveAestheticScore(refiner_positive_aesthetic_store) setRefinerPositiveAestheticScore(refiner_positive_aesthetic_score)
); );
} }
if ( if (
isValidSDXLRefinerNegativeAestheticScore( isValidSDXLRefinerNegativeAestheticScore(
refiner_negative_aesthetic_store refiner_negative_aesthetic_score
) )
) { ) {
dispatch( dispatch(
setRefinerNegativeAestheticScore(refiner_negative_aesthetic_store) setRefinerNegativeAestheticScore(refiner_negative_aesthetic_score)
); );
} }

View File

@ -28,6 +28,8 @@ import {
} from '../util'; } from '../util';
import { boardsApi } from './boards'; import { boardsApi } from './boards';
import { ImageMetadataAndWorkflow } from 'features/nodes/types/types'; import { ImageMetadataAndWorkflow } from 'features/nodes/types/types';
import { fetchBaseQuery } from '@reduxjs/toolkit/dist/query';
import { $authToken, $projectId } from '../client';
export const imagesApi = api.injectEndpoints({ export const imagesApi = api.injectEndpoints({
endpoints: (build) => ({ endpoints: (build) => ({
@ -115,18 +117,40 @@ export const imagesApi = api.injectEndpoints({
], ],
keepUnusedDataFor: 86400, // 24 hours keepUnusedDataFor: 86400, // 24 hours
}), }),
getImageMetadataFromFile: build.query<ImageMetadataAndWorkflow, string>({ getImageMetadataFromFile: build.query<ImageMetadataAndWorkflow, ImageDTO>({
query: (image_name) => ({ queryFn: async (args: ImageDTO, api, extraOptions) => {
url: `images/i/${image_name}/full`, const authToken = $authToken.get();
responseHandler: async (res) => { const projectId = $projectId.get();
return await res.blob(); const customBaseQuery = fetchBaseQuery({
}, baseUrl: '',
}), prepareHeaders: (headers) => {
providesTags: (result, error, image_name) => [ if (authToken) {
{ type: 'ImageMetadataFromFile', id: image_name }, headers.set('Authorization', `Bearer ${authToken}`);
}
if (projectId) {
headers.set('project-id', projectId);
}
return headers;
},
responseHandler: async (res) => {
return await res.blob();
},
});
const response = await customBaseQuery(
args.image_url,
api,
extraOptions
);
const data = await getMetadataAndWorkflowFromImageBlob(
response.data as Blob
);
return { data };
},
providesTags: (result, error, image_dto) => [
{ type: 'ImageMetadataFromFile', id: image_dto.image_name },
], ],
transformResponse: (response: Blob) =>
getMetadataAndWorkflowFromImageBlob(response),
keepUnusedDataFor: 86400, // 24 hours keepUnusedDataFor: 86400, // 24 hours
}), }),
clearIntermediates: build.mutation<number, void>({ clearIntermediates: build.mutation<number, void>({

File diff suppressed because one or more lines are too long