Upgrade to Pro — share decks privately, control downloads, hide ads and more …

20230322 - Generative AI 小聚 ft. Happy Designer

20230322 - Generative AI 小聚 ft. Happy Designer

TLDR

蒼時弦や

March 22, 2023
Tweet

More Decks by 蒼時弦や

Other Decks in Technology

Transcript

  1. 除了串 API 之外工程師還能做些什麼
    Generative AI Meetup ft. Happy Designer

    View Slide

  2. 蒼時弦也
    Software Developer
    https://blog.aotoki.me

    View Slide

  3. 開始之前
    生態系進化太快,都不知道該怎麼辦⋯⋯

    View Slide

  4. Diffusers
    簡單使用 Stable Diffusion 的方法

    View Slide

  5. Hugging Face
    AI 領域的 GitHub,大部分開源模型都可以在上面找到

    View Slide

  6. import
    from import
    =
    =
    =
    =
    =
    torch

    diffusers StableDiffusionPipeline


    pipe StableDiffusionPipeline.from_pretrained(
    , torch.float16)

    pipe pipe.to( )


    prompt
    image pipe(prompt).images[ ]
    # 載入模型

    # 進行運算

    "runwayml/stable-
    diffusion-v1-5"
    "cuda"
    "a photo of an astronaut riding a horse on mars"

    torch_dtype
    0

    View Slide

  7. # ...

    # 載入不同模型


    # 多重處理

    prompt
    image txt2image(prompt).images[ ]

    image upscale(image).images[ ]

    image image2image(image).images[ ]
    =
    =
    =
    =
    "a photo of an astronaut riding a horse on mars"

    0
    0
    0

    View Slide

  8. View Slide

  9. http://bit.ly/3JJf16o

    View Slide

  10. Replicate
    目前最好用的 Serverless GPU 服務

    View Slide

  11. View Slide

  12. from import
    import
    class
    def
    def
    = =
    = =
    =
    return
    cog BasePredictor, Path, Input

    torch


    ( ):

    (self):

    (self,

    image: Path Input( ),

    scale: Input(
    , )

    ) -> Path:

    output
    Predictor BasePredictor
    setup
    predict
    # 初始化、載入模型


    # 處理 e.g. Stable Diffusion Pipeline

    description
    description
    default
    "Image to enlarge"
    "Factor to scale
    image by"
    float
    1.5

    View Slide

  13. $
    $
    cog login

    cog push r8.im your username your model name
    /< - >/< - - >

    View Slide

  14. 有 GPU 的伺服器、API 都有了,剩下就是套應用

    View Slide

  15. AI Gacha
    使用 Diffusers、Replicate 的實驗性專案

    View Slide

  16. View Slide

  17. http://bit.ly/3yImmgc

    View Slide

  18. 我的看法
    能做的事情其實不多,大部分應用的成本也偏高,但是商用已經沒
    有問題,剩下要處理的大概會在 跟讓更多人能
    合法的版權 輕鬆上手

    View Slide