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 full-size slide

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

    View full-size slide

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

    View full-size slide

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

    View full-size slide

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

    View full-size 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 full-size 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 full-size slide

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

    View full-size slide

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

    View full-size slide

  10. 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 full-size slide

  11. $
    $
    cog login

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

    View full-size slide

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

    View full-size slide

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

    View full-size slide

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

    View full-size slide

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

    View full-size slide