Skip to content

Commit

Permalink
Update fraction arg to employ a random selection (ultralytics#8234)
Browse files Browse the repository at this point in the history
Co-authored-by: Glenn Jocher <glenn.jocher@ultralytics.com>
  • Loading branch information
2 people authored and hmurari committed Apr 17, 2024
1 parent 8dff0ca commit 22bfb48
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion ultralytics/data/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,9 @@ def get_img_files(self, img_path):
except Exception as e:
raise FileNotFoundError(f"{self.prefix}Error loading data from {img_path}\n{HELP_URL}") from e
if self.fraction < 1:
im_files = im_files[: round(len(im_files) * self.fraction)]
# im_files = im_files[: round(len(im_files) * self.fraction)]
num_elements_to_select = round(len(im_files) * self.fraction)
im_files = random.sample(im_files, num_elements_to_select)
return im_files

def update_labels(self, include_class: Optional[list]):
Expand Down

0 comments on commit 22bfb48

Please sign in to comment.