Fixes metadata viewer not showing metadata after refresh

Also adds Dream-style prompt to metadata
This commit is contained in:
psychedelicious 2022-11-21 20:31:52 +11:00 committed by blessedcoolant
parent 306ed44e19
commit 0cdb7bb0cd
3 changed files with 31 additions and 3 deletions

View File

@ -425,7 +425,8 @@ class InvokeAIWebServer:
thumbnail_path
),
"mtime": os.path.getmtime(path),
"metadata": metadata,
"metadata": metadata.get("sd-metadata"),
"dreamPrompt": metadata.get("Dream"),
"width": width,
"height": height,
"category": category,
@ -496,7 +497,8 @@ class InvokeAIWebServer:
thumbnail_path
),
"mtime": os.path.getmtime(path),
"metadata": metadata,
"metadata": metadata.get("sd-metadata"),
"dreamPrompt": metadata.get("Dream"),
"width": width,
"height": height,
"category": category,
@ -659,7 +661,8 @@ class InvokeAIWebServer:
"url": self.get_url_from_image_path(path),
"thumbnail": self.get_url_from_image_path(thumbnail_path),
"mtime": os.path.getmtime(path),
"metadata": metadata,
"metadata": metadata.get("sd-metadata"),
"dreamPrompt": metadata.get("Dream"),
"width": width,
"height": height,
},
@ -1090,6 +1093,7 @@ class InvokeAIWebServer:
"thumbnail": self.get_url_from_image_path(thumbnail_path),
"mtime": os.path.getmtime(path),
"metadata": metadata,
"dreamPrompt": command,
"width": width,
"height": height,
"boundingBox": original_bounding_box,

View File

@ -120,6 +120,7 @@ export declare type Image = {
height: number;
category: GalleryCategory;
isBase64?: boolean;
dreamPrompt?: 'string';
};
// GalleryImages is an array of Image.

View File

@ -45,6 +45,7 @@ type MetadataItemProps = {
onClick?: () => void;
value: number | string | boolean;
labelPosition?: string;
withCopy?: boolean;
};
/**
@ -56,6 +57,7 @@ const MetadataItem = ({
onClick,
isLink,
labelPosition,
withCopy = false,
}: MetadataItemProps) => {
return (
<Flex gap={2}>
@ -71,6 +73,18 @@ const MetadataItem = ({
/>
</Tooltip>
)}
{withCopy && (
<Tooltip label={`Copy ${label}`}>
<IconButton
aria-label={`Copy ${label}`}
icon={<FaCopy />}
size={'xs'}
variant={'ghost'}
fontSize={14}
onClick={() => navigator.clipboard.writeText(value.toString())}
/>
</Tooltip>
)}
<Flex direction={labelPosition ? 'column' : 'row'}>
<Text fontWeight={'semibold'} whiteSpace={'pre-wrap'} pr={2}>
{label}:
@ -115,6 +129,8 @@ const ImageMetadataViewer = memo(
});
const metadata = image?.metadata?.image || {};
const dreamPrompt = image?.dreamPrompt;
const {
type,
postprocessing,
@ -381,6 +397,13 @@ const ImageMetadataViewer = memo(
)}
</>
)}
{dreamPrompt && (
<MetadataItem
withCopy
label="Dream Prompt"
value={dreamPrompt}
/>
)}
<Flex gap={2} direction={'column'}>
<Flex gap={2}>
<Tooltip label={`Copy metadata JSON`}>