pollinations.ai Image generator

Created a nice software using SpiderBasic ? Post you link here !
User avatar
Peter
Posts: 1093
Joined: Mon Feb 24, 2014 10:17 pm
Location: 127.0.0.1:9080
Contact:

pollinations.ai Image generator

Post by Peter »

A little gimmick to generate images with pollinations.ai. ;)

(Sometimes the image generation takes a little while. So have a little patience.)

Code: Select all

EnableExplicit

Enumeration
  #Window
  #lblPrompt
  #lblWait
  #txtPrompt
  #cmdExecutePrompt
  #ImageGadget
EndEnumeration

Procedure InProgress(Flag)
  
  DisableGadget(#txtPrompt, Flag)
  DisableGadget(#cmdExecutePrompt, Flag)
  HideGadget(#ImageGadget, Flag)
  HideGadget(#lblWait, Bool(Flag=#False))
  
EndProcedure


Procedure cmdExecutePromptEvent()
  
  If GetGadgetText(#txtPrompt) = "" : ProcedureReturn : EndIf
  
  InProgress(#True)  
  
  LoadImage(0, "https://image.pollinations.ai/prompt/" + URLEncoder(GetGadgetText(#txtPrompt))) ; + "&seed=" + ElapsedMilliseconds()
  
EndProcedure

Procedure Loaded(Type, Filename$, ObjectId)
  SetGadgetState(#ImageGadget, ImageID(ObjectId))
  InProgress(#False)  
EndProcedure

Procedure LoadingError(Type, Filename$, ObjectId)
  Debug Filename$ + ": loading error"
  DisableGadget(#cmdExecutePrompt, #False)
  InProgress(#False)  
EndProcedure

OpenWindow(#Window, #PB_Ignore, #PB_Ignore, 532, 444, "pollinations.ai Image generator", #PB_Window_ScreenCentered)

TextGadget(#lblPrompt, 10, 10, 50, 30, "Prompt:", #PB_Text_VerticalCenter)
StringGadget(#txtPrompt, 60, 10, 400, 30, "PureBasic Programmer")
ButtonGadget(#cmdExecutePrompt, 470, 10, 55, 30, "Execute")
TextGadget(#lblWait, 0, 0, WindowWidth(#Window), WindowHeight(#Window), "Please wait...", #PB_Text_VerticalCenter | #PB_Text_Center)
ImageGadget(#ImageGadget, 10, 50, 512, 384, 0)

InProgress(#False)  

BindGadgetEvent(#cmdExecutePrompt, @cmdExecutePromptEvent())

BindEvent(#PB_Event_Loading, @Loaded())
BindEvent(#PB_Event_LoadingError, @LoadingError())
Image
Dirk Geppert
Posts: 284
Joined: Fri Sep 22, 2017 7:02 am

Re: pollinations.ai Image generator

Post by Dirk Geppert »

:o :D thx Peter!
tj1010
Posts: 201
Joined: Wed May 27, 2015 1:36 pm
Contact:

Re: pollinations.ai Image generator

Post by tj1010 »

I'm surprised you found a trained A.I. that isn't behind some metered subscription HTTP API.

I've been waiting on a decently trained LSTM to come around subscription or not.. If you use one with a natural language A.I. like chatgpt-4 you can do some really interesting stuff with very little coding..
bembulak
Posts: 71
Joined: Wed Feb 26, 2014 9:53 am

Re: pollinations.ai Image generator

Post by bembulak »

That's nice.

I'd like to save some of the images - are there built-in routines to save the canvas?
Post Reply