Reformat Markdown code blocks (#12795)
Signed-off-by: Glenn Jocher <glenn.jocher@ultralytics.com> Co-authored-by: UltralyticsAssistant <web@ultralytics.com>
This commit is contained in:
parent
2af71d15a6
commit
fceea033ad
128 changed files with 1067 additions and 1018 deletions
|
|
@ -42,10 +42,10 @@ To train a YOLOv8n model on the African wildlife dataset for 100 epochs with an
|
|||
from ultralytics import YOLO
|
||||
|
||||
# Load a model
|
||||
model = YOLO('yolov8n.pt') # load a pretrained model (recommended for training)
|
||||
model = YOLO("yolov8n.pt") # load a pretrained model (recommended for training)
|
||||
|
||||
# Train the model
|
||||
results = model.train(data='african-wildlife.yaml', epochs=100, imgsz=640)
|
||||
results = model.train(data="african-wildlife.yaml", epochs=100, imgsz=640)
|
||||
```
|
||||
|
||||
=== "CLI"
|
||||
|
|
@ -63,7 +63,7 @@ To train a YOLOv8n model on the African wildlife dataset for 100 epochs with an
|
|||
from ultralytics import YOLO
|
||||
|
||||
# Load a model
|
||||
model = YOLO('path/to/best.pt') # load a brain-tumor fine-tuned model
|
||||
model = YOLO("path/to/best.pt") # load a brain-tumor fine-tuned model
|
||||
|
||||
# Inference using the model
|
||||
results = model.predict("https://ultralytics.com/assets/african-wildlife-sample.jpg")
|
||||
|
|
|
|||
|
|
@ -53,10 +53,10 @@ To train a YOLOv8n model on the Argoverse dataset for 100 epochs with an image s
|
|||
from ultralytics import YOLO
|
||||
|
||||
# Load a model
|
||||
model = YOLO('yolov8n.pt') # load a pretrained model (recommended for training)
|
||||
model = YOLO("yolov8n.pt") # load a pretrained model (recommended for training)
|
||||
|
||||
# Train the model
|
||||
results = model.train(data='Argoverse.yaml', epochs=100, imgsz=640)
|
||||
results = model.train(data="Argoverse.yaml", epochs=100, imgsz=640)
|
||||
```
|
||||
|
||||
=== "CLI"
|
||||
|
|
|
|||
|
|
@ -52,10 +52,10 @@ To train a YOLOv8n model on the brain tumor dataset for 100 epochs with an image
|
|||
from ultralytics import YOLO
|
||||
|
||||
# Load a model
|
||||
model = YOLO('yolov8n.pt') # load a pretrained model (recommended for training)
|
||||
model = YOLO("yolov8n.pt") # load a pretrained model (recommended for training)
|
||||
|
||||
# Train the model
|
||||
results = model.train(data='brain-tumor.yaml', epochs=100, imgsz=640)
|
||||
results = model.train(data="brain-tumor.yaml", epochs=100, imgsz=640)
|
||||
```
|
||||
|
||||
=== "CLI"
|
||||
|
|
@ -73,7 +73,7 @@ To train a YOLOv8n model on the brain tumor dataset for 100 epochs with an image
|
|||
from ultralytics import YOLO
|
||||
|
||||
# Load a model
|
||||
model = YOLO('path/to/best.pt') # load a brain-tumor fine-tuned model
|
||||
model = YOLO("path/to/best.pt") # load a brain-tumor fine-tuned model
|
||||
|
||||
# Inference using the model
|
||||
results = model.predict("https://ultralytics.com/assets/brain-tumor-sample.jpg")
|
||||
|
|
|
|||
|
|
@ -70,10 +70,10 @@ To train a YOLOv8n model on the COCO dataset for 100 epochs with an image size o
|
|||
from ultralytics import YOLO
|
||||
|
||||
# Load a model
|
||||
model = YOLO('yolov8n.pt') # load a pretrained model (recommended for training)
|
||||
model = YOLO("yolov8n.pt") # load a pretrained model (recommended for training)
|
||||
|
||||
# Train the model
|
||||
results = model.train(data='coco.yaml', epochs=100, imgsz=640)
|
||||
results = model.train(data="coco.yaml", epochs=100, imgsz=640)
|
||||
```
|
||||
|
||||
=== "CLI"
|
||||
|
|
|
|||
|
|
@ -45,10 +45,10 @@ To train a YOLOv8n model on the COCO8 dataset for 100 epochs with an image size
|
|||
from ultralytics import YOLO
|
||||
|
||||
# Load a model
|
||||
model = YOLO('yolov8n.pt') # load a pretrained model (recommended for training)
|
||||
model = YOLO("yolov8n.pt") # load a pretrained model (recommended for training)
|
||||
|
||||
# Train the model
|
||||
results = model.train(data='coco8.yaml', epochs=100, imgsz=640)
|
||||
results = model.train(data="coco8.yaml", epochs=100, imgsz=640)
|
||||
```
|
||||
|
||||
=== "CLI"
|
||||
|
|
|
|||
|
|
@ -48,10 +48,10 @@ To train a YOLOv8n model on the Global Wheat Head Dataset for 100 epochs with an
|
|||
from ultralytics import YOLO
|
||||
|
||||
# Load a model
|
||||
model = YOLO('yolov8n.pt') # load a pretrained model (recommended for training)
|
||||
model = YOLO("yolov8n.pt") # load a pretrained model (recommended for training)
|
||||
|
||||
# Train the model
|
||||
results = model.train(data='GlobalWheat2020.yaml', epochs=100, imgsz=640)
|
||||
results = model.train(data="GlobalWheat2020.yaml", epochs=100, imgsz=640)
|
||||
```
|
||||
|
||||
=== "CLI"
|
||||
|
|
|
|||
|
|
@ -56,10 +56,10 @@ Here's how you can use these formats to train your model:
|
|||
from ultralytics import YOLO
|
||||
|
||||
# Load a model
|
||||
model = YOLO('yolov8n.pt') # load a pretrained model (recommended for training)
|
||||
model = YOLO("yolov8n.pt") # load a pretrained model (recommended for training)
|
||||
|
||||
# Train the model
|
||||
results = model.train(data='coco8.yaml', epochs=100, imgsz=640)
|
||||
results = model.train(data="coco8.yaml", epochs=100, imgsz=640)
|
||||
```
|
||||
=== "CLI"
|
||||
|
||||
|
|
@ -103,7 +103,7 @@ You can easily convert labels from the popular COCO dataset format to the YOLO f
|
|||
```python
|
||||
from ultralytics.data.converter import convert_coco
|
||||
|
||||
convert_coco(labels_dir='path/to/coco/annotations/')
|
||||
convert_coco(labels_dir="path/to/coco/annotations/")
|
||||
```
|
||||
|
||||
This conversion tool can be used to convert the COCO dataset or any dataset in the COCO format to the Ultralytics YOLO format.
|
||||
|
|
|
|||
|
|
@ -66,10 +66,10 @@ To train a YOLOv8n model on the LVIS dataset for 100 epochs with an image size o
|
|||
from ultralytics import YOLO
|
||||
|
||||
# Load a model
|
||||
model = YOLO('yolov8n.pt') # load a pretrained model (recommended for training)
|
||||
model = YOLO("yolov8n.pt") # load a pretrained model (recommended for training)
|
||||
|
||||
# Train the model
|
||||
results = model.train(data='lvis.yaml', epochs=100, imgsz=640)
|
||||
results = model.train(data="lvis.yaml", epochs=100, imgsz=640)
|
||||
```
|
||||
|
||||
=== "CLI"
|
||||
|
|
|
|||
|
|
@ -48,10 +48,10 @@ To train a YOLOv8n model on the Objects365 dataset for 100 epochs with an image
|
|||
from ultralytics import YOLO
|
||||
|
||||
# Load a model
|
||||
model = YOLO('yolov8n.pt') # load a pretrained model (recommended for training)
|
||||
model = YOLO("yolov8n.pt") # load a pretrained model (recommended for training)
|
||||
|
||||
# Train the model
|
||||
results = model.train(data='Objects365.yaml', epochs=100, imgsz=640)
|
||||
results = model.train(data="Objects365.yaml", epochs=100, imgsz=640)
|
||||
```
|
||||
|
||||
=== "CLI"
|
||||
|
|
|
|||
|
|
@ -88,10 +88,10 @@ To train a YOLOv8n model on the Open Images V7 dataset for 100 epochs with an im
|
|||
from ultralytics import YOLO
|
||||
|
||||
# Load a COCO-pretrained YOLOv8n model
|
||||
model = YOLO('yolov8n.pt')
|
||||
model = YOLO("yolov8n.pt")
|
||||
|
||||
# Train the model on the Open Images V7 dataset
|
||||
results = model.train(data='open-images-v7.yaml', epochs=100, imgsz=640)
|
||||
results = model.train(data="open-images-v7.yaml", epochs=100, imgsz=640)
|
||||
```
|
||||
|
||||
=== "CLI"
|
||||
|
|
|
|||
|
|
@ -46,39 +46,40 @@ Dataset benchmarking evaluates machine learning model performance on specific da
|
|||
=== "Python"
|
||||
|
||||
```python
|
||||
from pathlib import Path
|
||||
import shutil
|
||||
import os
|
||||
import shutil
|
||||
from pathlib import Path
|
||||
|
||||
from ultralytics.utils.benchmarks import RF100Benchmark
|
||||
|
||||
|
||||
# Initialize RF100Benchmark and set API key
|
||||
benchmark = RF100Benchmark()
|
||||
benchmark.set_key(api_key="YOUR_ROBOFLOW_API_KEY")
|
||||
|
||||
|
||||
# Parse dataset and define file paths
|
||||
names, cfg_yamls = benchmark.parse_dataset()
|
||||
val_log_file = Path("ultralytics-benchmarks") / "validation.txt"
|
||||
eval_log_file = Path("ultralytics-benchmarks") / "evaluation.txt"
|
||||
|
||||
|
||||
# Run benchmarks on each dataset in RF100
|
||||
for ind, path in enumerate(cfg_yamls):
|
||||
path = Path(path)
|
||||
if path.exists():
|
||||
# Fix YAML file and run training
|
||||
benchmark.fix_yaml(str(path))
|
||||
os.system(f'yolo detect train data={path} model=yolov8s.pt epochs=1 batch=16')
|
||||
|
||||
os.system(f"yolo detect train data={path} model=yolov8s.pt epochs=1 batch=16")
|
||||
|
||||
# Run validation and evaluate
|
||||
os.system(f'yolo detect val data={path} model=runs/detect/train/weights/best.pt > {val_log_file} 2>&1')
|
||||
os.system(f"yolo detect val data={path} model=runs/detect/train/weights/best.pt > {val_log_file} 2>&1")
|
||||
benchmark.evaluate(str(path), str(val_log_file), str(eval_log_file), ind)
|
||||
|
||||
|
||||
# Remove the 'runs' directory
|
||||
runs_dir = Path.cwd() / "runs"
|
||||
shutil.rmtree(runs_dir)
|
||||
else:
|
||||
print("YAML file path does not exist")
|
||||
continue
|
||||
|
||||
|
||||
print("RF100 Benchmarking completed!")
|
||||
```
|
||||
|
||||
|
|
|
|||
|
|
@ -50,10 +50,10 @@ To train a YOLOv8n model on the SKU-110K dataset for 100 epochs with an image si
|
|||
from ultralytics import YOLO
|
||||
|
||||
# Load a model
|
||||
model = YOLO('yolov8n.pt') # load a pretrained model (recommended for training)
|
||||
model = YOLO("yolov8n.pt") # load a pretrained model (recommended for training)
|
||||
|
||||
# Train the model
|
||||
results = model.train(data='SKU-110K.yaml', epochs=100, imgsz=640)
|
||||
results = model.train(data="SKU-110K.yaml", epochs=100, imgsz=640)
|
||||
```
|
||||
|
||||
=== "CLI"
|
||||
|
|
|
|||
|
|
@ -46,10 +46,10 @@ To train a YOLOv8n model on the VisDrone dataset for 100 epochs with an image si
|
|||
from ultralytics import YOLO
|
||||
|
||||
# Load a model
|
||||
model = YOLO('yolov8n.pt') # load a pretrained model (recommended for training)
|
||||
model = YOLO("yolov8n.pt") # load a pretrained model (recommended for training)
|
||||
|
||||
# Train the model
|
||||
results = model.train(data='VisDrone.yaml', epochs=100, imgsz=640)
|
||||
results = model.train(data="VisDrone.yaml", epochs=100, imgsz=640)
|
||||
```
|
||||
|
||||
=== "CLI"
|
||||
|
|
|
|||
|
|
@ -49,10 +49,10 @@ To train a YOLOv8n model on the VOC dataset for 100 epochs with an image size of
|
|||
from ultralytics import YOLO
|
||||
|
||||
# Load a model
|
||||
model = YOLO('yolov8n.pt') # load a pretrained model (recommended for training)
|
||||
model = YOLO("yolov8n.pt") # load a pretrained model (recommended for training)
|
||||
|
||||
# Train the model
|
||||
results = model.train(data='VOC.yaml', epochs=100, imgsz=640)
|
||||
results = model.train(data="VOC.yaml", epochs=100, imgsz=640)
|
||||
```
|
||||
|
||||
=== "CLI"
|
||||
|
|
|
|||
|
|
@ -52,10 +52,10 @@ To train a model on the xView dataset for 100 epochs with an image size of 640,
|
|||
from ultralytics import YOLO
|
||||
|
||||
# Load a model
|
||||
model = YOLO('yolov8n.pt') # load a pretrained model (recommended for training)
|
||||
model = YOLO("yolov8n.pt") # load a pretrained model (recommended for training)
|
||||
|
||||
# Train the model
|
||||
results = model.train(data='xView.yaml', epochs=100, imgsz=640)
|
||||
results = model.train(data="xView.yaml", epochs=100, imgsz=640)
|
||||
```
|
||||
|
||||
=== "CLI"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue