In[]:=
StableDiffusionSynthesize=ResourceFunction["https://www.wolframcloud.com/obj/nikm/DeployedResources/Function/StableDiffusionSynthesize/"]
Out[]=
In[]:=
$NetModelPath="/home/sw/Dropbox/GeneralBox/Research/LLMScience/FromNik";
In[]:=
sdOptions=Normal@<|TargetDevice->"GPU",AssociationMap[FileNameJoin[{$NetModelPath,"Parameters/Stable-Diffusion-V1",#<>".wlnet"}]&,{"Unet","Encoder","Decoder"}]|>;
In[]:=
seedimage=BlockRandom[SeedRandom[33];RandomVariate[NormalDistribution[],{4,64,64}]];
In[]:=
Dimensions[latent]
Out[]=
{4,64,64}
In[]:=
latent==seedimage
Out[]=
True
In[]:=
catembedding=NetModel[{"CLIP Multi-domain Feature Extractor","InputDomain"->"Text","Architecture"->"ViT-L/14"}]["A cat in a party hat",NetPort["post_normalize","Output"]];
In[]:=
Dimensions[catembedding]
Out[]=
{8,768}
In[]:=
eplane=(SeedRandom[345345];{RandomReal[NormalDistribution[],Dimensions[catembedding]],RandomReal[NormalDistribution[],Dimensions[catembedding]]});
In[]:=
Dimensions[{1,0}.eplane]
Out[]=
{70,768}
In[]:=
StableDiffusionSynthesize[%,sdOptions]
Out[]=
In[]:=
With[{rl=RandomReal[{-1,1},{10,2}]},Thread[rl->StableDiffusionSynthesize[((#+catembedding)->latent)&/@(#.eplane&/@rl),sdOptions]]]
Out[]=
In[]:=
Graphics[Inset[#[[2]],#[[1]],{0,0},.4]&/@%64]
Out[]=
Contents cannot be rendered at this time; please try again later
In[]:=
Flatten[Table[With[{rl=RandomReal[{-1,1},{10,2}]},Thread[rl->StableDiffusionSynthesize[((#+catembedding)->latent)&/@(#.eplane&/@rl),sdOptions]]],5]]
Out[]=
Contents cannot be rendered at this time; please try again later
Explore another plane through Cat Island...
Explore another plane through Cat Island...