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
|
|
@ -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!")
|
||||
```
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue