1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

秀和システム「Python x API で動かして学ぶ AI活用プログラミング」1章

Posted at

秀和システム「Python x API で動かして学ぶ AI活用プログラミング」
1章をやってみた。
ここでは記事の内容ではなく、自環境での動作結果だけを記録のために記載しています。

環境

OS:Windows 11 Home 64 ビット オペレーティング システム
CPU:11th Gen Intel(R) Core(TM) i7-1185G7 @ 3.00GHz 3.00 GHz
RAM:32.0 GB

ソース

image.png
(中略)
image.png

1_ObjectDetection_app.py
import streamlit as st
import cv2
import numpy as np
from ultralytics import YOLO

# モデルの読み込み
model = YOLO('yolov8n.pt') 

# Input
camera_img = st.camera_input(label='インカメラ画像')

# Process
if camera_img is not None:

    bytes_data = camera_img.getvalue()
    cv2_img = cv2.imdecode(np.frombuffer(bytes_data, np.uint8), 
                            cv2.IMREAD_COLOR)
    results = model(cv2_img,conf=0.5)
    output_img = results[0].plot(labels=True,conf=True)
    output_img = cv2.cvtColor(output_img, cv2.COLOR_BGR2RGB)
# Output
    st.image(output_img, caption='出力画像')

実行結果

image.png

1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?