1.以換臉為主要業務
2.接收使用者畫出遮罩區域及傳送換臉圖片
3.將資料傳到azure,再由azure進行排程控管,當排程順位為一時,連線到stable diffusion主機,進行處理。
4.處理完畢,回傳到azure,再由azure回傳到客戶端頁面,藉此隱藏stable diffusion主機的真實位址。
需要學習的功能:
- 排隊
- 前端畫遮罩功能
- paypal收費轉換成使用次數功能
內容目錄
串接 stable diffusion api 參考資源
- How to Install Stable Diffusion on Ubuntu || Run Stable Diffusion AI on Linux (youtube.com)
- 开源!如何把stable diffusion变成商用软件?教你正确的调用stable diffusion api! (youtube.com)
- stable diffusion的javascript最强开源模版!stable diffusion api & react 前端开源代码详解!优雅的搭建AI绘图网站! (youtube.com)
- I tried to build a REACT STABLE DIFFUSION App in 15 minutes (youtube.com)
- 【AI绘画】三分钟教你怎么利用Stable Diffusion webUI的API接口开发属于自己的绘画流程_哔哩哔哩_bilibili
- stable diffusion api 多人列队及跟随列队切换模型代码讲解_哔哩哔哩_bilibili
- 關於我:Ivon Huang · Ivon的部落格 (ivonblog.com)
- python – How to mask image with binary mask? – Stack Overflow
- stable diffusion 远端跑图—— Api基础知识掌握 – 知乎 (zhihu.com)
- RunPod Partners With RandomSeed to Provide Accessible, User-Friendly Stable Diffusion API Access
- stable diffusion 远端跑图—— Api进阶知识掌握(一)第三方插件的api调用方式 – 知乎 (zhihu.com)
- 潛在對手YouCam Enhance | Best AI Photo Enhancer to Upgrade Any Photo (perfectcorp.com)
- 潛在對手美妝科技 & AR 技術領導者 | 玩美移動 (perfectcorp.com)
串接 paypal 參考資源
Part 1 : Overview of The Course | PayPal Integration With .NET (youtube.com)
從5. 【AI绘画】三分钟教你怎么利用Stable Diffusion webUI的API接口开发属于自己的绘画流程_哔哩哔哩_bilibili開始實作
因為5.的影片長度最短,先從5.開始。
import requests
from PIL import Image
import io
import base64
url = "http://127.0.0.1:7860"
# 文生圖
text2img_data = {
"prompt":"13 years old smirk girl,(8k, best quality, masterpiece:1.2), black hair, (realistic, photo-realistic:1.37), ultra-detailed, 1 girl,cute, solo",
"sampler_name":"DDIM",
"batch_size":1,
"steps":20,
"cfg_scale":9,
"width":512,
"height":768,
"negative_prompt":"umbrella, car, flower,paintings, sketches, (worst quality:2), (low quality:2), (normal quality:2), lowres, normal quality, ((monochrome)), ((grayscale)), skin spots, acnes, skin blemishes, age spot, (outdoor:1.6), manboobs, backlight,(ugly:1.331), (duplicate:1.331), (morbid:1.21), (mutilated:1.21), (tranny:1.331), mutated hands, (poorly drawn hands:1.331), blurry, (bad anatomy:1.21), (bad proportions:1.331), extra limbs, (disfigured:1.331), (more than 2 nipples:1.331), (missing arms:1.331), (extra legs:1.331), (fused fingers:1.61051), (too many fingers:1.61051), (unclear eyes:1.331), bad hands, missing fingers, extra digit, (futa:1.1), bad body, NG_DeepNegative_V1_75T,pubic hair, glans"
}
response = requests.post(url=f' {url}/sdapi/v1/txt2img', json=text2img_data)
response.json()
image = Image.open(io.BytesIO(base64.b64decode(response.json()['images'][0])))
image
# 圖生圖
with io.BytesIO() as output:
image.save(output, format='JPEG')
image_bytes = output.getvalue()
image_code = base64.b64encode(image_bytes).decode('utf-8')
image_code
img2img_data = {
"init_images":[
image_code
],
"seed":123456789,
"resize_mode": 1,
"inpaint_full_res": True,
"denoising_strength":0.5,
"prompt":"13 years old smirk girl,<lora:android_2:1>,(8k, best quality, masterpiece:1.2), black hair, (realistic, photo-realistic:1.37), ultra-detailed, 1 girl,cute, solo",
"sampler_name":"DDIM",
"batch_size":1,
"steps":20,
"cfg_scale":9,
"width":512,
"height":512,
"negative_prompt":"umbrella, car, flower,paintings, sketches, (worst quality:2), (low quality:2), (normal quality:2), lowres, normal quality, ((monochrome)), ((grayscale)), skin spots, acnes, skin blemishes, age spot, (outdoor:1.6), manboobs, backlight,(ugly:1.331), (duplicate:1.331), (morbid:1.21), (mutilated:1.21), (tranny:1.331), mutated hands, (poorly drawn hands:1.331), blurry, (bad anatomy:1.21), (bad proportions:1.331), extra limbs, (disfigured:1.331), (more than 2 nipples:1.331), (missing arms:1.331), (extra legs:1.331), (fused fingers:1.61051), (too many fingers:1.61051), (unclear eyes:1.331), bad hands, missing fingers, extra digit, (futa:1.1), bad body, NG_DeepNegative_V1_75T,pubic hair, glans"
}
response = requests.post(url=f' {url}/sdapi/v1/img2img', json=img2img_data)
response.json()
image = Image.open(io.BytesIO(base64.b64decode(response.json()['images'][0])))
image
到這裡已經可以文生圖、圖生圖了,且透過”resize_mode”: 1 可以開啟crop and resize模式。
6. stable diffusion api 多人列队及跟随列队切换模型代码讲解_哔哩哔哩_bilibili看起來很詳細,接著看


這個影片是講說他如何把原本的api修改成可以多人排隊、鎖執行緒,文生圖的參數如上,但圖生圖隻字未提。
接著實作3. stable diffusion的javascript最强开源模版!stable diffusion api & react 前端开源代码详解!优雅的搭建AI绘图网站! (youtube.com)
因為這個影片有掩飾出完整的webui功能,也有話遮罩的部分,可能需要透過觀察他的程式碼來學習。
幹….一堆沒頭沒尾的東西,缺乏基礎知識根本沒辦法照做。
我已經建立一個空的react專案>用npm 安裝package,但是不知道怎麼使用到專案裡面。
接著實作8. python – How to mask image with binary mask? – Stack Overflow
有成功將固定式遮罩當作參數傳給後端。