ultralytics 8.0.181 RTDETR, MLFlow fixes and Examples updates (#4927)
Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: Jordane Sikati <jordanesikati@pusan.ac.kr> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Akash A Desai <62583018+akashAD98@users.noreply.github.com> Co-authored-by: Lukas Hennies <45569834+Gornoka@users.noreply.github.com> Co-authored-by: 唐洁 <tangjie1953479@tongji.edu.cn>
This commit is contained in:
parent
5702b2dccd
commit
742ec7fb1d
9 changed files with 46 additions and 26 deletions
|
|
@ -83,6 +83,7 @@ Without further ado, let's dive in!
|
|||
3. Now, read the contents of the dataset YAML file and extract the indices of the class labels.
|
||||
|
||||
```python
|
||||
yaml_file = 'path/to/data.yaml' # your data YAML with data directories and names dictionary
|
||||
with open(yaml_file, 'r', encoding="utf8") as y:
|
||||
classes = yaml.safe_load(y)['names']
|
||||
cls_idx = sorted(classes.keys())
|
||||
|
|
@ -177,10 +178,18 @@ The ideal scenario is for all class ratios to be reasonably similar for each spl
|
|||
4. Next, we create the directories and dataset YAML files for each split.
|
||||
|
||||
```python
|
||||
supported_extensions = ['.jpg', '.jpeg', '.png']
|
||||
|
||||
# Initialize an empty list to store image file paths
|
||||
images = []
|
||||
|
||||
# Loop through supported extensions and gather image files
|
||||
for ext in supported_extensions:
|
||||
images.extend(sorted((dataset_path / 'images').rglob(f"*{ext}")))
|
||||
|
||||
# Create the necessary directories and dataset YAML files (unchanged)
|
||||
save_path = Path(dataset_path / f'{datetime.date.today().isoformat()}_{ksplit}-Fold_Cross-val')
|
||||
save_path.mkdir(parents=True, exist_ok=True)
|
||||
|
||||
images = sorted((dataset_path / 'images').rglob("*.jpg")) # change file extension as needed
|
||||
ds_yamls = []
|
||||
|
||||
for split in folds_df.columns:
|
||||
|
|
@ -216,8 +225,7 @@ The ideal scenario is for all class ratios to be reasonably similar for each spl
|
|||
img_to_path = save_path / split / k_split / 'images'
|
||||
lbl_to_path = save_path / split / k_split / 'labels'
|
||||
|
||||
# Copy image and label files to new directory
|
||||
# Might throw a SamefileError if file already exists
|
||||
# Copy image and label files to new directory (SamefileError if file already exists)
|
||||
shutil.copy(image, img_to_path / image.name)
|
||||
shutil.copy(label, lbl_to_path / label.name)
|
||||
```
|
||||
|
|
@ -244,9 +252,15 @@ fold_lbl_distrb.to_csv(save_path / "kfold_label_distribution.csv")
|
|||
|
||||
```python
|
||||
results = {}
|
||||
|
||||
# Define your additional arguments here
|
||||
batch = 16
|
||||
project = 'kfold_demo'
|
||||
epochs = 100
|
||||
|
||||
for k in range(ksplit):
|
||||
dataset_yaml = ds_yamls[k]
|
||||
model.train(data=dataset_yaml, *args, **kwargs) # Include any training arguments
|
||||
model.train(data=dataset_yaml,epochs=epochs, batch=batch, project=project) # include any train arguments
|
||||
results[k] = model.metrics # save output metrics for further analysis
|
||||
```
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue