WOLFRAM NOTEBOOK

In[]:=
textEncoder=NetModel[{"CLIP Multi-domain Feature Extractor","InputDomain"->"Text","Architecture"->"ViT-L/14"}];
In[]:=
results=URLExecute[HTTPRequest["https://knn.laion.ai/knn-service",Method->"POST","Body"ExportString[<|"indice_name"->"laion5B-L-14",(*"text""cat",*)"embedding_input"->Normalize[textEncoder["A cat in a party hat"]],"deduplicate"->True,"use_violence_detector"->True,"use_safety_model"->True,"use_mclip"->False,"aesthetic_score"->9,"aesthetic_weight"->.5,"modality"->"image","num_images"->40,"num_result_ids"->40|>,"JSON"]],"RawJSON"];
In[]:=
results
Out[]=
In[]:=
Import[#["url"]]&/@Take[%,4]
Out[]=
$Aborted
In[]:=
URLRead[#["url"],TimeConstraint->2]&/@Take[%226,4]
URLRead
:Connection timed out after 2000 milliseconds.
Out[]=
In[]:=
Import/@DeleteCases[%,_Failure]
Out[]=

Image Distances

In[]:=
imageEncoder=NetModel[{"CLIP Multi-domain Feature Extractor","InputDomain"->"Image","Architecture"->"ViT-L/14"}];
In[]:=
URLExecuteHTTPRequest"https://knn.laion.ai/knn-service",Method->"POST","Body"ExportString<|"indice_name"->"laion5B-L-14",(*"text""cat",*)"embedding_input"->NormalizeimageEncoder
,"deduplicate"->True,"use_violence_detector"->True,"use_safety_model"->True,"use_mclip"->False,"aesthetic_score"->9,"aesthetic_weight"->.5,"modality"->"image","num_images"->40,"num_result_ids"->40|>,"JSON","RawJSON"
Out[]=
In[]:=
pages=URLRead[#["url"],TimeConstraint->2]&/@%;
In[]:=
Count[%,_Failure]

Canonical Cat

Definition

Note: aesthetic score removed....

Blurring an image

Wolfram Cloud

You are using a browser not supported by the Wolfram Cloud

Supported browsers include recent versions of Chrome, Edge, Firefox and Safari.


I understand and wish to continue anyway »

You are using a browser not supported by the Wolfram Cloud. Supported browsers include recent versions of Chrome, Edge, Firefox and Safari.