3
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

かんたん

新しいモデルは色々あるけど、とはいえYolov8は強力で、
簡単に使えて便利なので、すぐ使えるように手順をシンプルに。

インストール

pip install ultralytics

データセット準備

以下のディレクトリ構成で準備します。

datasets
   |__my_data
         |__images
         |    |__train
         |    |__val
         |
         |__labels
              |__train
              |__val
          

データyamlファイルを作ります。
path:は頭に自動的にdatasetsというディレクトリがつくので注意。

path: my_data # dataset root dir
train: images/train2017 # train images (relative to 'path') 128 images
val: images/train2017 # val images (relative to 'path') 128 images
test: # test images (optional)

# Classes
names:
  0: person
  1: bicycle
  2: car
  3: motorcycle
  4: airplane
  5: bus
  6: train
  7: truck
  8: boat
  9: traffic light
  10: fire hydrant
  11: stop sign
  12: parking meter
  13: bench
  14: bird
  15: cat
  16: dog
  17: horse
  ...

学習

from ultralytics import YOLO

# Load a model
model = YOLO('yolov8s.pt')  # load a pretrained model (recommended for training)

# Use the model
results = model.train(data='my_data.yaml', epochs=100)  # train the model

検証

model = YOLO('runs/detect/train/weights/best.pt')
model.val(data='my_data.yaml')

推論

model = YOLO('runs/detect/train/weights/best.pt')
model("datasets/my_data/images/val/",save=True)

🐣


フリーランスエンジニアです。
AIについて色々記事を書いていますのでよかったらプロフィールを見てみてください。

もし以下のようなご要望をお持ちでしたらお気軽にご相談ください。
AIサービスを開発したい、ビジネスにAIを組み込んで効率化したい、AIを使ったスマホアプリを開発したい、
ARを使ったアプリケーションを作りたい、スマホアプリを作りたいけどどこに相談したらいいかわからない…

いずれも中間コストを省いたリーズナブルな価格でお請けできます。

お仕事のご相談はこちらまで
rockyshikoku@gmail.com

機械学習やAR技術を使ったアプリケーションを作っています。
機械学習/AR関連の情報を発信しています。

X
Medium
GitHub

3
2
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
3
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?