爱意满满的作品展示区。
sadhen

直接用 Rikai SQL 检测图像中的周杰伦

  •  1
     
  •   sadhen ·
    darcy-shen · Jan 21, 2022 · 1922 views
    This topic created in 1577 days ago, the information mentioned may be changed or developed.

    直接用 SQL 就可以调用 Yolov5 模型,做图像检测。

    详见Open in Google Colab

    下面是用 sql 查询得到结果,用 python 把检测结果图层叠加上去的代码片段:

    from rikai.viz import Text
    from rikai.types.vision import Image
    from functools import reduce
    
    df = spark.sql(f"""
    select * from (
      select explode(ML_PREDICT(yolov5m, image)) as pred
      from (
        select to_image('{uri}') as image
      )
    )
    where pred.label = 'person' -- truck/car/person
    """)
    preds = [row.pred for row in df.collect()]
    
    def add_layer(image, pred):
        return image | pred.box | Text(pred.label, (pred.box.xmin, pred.box.ymin - 10))
    
    reduce(lambda a,b: add_layer(a, b), [image] + preds)
    

    对 Rikai 感兴趣的小伙伴可以观看完整视频《 Rikai: 视频内容理解引擎》

    想要和我一起工作么,加入我们

    帮忙在 Hacknews Upvote: https://news.ycombinator.com/item?id=30019507

    ttys001
        1
    ttys001  
       Jan 21, 2022
    有点意思
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   886 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 29ms · UTC 22:28 · PVG 06:28 · LAX 15:28 · JFK 18:28
    ♥ Do have faith in what you're doing.