Stability.ai是一個成熟的人工智能組織,以其模型而聞名,該模型從描述中生成圖像和文本。以下是他們開發的關鍵模型的摘要,該模型按時間順序發布:
圖像生成模型:
Stable Diffusion (2022年8月)是第一個潛在擴散模型,能夠基於文本描述生成圖像。
Stable Diffusion 2.0 (2022年11月)一個更新版本,具有改進的圖像質量,對更高分辨率的支持以及其他功能。
Stable Diffusion XL (SDXL) (2023年4月)著重於光真相,此版本引入了圖像組成和麵部生成的改進。
Stable Diffusion 3.0 (2024年2月)具有結合擴散變壓器和流量匹配的新體系結構,此版本可增強多主題查詢和整體圖像質量的性能。
Stable Cascade (2024年2月)建立在Würstchen架構上,該模型提高了文本到圖像生成的準確性和效率。
Stable Diffusion 3.5 (2024年10月)包括穩定擴散3.5大型和3.5培養基等變體,為具有優化效率的不同生成任務提供了更多選擇。
重要的
這是一個非正式的圖書館。穩定性。 EA不提供Delphi的任何官方圖書館。該存儲庫包含有關穩定性的Delphi實現。
您可以訪問穩定性。 Eai控制台以探索可用的可能性。
要獲取API密鑰,您需要創建一個帳戶。將授予您25個信用額度,並將自動生成一個初始密鑰。您可以在這裡找到此鍵。
有一個令牌後,您可以初始化IStabilityAI接口,這是API的切入點。
筆記
uses StabilityAI;
var Stability := TStabilityAIFactory.CreateInstance(API_KEY);警告
要使用本教程中提供的示例,尤其是為了使用異步方法,我建議將穩定性接口定義為最寬的範圍。
因此,設置Stability := TStabilityAIFactory.CreateInstance(API_KEY);在您申請的OnCreate事件中。
Stability: IStabilityAI;
在異步方法的上下文中,對於不涉及流的方法,回調使用以下通用記錄: TAsynCallBack<T> = record在StabilityAI.Async.Support.pas單元中定義的記錄。該記錄公開了以下屬性:
TAsynCallBack<T> = record
...
Sender: TObject;
OnStart: TProc<TObject>;
OnSuccess: TProc<TObject, T>;
OnError: TProc<TObject, string>; 每個屬性的名稱是自稱的;如果需要,請參閱內部文檔以獲取更多詳細信息。
筆記
在本教程的其餘部分中,除非另有說明,否則我們將主要使用匿名方法,因為與API一起使用,由於處理時間有時可能很長,因此需要它。
穩定的圖像Ultra使用擴散3.5模型。此方法的區分:
異步代碼示例
// uses StabilityAI, StabilityAI.Types, StabilityAI.Common, StabilityAI.StableImage.Generate;
Stability.StableImage.Generate.ImageUltra(
procedure (Params: TStableImageUltra)
begin
Params.AspectRatio(ratio16x9);
Params.Prompt( ' Lighthouse on a cliff overlooking the ocean ' );
// A blurb of text describing what you do not wish to see in the output image.
// Params.NegativePrompt('...')
Params.OutputFormat(png);
end ,
function : TAsynStableImage
begin
// Add a TImage on the form
// Add a TMemo on the form
Result.Sender := Image1;
Result.OnStart :=
procedure (Sender: TObject)
begin
Memo1.Lines.Text := Memo1.Text + ' The generation has started. Please wait... ' + sLineBreak;
end ;
Result.OnSuccess :=
procedure (Sender: TObject; Image: TStableImage)
begin
var Stream := Image.GetStream;
try
Image.SaveToFile( ' lighthouse.png ' );
// for VCL
Image1.Picture.LoadFromStream(Stream);
// for FMX
// Image1.Bitmap.LoadFromStream(Stream);
Memo1.Lines.Text := Memo1.Text + ' Generation ended successfully ' + sLineBreak;
finally
Stream.Free;
end ;
end ;
Result.OnError :=
procedure (Sender: TObject; Error: String)
begin
Memo1.Lines.Text := Memo1.Text + Error + sLineBreak;
end ;
end );官方文檔的詳細設置
為了簡化本教程中提供的示例代碼,我在源代碼中包含了兩個單元: VCL.Stability.Tutorial and FMX.Stability.Tutorial 。根據您選擇測試提供的源代碼的選項,您需要在應用程序的OnCreate事件中實例化TVCLStabilitySender或TFMXStabilitySender類,如下:
提示
// uses VCL.Stability.Tutorial;
StabilityResult := TVCLStabilitySender.Create(Memo1, Image1);或者
// uses FMX.Stability.Tutorial;
StabilityResult := TFMXStabilitySender.Create(Memo1, Image1);確保事先向您的表格中添加一個TMemo和一個TImage組件。
還可以提供參考圖像,以用作生成的起點。在這種情況下,必須指定strength參數,因為它決定了輸入圖像對最終輸出的影響。 strength值為0將產生與輸入相同的圖像,而1的圖像表示初始圖像沒有影響。
// uses StabilityAI, StabilityAI.Types, StabilityAI.Common, StabilityAI.StableImage.Generate, FMX.Stability.Tutorial;
StabilityResult.FileName := ' lighthouse1.png ' ;
Stability.StableImage.Generate.ImageUltra(
procedure (Params: TStableImageUltra)
begin
Params.AspectRatio(ratio16x9);
Params.Prompt( ' There are many birds in the sky ' );
Params.Image( ' lighthouse.png ' );
Params.Strength( 0.3 );
Params.OutputFormat(png);
end ,
function : TAsynStableImage
begin
Result.Sender := StabilityResult;
Result.OnStart := Start;
Result.OnSuccess := Display;
Result.OnError := Display;
end );特異性:
Stable Image Core是一項文本到圖像生成服務,旨在以速度提供優質質量。與其他類似工具不同,它不需要“及時工程”的專業知識。用戶只需描述樣式,場景或角色,該工具會生成與其描述對齊的圖像。要點:
應用清單:
異步代碼示例
// uses StabilityAI, StabilityAI.Types, StabilityAI.Common, StabilityAI.StableImage.Generate, FMX.Stability.Tutorial;
StabilityResult.FileName := ' lighthouse2.png ' ;
Stability.StableImage.Generate.ImageCore(
procedure (Params: TStableImageCore)
begin
Params.AspectRatio(ratio16x9);
Params.Prompt( ' Lighthouse on a cliff overlooking the ocean ' );
Params.OutputFormat(png);
end ,
function : TAsynStableImage
begin
Result.Sender := StabilityResult;
Result.OnStart := Start;
Result.OnSuccess := Display;
Result.OnError := Display;
end );官方文檔的詳細設置
您可以通過從17種可用樣式中選擇特定樣式來指導圖像模型。
// uses StabilityAI, StabilityAI.Types, StabilityAI.Common, StabilityAI.StableImage.Generate, FMX.Stability.Tutorial;
StabilityResult.FileName := ' lighthouse3.png ' ;
Stability.StableImage.Generate.ImageCore(
procedure (Params: TStableImageCore)
begin
Params.AspectRatio(ratio16x9);
Params.Prompt( ' Lighthouse on a cliff overlooking the ocean ' );
Params.StylePreset(TStylePreset.digitalArt);
Params.OutputFormat(png);
end ,
function : TAsynStableImage
begin
Result.Sender := StabilityResult;
Result.OnStart := Start;
Result.OnSuccess := Display;
Result.OnError := Display;
end );可用型號的清單
穩定的擴散3.5
穩定擴散3.0 (煙花AI)
要點:
Turbo版本可以更快地生成圖像,而無需犧牲質量。此模式僅基於文本描述創建圖像。 prompt是唯一的強制性輸入,但是可選的aspect_ratio參數可用於調整所得圖像的尺寸。
異步代碼示例
// uses StabilityAI, StabilityAI.Types, StabilityAI.Common, StabilityAI.StableImage.Generate, FMX.Stability.Tutorial;
StabilityResult.FileName := ' lighthouse4.png ' ;
Stability.StableImage.Generate.Diffusion(
procedure (Params: TStableImageDiffusion)
begin
Params.AspectRatio(ratio16x9);
Params.Prompt( ' Lighthouse on a cliff overlooking the ocean ' );
Params.OutputFormat(png);
end ,
function : TAsynStableImage
begin
Result.Sender := StabilityResult;
Result.OnStart := Start;
Result.OnSuccess := Display;
Result.OnError := Display;
end );官方文檔的詳細設置
此方法使用現有映像作為初始參考時,基於文本輸入生成圖像。必要的參數包括:
prompt :指導圖像生成的描述性文本。image :作為輸出基礎的起始圖像。strength :確定起始圖像影響最終結果的程度。mode :應將其設置為“圖像到圖像”。異步代碼示例
// uses StabilityAI, StabilityAI.Types, StabilityAI.Common, StabilityAI.StableImage.Generate, FMX.Stability.Tutorial;
StabilityResult.FileName := ' lighthouse5.png ' ;
Stability.StableImage.Generate.Diffusion(
procedure (Params: TStableImageDiffusion)
begin
Params.Prompt( ' There are many birds in the sky ' );
Params.Mode(imageToImage);
Params.Image( ' lighthouse4.png ' );
Params.Strength( 0.6 );
Params.OutputFormat(png);
end ,
function : TAsynStableImage
begin
Result.Sender := StabilityResult;
Result.OnStart := Start;
Result.OnSuccess := Display;
Result.OnError := Display;
end );筆記
注意:最大請求大小為10MIB。
兩種模式都允許使用這些可選參數:
model :指定要使用的模型,例如SD3大, SD3大渦輪增壓或SD3介質。output_format :確定所得圖像的所需格式。seed :為生成過程設置隨機種子。negative_prompt :定義要從生成的圖像中排除的關鍵字。cfg_scale :在擴散過程中調整對及時文本的粘附水平。 使用SDXL 1.0:使用stable-diffusion-xl-1024-v1-0作為請求的engine_id ,並使用以下組合之一指定尺寸( height和width ):
使用SD 1.6 :SD 1.6是一種靈活的分辨率基本模型,旨在生成具有非標準縱橫比的圖像。該模型針對512 x 512像素的分辨率進行了優化。要創建1兆像素的分辨率的輸出,我們建議使用以相同價格獲得的SDXL 1.0。
要使用此模型,請在請求中將stable-diffusion-v1-6設置為engine_id ,並確保height和width滿足以下要求:
異步代碼示例
// uses
// StabilityAI, StabilityAI.Types, StabilityAI.Common, StabilityAI.StableImage.Generate,
// StabilityAI.Version1.SDXL1AndSD1_6, FMX.Stability.Tutorial;
StabilityResult.FileName := ' lighthouse6.png ' ;
Stability.Version1.SDXLAndSDL.TextToImage( ' stable-diffusion-xl-1024-v1-0 ' ,
procedure (Params: TPayload)
begin
Params.TextPrompts([TPrompt.New( 1 , ' A lighthouse on a cliff ' ) ]);
Params.CfgScale( 7 );
Params.Height( 1216 );
Params.Width( 832 );
Params.Sampler(TSamplerType.K_DPMPP_2S_ANCESTRAL);
Params.Samples( 1 );
Params.Steps( 30 );
end ,
function : TAsynArtifacts
begin
Result.Sender := StabilityResult;
Result.OnStart := Start;
Result.OnSuccess := Display;
Result.OnError := Display;
end );官方文檔的詳細設置
調整轉化程度
init_image_mode=IMAGE_STRENGTH with image_strength=0.35 ,或使用init_image_mode=STEP_SCHEDULE step_schedule_start=0.65 。兩種方法都會產生相似的結果,但是step_schedule模式通過允許您指定step_schedule_end值來提供額外的靈活性,並在需要時提供更多細微的控件。有關更多詳細信息,請參閱下面的特定參數描述。異步代碼示例
// uses
// StabilityAI, StabilityAI.Types, StabilityAI.Common, StabilityAI.StableImage.Generate,
// StabilityAI.Version1.SDXL1AndSD1_6, FMX.Stability.Tutorial;
StabilityResult.FileName := ' lighthouse7.png ' ;
Stability.Version1.SDXLAndSDL.ImageToImageWithPrompt( ' stable-diffusion-v1-6 ' ,
procedure (Params: TPayloadPrompt)
begin
Params.TextPrompts([TPromptMultipart.New( 1 , ' A dog space commander ' ) ]);
Params.InitImage( ' lighthouse6.png ' );
Params.ImageStrength( 0.45 );
Params.CfgScale( 7 );
Params.Sampler(TSamplerType.K_DPMPP_2S_ANCESTRAL);
Params.Samples( 3 );
Params.Steps( 30 );
end ,
function : TAsynArtifacts
begin
Result.Sender := StabilityResult;
Result.OnStart := Start;
Result.OnSuccess := Display;
Result.OnError := Display;
end );提示
在我們的代碼示例中,樣本參數的值為3,這意味著生成了三個圖像。只顯示第一個。另外兩個用索引文件名保存如下:Lighthouse701.png和Lighthouse702.png。
官方文檔的詳細設置
使用掩碼修改圖像的特定部分。面具必須匹配原始圖像的尺寸和形狀。此功能還支持帶有alpha通道的圖像。
使用métode:
ImageToImageWithMask( const Model: string; ParamProc: TProc<TPayloadMask>;
CallBacks: TFunc<TAsynArtifacts>);增強圖像的大小和分辨率的工具
保守的高檔器
創意高檔器
快速上映器
接受尺寸從64x64像素到1兆像素的圖像,並將其分辨率提高到4K。更廣泛地說,它可以在維護其原始細節的同時將圖像提高約20至40倍。保守的高檔選項著重於通過最小修改來保存圖像的完整性,並且不打算重新解釋圖像的內容。
異步代碼示例
// uses
// StabilityAI, StabilityAI.Types, StabilityAI.Common, FMX.Stability.Tutorial,
// StabilityAI.StableImage.Upscale;
StabilityResult.FileName := ' Upscalelighthouse1.png ' ;
Stability.StableImage.Upscale.Conservative(
procedure (Params: TUpscaleConservative)
begin
Params.Image( ' lighthouse.png ' );
Params.Prompt( ' The light house ' );
Params.OutputFormat(png);
end ,
function : TAsynStableImage
begin
Result.Sender := StabilityResult;
Result.OnStart := Start;
Result.OnSuccess := Display;
Result.OnError := Display;
end );官方文檔的詳細設置
接受從64x64像素到最大1兆像素的圖像,將其分辨率提高到4K。更廣泛地說,它可以在維護和通常提高其質量的同時將圖像提高約20至40倍。創意的高檔功能對於大量退化的圖像特別有效,但它不適合大於1兆像素的照片,因為它應用了重大的重新解釋(可通過創造力量表調節)。
警告
此功能被編輯器標記為異步,但實際上,對於使用它的第三方應用程序而言,它的行為並不是這樣。它更像是一種稍微延遲處理的緩存機制。
異步代碼示例
// uses
// StabilityAI, StabilityAI.Types, StabilityAI.Common, FMX.Stability.Tutorial,
// StabilityAI.StableImage.Upscale;
Stability.StableImage.Upscale.Creative(
procedure (Params: TUpscaleCreative)
begin
Params.Image( ' lighthouse.png ' );
Params.Prompt( ' The gray light house ' );
Params.OutputFormat(png);
end ,
function : TAsynResults
begin
Result.Sender := StabilityResult;
Result.OnStart := Start;
Result.OnSuccess := Display;
Result.OnError := Display;
end );官方文檔的詳細設置
我們檢索作業ID,在下一步中,除非檢索的狀態為“過程中”,否則我們需要加載圖像。在這種情況下,應重新進行操作。
// uses
// StabilityAI, StabilityAI.Types, StabilityAI.Common, FMX.Stability.Tutorial,
// StabilityAI.StableImage.Results,
// e.g. Id ---> ea771536f066b7fd03d62384581982ecd8b54a932a6378d5809d43f6e5aa789a
StabilityResult.FileName := ' Upscalelighthouse2.png ' ;
Stability.StableImage.Results.Fetch(StabilityResult.Id,
function : TAsynResults
begin
Result.Sender := StabilityResult;
Result.OnStart := Start;
Result.OnSuccess := Display;
Result.OnError := Display;
end );官方文檔的詳細設置
快速上限器服務膜圖像分辨率提高了400%。它專為速度和效率而設計,在大約一秒鐘內處理圖像,使其成為改善壓縮視覺效果的絕佳工具,非常適合社交媒體帖子和其他各種用途。
異步代碼示例
// uses
// StabilityAI, StabilityAI.Types, StabilityAI.Common, FMX.Stability.Tutorial,
// StabilityAI.StableImage.Upscale;
StabilityResult.FileName := ' Upscalelighthouse3.png ' ;
Stability.StableImage.Upscale.Fast(
procedure (Params: TUpscaleFast)
begin
Params.Image( ' lighthouse.png ' );
Params.OutputFormat(png);
end ,
function : TAsynStableImage
begin
Result.Sender := StabilityResult;
Result.OnStart := Start;
Result.OnSuccess := Display;
Result.OnError := Display;
end );官方文檔的詳細設置
功能清單
擦除服務旨在消除圖像中的不必要元素,例如使用掩蔽技術在面上的瑕疵或表面上的對象。
可以用兩種方法之一提供Masks :
mask參數提供單獨的圖像。異步代碼示例
筆記
mask ,則將根據圖像的Alpha通道自動生成掩碼。透明區域將受到覆蓋,而不透明的區域將保持不變。mask一起提供,則mask將覆蓋Alpha通道。 // uses
// StabilityAI, StabilityAI.Types, StabilityAI.Common, FMX.Stability.Tutorial,
// StabilityAI.StableImage.Edit;
StabilityResult.FileName := ' EraseLighthouse.png ' ;
Stability.StableImage.Edit.Erase(
procedure (Params: TErase)
begin
Params.Image( ' Lighthouse.png ' );
Params.OutputFormat(png);
end ,
function: TAsynStableImage
begin
Result.Sender := StabilityResult;
Result.OnStart := Start;
Result.OnSuccess := Display;
Result.OnError := Display;
end );提供口罩時:
筆記
mask的尺寸與圖像參數的尺寸不同,則將自動調整以匹配圖像大小。 Stability.StableImage.Edit.Erase(
procedure (Params: TErase)
begin
Params.Image( ' Lighthouse.png ' );
Params.Mask( ' MyMask01.png ' );
Params.GrowMask( 6 );
Params.OutputFormat(png);
end ,
...官方文檔的詳細設置
通過添加或替換新內容的特定部分,以mask圖像為指導,通過添加或替換特定部分來智能修改圖像。
該mask可以通過兩種方式提供:
// uses
// StabilityAI, StabilityAI.Types, StabilityAI.Common, FMX.Stability.Tutorial,
// StabilityAI.StableImage.Edit;
StabilityResult.FileName := ' InpaintLighthouse.png ' ;
Stability.StableImage.Edit.Inpaint(
procedure (Params: TInpaint)
begin
Params.Image( ' Lighthouse.png ' );
Params.Mask( ' Mask01.png ' );
Params.Prompt( ' The lighthouse is bigger ' );
Params.OutputFormat(png);
end ,
function: TAsynStableImage
begin
Result.Sender := StabilityResult;
Result.OnStart := Start;
Result.OnSuccess := Display;
Result.OnError := Display;
end ); mask的使用與擦除API所描述的使用相同。
官方文檔的詳細設置
支出服務允許通過沿任何方向添加內容填充周圍空間的內容來無縫擴展圖像。與其他方法,無論是自動化的還是手動的,此服務旨在減少可見的偽影並避免明顯的圖像編輯指示。
// uses
// StabilityAI, StabilityAI.Types, StabilityAI.Common, FMX.Stability.Tutorial,
// StabilityAI.StableImage.Edit;
StabilityResult.FileName := ' OutpaintLighthouse.png ' ;
Stability.StableImage.Edit.Outpaint(
procedure (Params: TOutpaint)
begin
Params.Image( ' Lighthouse.png ' );
Params.Right( 200 );
Params.Down( 400 );
Params.OutputFormat(png);
end ,
function: TAsynStableImage
begin
Result.Sender := StabilityResult;
Result.OnStart := Start;
Result.OnSuccess := Display;
Result.OnError := Display;
end );官方文檔的詳細設置
搜索和替換服務提供了一種專門的介入形式,可以消除對掩蔽的需求。相反,用戶可以通過使用search_prompt用簡單的語言來指定一個對象來替換。然後,該服務將自動檢測並分割指定的對象,並用提示中描述的一個無縫代替它。
// uses
// StabilityAI, StabilityAI.Types, StabilityAI.Common, FMX.Stability.Tutorial,
// StabilityAI.StableImage.Edit;
StabilityResult.FileName := ' SearchReplaceLighthouse.png ' ;
Stability.StableImage.Edit.SearchAndReplace(
procedure (Params: TSearchAndReplace)
begin
Params.Image( ' Lighthouse.png ' );
Params.Prompt( ' Replace the lighthouse ' );
Params.SearchPrompt( ' Lighthouse ' );
Params.OutputFormat(png);
end ,
function: TAsynStableImage
begin
Result.Sender := StabilityResult;
Result.OnStart := Start;
Result.OnSuccess := Display;
Result.OnError := Display;
end );官方文檔的詳細設置
通過利用搜索和重新著色服務,您可以通過簡單的提示更改圖像中特定對象的顏色。這種專門的介入形式不需要面罩。相反,該服務自動段落對象並按照提示中指定的新顏色應用。
// uses
// StabilityAI, StabilityAI.Types, StabilityAI.Common, FMX.Stability.Tutorial,
// StabilityAI.StableImage.Edit;
StabilityResult.FileName := ' SearchRecolorLighthouse.png ' ;
Stability.StableImage.Edit.SearchAndRecolor(
procedure (Params: TSearchAndRecolor)
begin
Params.Image( ' Lighthouse.png ' );
Params.Prompt( ' The lighthouse is pink ' );
Params.SelectPrompt( ' Lighthouse ' );
Params.OutputFormat(png);
end ,
function: TAsynStableImage
begin
Result.Sender := StabilityResult;
Result.OnStart := Start;
Result.OnSuccess := Display;
Result.OnError := Display;
end );官方文檔的詳細設置
刪除背景服務精確地識別並隔離了圖像中的前景,從而可以根據需要刪除或更換背景。
// uses
// StabilityAI, StabilityAI.Types, StabilityAI.Common, FMX.Stability.Tutorial,
// StabilityAI.StableImage.Edit;
StabilityResult.FileName := ' RemoveBackgroundLighthouse.png ' ;
Stability.StableImage.Edit.RemoveBackground(
procedure (Params: TRemoveBackground)
begin
Params.Image( ' Lighthouse.png ' );
Params.OutputFormat(png);
end ,
function: TAsynStableImage
begin
Result.Sender := StabilityResult;
Result.OnStart := Start;
Result.OnSuccess := Display;
Result.OnError := Display;
end );官方文檔的詳細設置
替換背景和Relight Editing Service可以使用AI生成的圖像或其自己的上傳毫不費力地更改背景,同時無縫調整照明以補充主題。該API提供了針對各種行業的高效圖像編輯解決方案,包括電子商務,房地產,攝影和創意努力。
關鍵功能包括:
警告
此功能被編輯器標記為異步,但實際上,對於使用它的第三方應用程序而言,它的行為並不是這樣。它更像是一種稍微延遲處理的緩存機制。
// uses
// StabilityAI, StabilityAI.Types, StabilityAI.Common, FMX.Stability.Tutorial,
// StabilityAI.StableImage.Edit;
Stability.StableImage.Edit.ReplaceBackgroundAndRelight(
procedure (Params: TReplaceBackgroundAndRelight)
begin
Params.SubjectImage( ' Lighthouse.png ' );
Params.BackgroundPrompt( ' cinematic lighting ' );
Params.OutputFormat(png);
end ,
function: TAsynResults
begin
Result.Sender := StabilityResult;
Result.OnStart := Start;
Result.OnSuccess := Display;
Result.OnError := Display;
end );API返回正在進行的任務的ID,就像高檔創意API一樣。然後,如前所述,您需要使用獲取API。
官方文檔的詳細設置
創建圖像和草圖的受控變體的工具
該工具旨在用於涉及迭代設計和頭腦風暴的開發工作流程。它通過精確的調整將手繪草圖轉換為拋光的視覺效果。此外,它通過利用圖像的輪廓和邊緣來微調對非縫製圖像的最終外觀的微調控制。
// uses
// StabilityAI, StabilityAI.Types, StabilityAI.Common, FMX.Stability.Tutorial,
// StabilityAI.StableImage.Control;
StabilityResult.FileName := ' Control01.png ' ;
Stability.StableImage.Control.Sketch(
procedure (Params: TSketch)
begin
Params.Image( ' lighthouse.png ' );
Params.ControlStrength( 0.7 );
Params.Prompt( ' a medieval castle on a hill ' );
Params.OutputFormat(png);
end ,
function : TAsynStableImage
begin
Result.Sender := StabilityResult;
Result.OnStart := Start;
Result.OnSuccess := Display;
Result.OnError := Display;
end );官方文檔的詳細設置
該服務旨在在保留輸入圖像的結構時生成圖像,從而使其對於復制場景或基於預定義的模型渲染字符之類的任務特別有用。
// uses
// StabilityAI, StabilityAI.Types, StabilityAI.Common, FMX.Stability.Tutorial,
// StabilityAI.StableImage.Control;
StabilityResult.FileName := ' Control02.png ' ;
Stability.StableImage.Control.Structure(
procedure (Params: TStructure)
begin
Params.Image( ' lighthouse.png ' );
Params.ControlStrength( 0.7 );
Params.Prompt( ' a well manicured shrub in an english garden ' );
Params.OutputFormat(png);
end ,
function : TAsynStableImage
begin
Result.Sender := StabilityResult;
Result.OnStart := Start;
Result.OnSuccess := Display;
Result.OnError := Display;
end );官方文檔的詳細設置
該工具分析給定輸入圖像(控製圖像)的風格特徵,並將其應用它們以生成由指定提示的新圖像。輸出圖像在合併請求的內容時保留了控製圖像的視覺樣式。
// uses
// StabilityAI, StabilityAI.Types, StabilityAI.Common, FMX.Stability.Tutorial,
// StabilityAI.StableImage.Control;
StabilityResult.FileName := ' Control03.png ' ;
Stability.StableImage.Control.Style(
procedure (Params: TStyle)
begin
Params.Image( ' lighthouse.png ' );
Params.Prompt( ' a majestic portrait of a chicken ' );
Params.Fidelity( 0.7 );
Params.OutputFormat(png);
end ,
function : TAsynStableImage
begin
Result.Sender := StabilityResult;
Result.OnStart := Start;
Result.OnSuccess := Display;
Result.OnError := Display;
end );官方文檔的詳細設置
獲取異步幾代結果的工具。
要使用,請參見Fetch async生成結果
穩定的快速3D從單個2D輸入圖像生成高質量的3D資產。
有關更多詳細信息,請參見GLB文件格式規範。
// uses
// StabilityAI, StabilityAI.Types, StabilityAI.Common, FMX.Stability.Tutorial,
// StabilityAI.VideoAnd3D.Stable3D;
StabilityResult.FileName := ' My_Result.gltf ' ;
Stability.VideoAnd3D.Model3D.Fast3D(
procedure (Params: TStable3D)
begin
Params.Image( ' My_ImageTo3D.png ' );
Params.ForegroundRatio( 0.85 );
end ,
function : TAsynModel3D
begin
Result.Sender := StabilityResult;
Result.OnStart := Start;
Result.OnSuccess := Display;
Result.OnError := Display;
end );官方文檔的詳細設置
使用穩定的視頻擴散,一種潛在的視頻擴散模型,從初始圖像中生成一個簡短的視頻。
ID從響應中檢索以檢查image-to-video/result/{id} endpoint的結果。確保不要每10秒鐘一次對此終點進行輪詢,以避免錯誤或限制問題。 // uses
// StabilityAI, StabilityAI.Types, StabilityAI.Common, FMX.Stability.Tutorial,
// StabilityAI.VideoAnd3D.Video;
Stability.VideoAnd3D.ImageToVideo.Generation(
procedure (Params: TVideo)
begin
Params.Image( ' lighthouse1024x576.png ' );
end ,
function : TAsynJobVideo
begin
Result.Sender := StabilityResult;
Result.OnStart := Start;
Result.OnSuccess := Display;
Result.OnError := Display;
end );最後,我們檢索了視頻創建任務的ID( EG D4FB4AA.8301AEE0B368A41B3C0A78018DFC28DFC28F1F959A3666666666666951408FB8E3 )。然後,我們只是以這種方式檢索結果。
官方文檔的詳細設置
// uses
// StabilityAI, StabilityAI.Types, StabilityAI.Common, FMX.Stability.Tutorial,
// StabilityAI.VideoAnd3D.Video;
var Id := ' d4fb4aa8301aee0b368a41b3c0a78018dfc28f1f959a3666be2e6951408fb8e3 ' ;
StabilityResult.FileName := ' lighthouse1024x576.mp4 ' ;
Stability.VideoAnd3D.ImageToVideo.Fetch(Id,
function : TAsynResults
begin
Result.Sender := StabilityResult;
Result.OnStart := Start;
Result.OnSuccess := Display;
Result.OnError := Display;
end );官方文檔的詳細設置
列出與Version 1 REST API端點兼容的引擎。
// uses
// StabilityAI, StabilityAI.Types, StabilityAI.Common, FMX.Stability.Tutorial,
// StabilityAI.Version1.Engines;
Stability.Version1.Engines.List(
function : TAsynEngines
begin
Result.Sender := StabilityResult;
Result.OnStart := Start;
Result.OnSuccess := Display;
Result.OnError := Display;
end );官方文檔的詳細設置
檢索有關鏈接到指定API密鑰的帳戶的詳細信息
// uses
// StabilityAI, StabilityAI.Types, StabilityAI.Common, FMX.Stability.Tutorial,
// StabilityAI.Version1.User;
Stability.Version1.User.AccountDetails(
function : TAsynAccountDetails
begin
Result.Sender := StabilityResult;
Result.OnStart := Start;
Result.OnSuccess := Display;
Result.OnError := Display;
end );官方文檔的詳細設置
檢索鏈接到提供的API密鑰的帳戶或組織的信用餘額。
// uses
// StabilityAI, StabilityAI.Types, StabilityAI.Common, FMX.Stability.Tutorial,
// StabilityAI.Version1.User;
var Balance := Stability.Version1.User.AccountBalance;
try
Memo1.Lines.Text := Memo1.Text + Balance.Credits.ToString + sLineBreak;
finally
Balance.Free;
end ;官方文檔的詳細設置
穩定性。 EAI已宣布了兩個即將到來的功能:
Stable LLM 12B和Stable LLM 1.6B 。Audio Stable 2.0 。您可以通過發送消息聯繫穩定性。 AI來測試此模型。歡迎拉動請求。如果您打算進行重大更改,請先開設一個問題,討論您建議的更改。
該項目已根據MIT許可獲得許可。