ultralytics 8.2.60__py3-none-any.whl → 8.2.62__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of ultralytics might be problematic. Click here for more details.

@@ -280,6 +280,8 @@ class YOLOMultiModalDataset(YOLODataset):
280
280
 
281
281
 
282
282
  class GroundingDataset(YOLODataset):
283
+ """Handles object detection tasks by loading annotations from a specified JSON file, supporting YOLO format."""
284
+
283
285
  def __init__(self, *args, task="detect", json_file, **kwargs):
284
286
  """Initializes a GroundingDataset for object detection, loading annotations from a specified JSON file."""
285
287
  assert task == "detect", "`GroundingDataset` only support `detect` task for now!"
@@ -21,6 +21,8 @@ from .utils import get_sim_index_schema, get_table_schema, plot_query_result, pr
21
21
 
22
22
 
23
23
  class ExplorerDataset(YOLODataset):
24
+ """Extends YOLODataset for advanced data exploration and manipulation in model training workflows."""
25
+
24
26
  def __init__(self, *args, data: dict = None, **kwargs) -> None:
25
27
  """Initializes the ExplorerDataset with the provided data arguments, extending the YOLODataset class."""
26
28
  super().__init__(*args, data=data, **kwargs)
@@ -54,6 +56,8 @@ class ExplorerDataset(YOLODataset):
54
56
 
55
57
 
56
58
  class Explorer:
59
+ """Utility class for image embedding, table creation, and similarity querying using LanceDB and YOLO models."""
60
+
57
61
  def __init__(
58
62
  self,
59
63
  data: Union[str, Path] = "coco128.yaml",
@@ -1,5 +1,6 @@
1
1
  # Ultralytics YOLO 🚀, AGPL-3.0 license
2
2
 
3
+ import sys
3
4
  import time
4
5
  from threading import Thread
5
6
 
@@ -17,7 +18,8 @@ def _get_explorer():
17
18
  """Initializes and returns an instance of the Explorer class."""
18
19
  exp = Explorer(data=st.session_state.get("dataset"), model=st.session_state.get("model"))
19
20
  thread = Thread(
20
- target=exp.create_embeddings_table, kwargs={"force": st.session_state.get("force_recreate_embeddings")}
21
+ target=exp.create_embeddings_table,
22
+ kwargs={"force": st.session_state.get("force_recreate_embeddings"), "split": st.session_state.get("split")},
21
23
  )
22
24
  thread.start()
23
25
  progress_bar = st.progress(0, text="Creating embeddings table...")
@@ -29,33 +31,45 @@ def _get_explorer():
29
31
  progress_bar.empty()
30
32
 
31
33
 
32
- def init_explorer_form():
34
+ def init_explorer_form(data=None, model=None):
33
35
  """Initializes an Explorer instance and creates embeddings table with progress tracking."""
34
- datasets = ROOT / "cfg" / "datasets"
35
- ds = [d.name for d in datasets.glob("*.yaml")]
36
- models = [
37
- "yolov8n.pt",
38
- "yolov8s.pt",
39
- "yolov8m.pt",
40
- "yolov8l.pt",
41
- "yolov8x.pt",
42
- "yolov8n-seg.pt",
43
- "yolov8s-seg.pt",
44
- "yolov8m-seg.pt",
45
- "yolov8l-seg.pt",
46
- "yolov8x-seg.pt",
47
- "yolov8n-pose.pt",
48
- "yolov8s-pose.pt",
49
- "yolov8m-pose.pt",
50
- "yolov8l-pose.pt",
51
- "yolov8x-pose.pt",
52
- ]
36
+ if data is None:
37
+ datasets = ROOT / "cfg" / "datasets"
38
+ ds = [d.name for d in datasets.glob("*.yaml")]
39
+ else:
40
+ ds = [data]
41
+
42
+ if model is None:
43
+ models = [
44
+ "yolov8n.pt",
45
+ "yolov8s.pt",
46
+ "yolov8m.pt",
47
+ "yolov8l.pt",
48
+ "yolov8x.pt",
49
+ "yolov8n-seg.pt",
50
+ "yolov8s-seg.pt",
51
+ "yolov8m-seg.pt",
52
+ "yolov8l-seg.pt",
53
+ "yolov8x-seg.pt",
54
+ "yolov8n-pose.pt",
55
+ "yolov8s-pose.pt",
56
+ "yolov8m-pose.pt",
57
+ "yolov8l-pose.pt",
58
+ "yolov8x-pose.pt",
59
+ ]
60
+ else:
61
+ models = [model]
62
+
63
+ splits = ["train", "val", "test"]
64
+
53
65
  with st.form(key="explorer_init_form"):
54
- col1, col2 = st.columns(2)
66
+ col1, col2, col3 = st.columns(3)
55
67
  with col1:
56
- st.selectbox("Select dataset", ds, key="dataset", index=ds.index("coco128.yaml"))
68
+ st.selectbox("Select dataset", ds, key="dataset")
57
69
  with col2:
58
70
  st.selectbox("Select model", models, key="model")
71
+ with col3:
72
+ st.selectbox("Select split", splits, key="split")
59
73
  st.checkbox("Force recreate embeddings", key="force_recreate_embeddings")
60
74
 
61
75
  st.form_submit_button("Explore", on_click=_get_explorer)
@@ -182,13 +196,13 @@ def utralytics_explorer_docs_callback():
182
196
  st.link_button("Ultrlaytics Explorer API", "https://docs.ultralytics.com/datasets/explorer/")
183
197
 
184
198
 
185
- def layout():
199
+ def layout(data=None, model=None):
186
200
  """Resets explorer session variables and provides documentation with a link to API docs."""
187
201
  st.set_page_config(layout="wide", initial_sidebar_state="collapsed")
188
202
  st.markdown("<h1 style='text-align: center;'>Ultralytics Explorer Demo</h1>", unsafe_allow_html=True)
189
203
 
190
204
  if st.session_state.get("explorer") is None:
191
- init_explorer_form()
205
+ init_explorer_form(data, model)
192
206
  return
193
207
 
194
208
  st.button(":arrow_backward: Select Dataset", on_click=reset_explorer)
@@ -264,4 +278,5 @@ def layout():
264
278
 
265
279
 
266
280
  if __name__ == "__main__":
267
- layout()
281
+ kwargs = dict(zip(sys.argv[1::2], sys.argv[2::2]))
282
+ layout(**kwargs)
@@ -545,7 +545,7 @@ def get_best_youtube_url(url, method="pytube"):
545
545
  """
546
546
  if method == "pytube":
547
547
  # Switched from pytube to pytubefix to resolve https://github.com/pytube/pytube/issues/1954
548
- check_requirements("pytubefix")
548
+ check_requirements("pytubefix==6.3.4") # bug in 6.4.2 https://github.com/JuanBindez/pytubefix/issues/123
549
549
  from pytubefix import YouTube
550
550
 
551
551
  streams = YouTube(url).streams.filter(file_extension="mp4", only_video=True)