supervisely 6.73.238__py3-none-any.whl → 6.73.240__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.
Files changed (138) hide show
  1. supervisely/annotation/annotation.py +2 -2
  2. supervisely/api/entity_annotation/tag_api.py +11 -4
  3. supervisely/api/file_api.py +17 -3
  4. supervisely/nn/__init__.py +1 -0
  5. supervisely/nn/benchmark/__init__.py +14 -2
  6. supervisely/nn/benchmark/base_benchmark.py +84 -37
  7. supervisely/nn/benchmark/base_evaluator.py +120 -0
  8. supervisely/nn/benchmark/base_visualizer.py +265 -0
  9. supervisely/nn/benchmark/comparison/detection_visualization/text_templates.py +5 -5
  10. supervisely/nn/benchmark/comparison/detection_visualization/vis_metrics/calibration_score.py +2 -2
  11. supervisely/nn/benchmark/comparison/detection_visualization/vis_metrics/explore_predicttions.py +39 -16
  12. supervisely/nn/benchmark/comparison/detection_visualization/vis_metrics/localization_accuracy.py +1 -1
  13. supervisely/nn/benchmark/comparison/detection_visualization/vis_metrics/outcome_counts.py +4 -4
  14. supervisely/nn/benchmark/comparison/detection_visualization/vis_metrics/overview.py +12 -11
  15. supervisely/nn/benchmark/comparison/detection_visualization/vis_metrics/pr_curve.py +1 -1
  16. supervisely/nn/benchmark/comparison/detection_visualization/vis_metrics/precision_recal_f1.py +6 -6
  17. supervisely/nn/benchmark/comparison/detection_visualization/vis_metrics/speedtest.py +3 -3
  18. supervisely/nn/benchmark/{instance_segmentation_benchmark.py → instance_segmentation/benchmark.py} +9 -3
  19. supervisely/nn/benchmark/instance_segmentation/evaluator.py +58 -0
  20. supervisely/nn/benchmark/{visualization/text_templates/instance_segmentation_text.py → instance_segmentation/text_templates.py} +53 -69
  21. supervisely/nn/benchmark/instance_segmentation/visualizer.py +18 -0
  22. supervisely/nn/benchmark/object_detection/__init__.py +0 -0
  23. supervisely/nn/benchmark/object_detection/base_vis_metric.py +51 -0
  24. supervisely/nn/benchmark/{object_detection_benchmark.py → object_detection/benchmark.py} +4 -2
  25. supervisely/nn/benchmark/object_detection/evaluation_params.yaml +2 -0
  26. supervisely/nn/benchmark/{evaluation/object_detection_evaluator.py → object_detection/evaluator.py} +67 -9
  27. supervisely/nn/benchmark/{evaluation/coco → object_detection}/metric_provider.py +13 -14
  28. supervisely/nn/benchmark/{visualization/text_templates/object_detection_text.py → object_detection/text_templates.py} +49 -41
  29. supervisely/nn/benchmark/object_detection/vis_metrics/__init__.py +48 -0
  30. supervisely/nn/benchmark/{visualization → object_detection}/vis_metrics/confidence_distribution.py +20 -24
  31. supervisely/nn/benchmark/object_detection/vis_metrics/confidence_score.py +119 -0
  32. supervisely/nn/benchmark/{visualization → object_detection}/vis_metrics/confusion_matrix.py +34 -22
  33. supervisely/nn/benchmark/object_detection/vis_metrics/explore_predictions.py +129 -0
  34. supervisely/nn/benchmark/{visualization → object_detection}/vis_metrics/f1_score_at_different_iou.py +21 -26
  35. supervisely/nn/benchmark/object_detection/vis_metrics/frequently_confused.py +137 -0
  36. supervisely/nn/benchmark/object_detection/vis_metrics/iou_distribution.py +106 -0
  37. supervisely/nn/benchmark/object_detection/vis_metrics/key_metrics.py +136 -0
  38. supervisely/nn/benchmark/{visualization → object_detection}/vis_metrics/model_predictions.py +53 -49
  39. supervisely/nn/benchmark/object_detection/vis_metrics/outcome_counts.py +188 -0
  40. supervisely/nn/benchmark/object_detection/vis_metrics/outcome_counts_per_class.py +191 -0
  41. supervisely/nn/benchmark/object_detection/vis_metrics/overview.py +116 -0
  42. supervisely/nn/benchmark/object_detection/vis_metrics/pr_curve.py +106 -0
  43. supervisely/nn/benchmark/object_detection/vis_metrics/pr_curve_by_class.py +49 -0
  44. supervisely/nn/benchmark/object_detection/vis_metrics/precision.py +72 -0
  45. supervisely/nn/benchmark/object_detection/vis_metrics/precision_avg_per_class.py +59 -0
  46. supervisely/nn/benchmark/object_detection/vis_metrics/recall.py +71 -0
  47. supervisely/nn/benchmark/object_detection/vis_metrics/recall_vs_precision.py +56 -0
  48. supervisely/nn/benchmark/object_detection/vis_metrics/reliability_diagram.py +110 -0
  49. supervisely/nn/benchmark/object_detection/vis_metrics/speedtest.py +151 -0
  50. supervisely/nn/benchmark/object_detection/visualizer.py +697 -0
  51. supervisely/nn/benchmark/semantic_segmentation/__init__.py +9 -0
  52. supervisely/nn/benchmark/semantic_segmentation/base_vis_metric.py +55 -0
  53. supervisely/nn/benchmark/semantic_segmentation/benchmark.py +32 -0
  54. supervisely/nn/benchmark/semantic_segmentation/evaluation_params.yaml +0 -0
  55. supervisely/nn/benchmark/semantic_segmentation/evaluator.py +162 -0
  56. supervisely/nn/benchmark/semantic_segmentation/metric_provider.py +153 -0
  57. supervisely/nn/benchmark/semantic_segmentation/text_templates.py +130 -0
  58. supervisely/nn/benchmark/semantic_segmentation/vis_metrics/__init__.py +0 -0
  59. supervisely/nn/benchmark/semantic_segmentation/vis_metrics/acknowledgement.py +15 -0
  60. supervisely/nn/benchmark/semantic_segmentation/vis_metrics/classwise_error_analysis.py +57 -0
  61. supervisely/nn/benchmark/semantic_segmentation/vis_metrics/confusion_matrix.py +92 -0
  62. supervisely/nn/benchmark/semantic_segmentation/vis_metrics/explore_predictions.py +84 -0
  63. supervisely/nn/benchmark/semantic_segmentation/vis_metrics/frequently_confused.py +101 -0
  64. supervisely/nn/benchmark/semantic_segmentation/vis_metrics/iou_eou.py +45 -0
  65. supervisely/nn/benchmark/semantic_segmentation/vis_metrics/key_metrics.py +60 -0
  66. supervisely/nn/benchmark/semantic_segmentation/vis_metrics/model_predictions.py +107 -0
  67. supervisely/nn/benchmark/semantic_segmentation/vis_metrics/overview.py +112 -0
  68. supervisely/nn/benchmark/semantic_segmentation/vis_metrics/renormalized_error_ou.py +48 -0
  69. supervisely/nn/benchmark/semantic_segmentation/vis_metrics/speedtest.py +178 -0
  70. supervisely/nn/benchmark/semantic_segmentation/vis_metrics/vis_texts.py +21 -0
  71. supervisely/nn/benchmark/semantic_segmentation/visualizer.py +304 -0
  72. supervisely/nn/benchmark/utils/__init__.py +12 -0
  73. supervisely/nn/benchmark/utils/detection/__init__.py +2 -0
  74. supervisely/nn/benchmark/{evaluation/coco → utils/detection}/calculate_metrics.py +6 -4
  75. supervisely/nn/benchmark/utils/detection/metric_provider.py +533 -0
  76. supervisely/nn/benchmark/{coco_utils → utils/detection}/sly2coco.py +4 -4
  77. supervisely/nn/benchmark/{coco_utils/utils.py → utils/detection/utlis.py} +11 -0
  78. supervisely/nn/benchmark/utils/semantic_segmentation/__init__.py +0 -0
  79. supervisely/nn/benchmark/utils/semantic_segmentation/calculate_metrics.py +35 -0
  80. supervisely/nn/benchmark/utils/semantic_segmentation/evaluator.py +804 -0
  81. supervisely/nn/benchmark/utils/semantic_segmentation/loader.py +65 -0
  82. supervisely/nn/benchmark/utils/semantic_segmentation/utils.py +109 -0
  83. supervisely/nn/benchmark/visualization/evaluation_result.py +17 -3
  84. supervisely/nn/benchmark/visualization/vis_click_data.py +1 -1
  85. supervisely/nn/benchmark/visualization/widgets/__init__.py +3 -0
  86. supervisely/nn/benchmark/visualization/widgets/chart/chart.py +12 -4
  87. supervisely/nn/benchmark/visualization/widgets/gallery/gallery.py +35 -8
  88. supervisely/nn/benchmark/visualization/widgets/gallery/template.html +8 -4
  89. supervisely/nn/benchmark/visualization/widgets/markdown/markdown.py +1 -1
  90. supervisely/nn/benchmark/visualization/widgets/notification/notification.py +11 -7
  91. supervisely/nn/benchmark/visualization/widgets/radio_group/__init__.py +0 -0
  92. supervisely/nn/benchmark/visualization/widgets/radio_group/radio_group.py +34 -0
  93. supervisely/nn/benchmark/visualization/widgets/table/table.py +9 -3
  94. supervisely/nn/benchmark/visualization/widgets/widget.py +4 -0
  95. supervisely/project/project.py +18 -6
  96. {supervisely-6.73.238.dist-info → supervisely-6.73.240.dist-info}/METADATA +3 -1
  97. {supervisely-6.73.238.dist-info → supervisely-6.73.240.dist-info}/RECORD +104 -82
  98. supervisely/nn/benchmark/coco_utils/__init__.py +0 -2
  99. supervisely/nn/benchmark/evaluation/__init__.py +0 -3
  100. supervisely/nn/benchmark/evaluation/base_evaluator.py +0 -64
  101. supervisely/nn/benchmark/evaluation/coco/__init__.py +0 -2
  102. supervisely/nn/benchmark/evaluation/instance_segmentation_evaluator.py +0 -88
  103. supervisely/nn/benchmark/utils.py +0 -13
  104. supervisely/nn/benchmark/visualization/inference_speed/__init__.py +0 -19
  105. supervisely/nn/benchmark/visualization/inference_speed/speedtest_batch.py +0 -161
  106. supervisely/nn/benchmark/visualization/inference_speed/speedtest_intro.py +0 -28
  107. supervisely/nn/benchmark/visualization/inference_speed/speedtest_overview.py +0 -141
  108. supervisely/nn/benchmark/visualization/inference_speed/speedtest_real_time.py +0 -63
  109. supervisely/nn/benchmark/visualization/text_templates/inference_speed_text.py +0 -23
  110. supervisely/nn/benchmark/visualization/vis_metric_base.py +0 -337
  111. supervisely/nn/benchmark/visualization/vis_metrics/__init__.py +0 -67
  112. supervisely/nn/benchmark/visualization/vis_metrics/classwise_error_analysis.py +0 -55
  113. supervisely/nn/benchmark/visualization/vis_metrics/confidence_score.py +0 -93
  114. supervisely/nn/benchmark/visualization/vis_metrics/explorer_grid.py +0 -144
  115. supervisely/nn/benchmark/visualization/vis_metrics/frequently_confused.py +0 -115
  116. supervisely/nn/benchmark/visualization/vis_metrics/iou_distribution.py +0 -86
  117. supervisely/nn/benchmark/visualization/vis_metrics/outcome_counts.py +0 -119
  118. supervisely/nn/benchmark/visualization/vis_metrics/outcome_counts_per_class.py +0 -148
  119. supervisely/nn/benchmark/visualization/vis_metrics/overall_error_analysis.py +0 -109
  120. supervisely/nn/benchmark/visualization/vis_metrics/overview.py +0 -189
  121. supervisely/nn/benchmark/visualization/vis_metrics/percision_avg_per_class.py +0 -57
  122. supervisely/nn/benchmark/visualization/vis_metrics/pr_curve.py +0 -101
  123. supervisely/nn/benchmark/visualization/vis_metrics/pr_curve_by_class.py +0 -46
  124. supervisely/nn/benchmark/visualization/vis_metrics/precision.py +0 -56
  125. supervisely/nn/benchmark/visualization/vis_metrics/recall.py +0 -54
  126. supervisely/nn/benchmark/visualization/vis_metrics/recall_vs_precision.py +0 -57
  127. supervisely/nn/benchmark/visualization/vis_metrics/reliability_diagram.py +0 -88
  128. supervisely/nn/benchmark/visualization/vis_metrics/what_is.py +0 -23
  129. supervisely/nn/benchmark/visualization/vis_templates.py +0 -241
  130. supervisely/nn/benchmark/visualization/vis_widgets.py +0 -128
  131. supervisely/nn/benchmark/visualization/visualizer.py +0 -729
  132. /supervisely/nn/benchmark/{visualization/text_templates → instance_segmentation}/__init__.py +0 -0
  133. /supervisely/nn/benchmark/{evaluation/coco → instance_segmentation}/evaluation_params.yaml +0 -0
  134. /supervisely/nn/benchmark/{evaluation/coco → utils/detection}/metrics.py +0 -0
  135. {supervisely-6.73.238.dist-info → supervisely-6.73.240.dist-info}/LICENSE +0 -0
  136. {supervisely-6.73.238.dist-info → supervisely-6.73.240.dist-info}/WHEEL +0 -0
  137. {supervisely-6.73.238.dist-info → supervisely-6.73.240.dist-info}/entry_points.txt +0 -0
  138. {supervisely-6.73.238.dist-info → supervisely-6.73.240.dist-info}/top_level.txt +0 -0
@@ -1,56 +0,0 @@
1
- from __future__ import annotations
2
-
3
- from typing import TYPE_CHECKING
4
-
5
- from supervisely.nn.benchmark.visualization.vis_metric_base import MetricVis
6
- from supervisely.nn.benchmark.visualization.vis_widgets import Schema, Widget
7
-
8
- if TYPE_CHECKING:
9
- from supervisely.nn.benchmark.visualization.visualizer import Visualizer
10
-
11
-
12
- class Precision(MetricVis):
13
-
14
- def __init__(self, loader: Visualizer) -> None:
15
- super().__init__(loader)
16
- self.clickable = True
17
- self.schema = Schema(
18
- self._loader.vis_texts,
19
- markdown_P=Widget.Markdown(title="Precision", is_header=True),
20
- notification_precision=Widget.Notification(
21
- formats_title=[self._loader.base_metrics()["precision"].round(2)],
22
- formats_desc=[
23
- self._loader.mp.TP_count,
24
- (self._loader.mp.TP_count + self._loader.mp.FP_count),
25
- ],
26
- ),
27
- markdown_P_perclass=Widget.Markdown(
28
- formats=[self._loader.vis_texts.definitions.f1_score]
29
- ),
30
- chart=Widget.Chart(),
31
- )
32
-
33
- def get_figure(self, widget: Widget): # -> Optional[go.Figure]
34
- import plotly.express as px # pylint: disable=import-error
35
-
36
- # Per-class Precision bar chart
37
- # per_class_metrics_df_sorted = per_class_metrics_df.sort_values(by="precision")
38
- sorted_by_precision = self._loader.mp.per_class_metrics().sort_values(by="precision")
39
- fig = px.bar(
40
- sorted_by_precision,
41
- x="category",
42
- y="precision",
43
- # title="Per-class Precision (Sorted by F1)",
44
- color="precision",
45
- range_color=[0, 1],
46
- color_continuous_scale="Plasma",
47
- )
48
- fig.update_traces(hovertemplate="Class: %{x}<br>Precision: %{y:.2f}<extra></extra>")
49
- if len(sorted_by_precision) <= 20:
50
- fig.update_traces(
51
- text=sorted_by_precision.round(2),
52
- textposition="outside",
53
- )
54
- fig.update_xaxes(title_text="Class")
55
- fig.update_yaxes(title_text="Precision", range=[0, 1])
56
- return fig
@@ -1,54 +0,0 @@
1
- from __future__ import annotations
2
-
3
- from typing import TYPE_CHECKING
4
-
5
- from supervisely.nn.benchmark.visualization.vis_metric_base import MetricVis
6
- from supervisely.nn.benchmark.visualization.vis_widgets import Schema, Widget
7
-
8
- if TYPE_CHECKING:
9
- from supervisely.nn.benchmark.visualization.visualizer import Visualizer
10
-
11
-
12
- class Recall(MetricVis):
13
-
14
- def __init__(self, loader: Visualizer) -> None:
15
- super().__init__(loader)
16
- tp_plus_fn = self._loader.mp.TP_count + self._loader.mp.FN_count
17
- self.clickable = True
18
- self.schema = Schema(
19
- self._loader.vis_texts,
20
- markdown_R=Widget.Markdown(title="Recall", is_header=True),
21
- notification_recall=Widget.Notification(
22
- formats_title=[self._loader.base_metrics()["recall"].round(2)],
23
- formats_desc=[self._loader.mp.TP_count, tp_plus_fn],
24
- ),
25
- markdown_R_perclass=Widget.Markdown(
26
- formats=[self._loader.vis_texts.definitions.f1_score]
27
- ),
28
- chart=Widget.Chart(),
29
- )
30
-
31
- def get_figure(self, widget: Widget.Chart): # -> Optional[go.Figure]
32
- import plotly.express as px # pylint: disable=import-error
33
-
34
- # Per-class Precision bar chart
35
- # per_class_metrics_df_sorted = per_class_metrics_df.sort_values(by="recall")
36
- sorted_by_f1 = self._loader.mp.per_class_metrics().sort_values(by="f1")
37
- fig = px.bar(
38
- sorted_by_f1,
39
- x="category",
40
- y="recall",
41
- # title="Per-class Recall (Sorted by F1)",
42
- color="recall",
43
- range_color=[0, 1],
44
- color_continuous_scale="Plasma",
45
- )
46
- fig.update_traces(hovertemplate="Class: %{x}<br>Recall: %{y:.2f}<extra></extra>")
47
- if len(sorted_by_f1) <= 20:
48
- fig.update_traces(
49
- text=sorted_by_f1["recall"].round(2),
50
- textposition="outside",
51
- )
52
- fig.update_xaxes(title_text="Class")
53
- fig.update_yaxes(title_text="Recall", range=[0, 1])
54
- return fig
@@ -1,57 +0,0 @@
1
- from __future__ import annotations
2
-
3
- from typing import TYPE_CHECKING
4
-
5
- from supervisely.nn.benchmark.visualization.vis_metric_base import MetricVis
6
- from supervisely.nn.benchmark.visualization.vis_widgets import Schema, Widget
7
-
8
- if TYPE_CHECKING:
9
- from supervisely.nn.benchmark.visualization.visualizer import Visualizer
10
-
11
-
12
- class RecallVsPrecision(MetricVis):
13
-
14
- def __init__(self, loader: Visualizer) -> None:
15
- super().__init__(loader)
16
- self.clickable = True
17
- self.schema = Schema(
18
- self._loader.vis_texts,
19
- markdown_PR=Widget.Markdown(
20
- title="Recall vs Precision",
21
- is_header=True,
22
- formats=[self._loader.vis_texts.definitions.f1_score],
23
- ),
24
- chart=Widget.Chart(),
25
- )
26
-
27
- def get_figure(self, widget: Widget.Chart): # -> Optional[go.Figure]
28
- import plotly.graph_objects as go # pylint: disable=import-error
29
-
30
- blue_color = "#1f77b4"
31
- orange_color = "#ff7f0e"
32
- sorted_by_f1 = self._loader.mp.per_class_metrics().sort_values(by="f1")
33
- fig = go.Figure()
34
- fig.add_trace(
35
- go.Bar(
36
- y=sorted_by_f1["precision"],
37
- x=sorted_by_f1["category"],
38
- name="Precision",
39
- marker=dict(color=blue_color),
40
- )
41
- )
42
- fig.add_trace(
43
- go.Bar(
44
- y=sorted_by_f1["recall"],
45
- x=sorted_by_f1["category"],
46
- name="Recall",
47
- marker=dict(color=orange_color),
48
- )
49
- )
50
- fig.update_layout(
51
- barmode="group",
52
- # title="Per-class Precision and Recall (Sorted by F1)",
53
- )
54
- fig.update_xaxes(title_text="Class")
55
- fig.update_yaxes(title_text="Value", range=[0, 1])
56
- # fig.show()
57
- return fig
@@ -1,88 +0,0 @@
1
- from __future__ import annotations
2
-
3
- from typing import TYPE_CHECKING
4
-
5
- from supervisely.nn.benchmark.visualization.vis_metric_base import MetricVis
6
- from supervisely.nn.benchmark.visualization.vis_widgets import Schema, Widget
7
-
8
- if TYPE_CHECKING:
9
- from supervisely.nn.benchmark.visualization.visualizer import Visualizer
10
-
11
-
12
- class ReliabilityDiagram(MetricVis):
13
-
14
- def __init__(self, loader: Visualizer) -> None:
15
- super().__init__(loader)
16
- self.schema = Schema(
17
- self._loader.vis_texts,
18
- markdown_calibration_score_1=Widget.Markdown(
19
- title="Calibration Score",
20
- is_header=True,
21
- formats=[self._loader.vis_texts.definitions.confidence_score],
22
- ),
23
- collapse_what_is=Widget.Collapse(
24
- Schema(
25
- self._loader.vis_texts,
26
- markdown_what_is_calibration=Widget.Markdown(title="What is calibration?"),
27
- )
28
- ),
29
- markdown_calibration_score_2=Widget.Markdown(),
30
- markdown_reliability_diagram=Widget.Markdown(
31
- title="Reliability Diagram", is_header=True
32
- ),
33
- notification_ece=Widget.Notification(
34
- formats_title=[self._loader.mp.m_full.expected_calibration_error().round(4)]
35
- ),
36
- chart=Widget.Chart(),
37
- collapse_ece=Widget.Collapse(
38
- Schema(
39
- self._loader.vis_texts,
40
- markdown_calibration_curve_interpretation=Widget.Markdown(
41
- title="How to interpret the Calibration curve"
42
- ),
43
- )
44
- ),
45
- )
46
-
47
- def get_figure(self, widget: Widget): # -> Optional[go.Figure]:
48
- import plotly.graph_objects as go # pylint: disable=import-error
49
-
50
- # Calibration curve (only positive predictions)
51
- true_probs, pred_probs = self._loader.mp.m_full.calibration_curve()
52
-
53
- fig = go.Figure()
54
- fig.add_trace(
55
- go.Scatter(
56
- x=pred_probs,
57
- y=true_probs,
58
- mode="lines+markers",
59
- name="Calibration plot (Model)",
60
- line=dict(color="blue"),
61
- marker=dict(color="blue"),
62
- )
63
- )
64
- fig.add_trace(
65
- go.Scatter(
66
- x=[0, 1],
67
- y=[0, 1],
68
- mode="lines",
69
- name="Perfectly calibrated",
70
- line=dict(color="orange", dash="dash"),
71
- )
72
- )
73
-
74
- fig.update_layout(
75
- # title="Calibration Curve (only positive predictions)",
76
- xaxis_title="Confidence Score",
77
- yaxis_title="Fraction of True Positives",
78
- legend=dict(x=0.6, y=0.1),
79
- xaxis=dict(range=[0, 1]),
80
- yaxis=dict(range=[0, 1]),
81
- width=700,
82
- height=500,
83
- )
84
- fig.update_traces(
85
- hovertemplate="Confidence Score: %{x:.2f}<br>Fraction of True Positives: %{y:.2f}<extra></extra>"
86
- )
87
- # fig.show()
88
- return fig
@@ -1,23 +0,0 @@
1
- from __future__ import annotations
2
-
3
- from typing import TYPE_CHECKING
4
-
5
- from supervisely.nn.benchmark.visualization.vis_metric_base import MetricVis
6
- from supervisely.nn.benchmark.visualization.vis_widgets import Schema, Widget
7
-
8
- if TYPE_CHECKING:
9
- from supervisely.nn.benchmark.visualization.visualizer import Visualizer
10
-
11
-
12
- class WhatIs(MetricVis):
13
-
14
- def __init__(self, loader: Visualizer) -> None:
15
- super().__init__(loader)
16
- self.schema = Schema(
17
- self._loader.vis_texts,
18
- markdown_what_is=Widget.Markdown(title="What is YOLOv8 model", is_header=True),
19
- markdown_experts=Widget.Markdown(title="Expert Insights", is_header=True),
20
- markdown_how_to_use=Widget.Markdown(
21
- title="How To Use: Training, Inference, Evaluation Loop", is_header=True
22
- ),
23
- )
@@ -1,241 +0,0 @@
1
- from typing import List
2
-
3
-
4
- def generate_main_template(metric_visualizations: List):
5
- template_str = """<div class="model-benchmark-body">
6
-
7
- <sly-style>
8
- .model-benchmark-body .sly-markdown-widget .markdown-body { padding: 0; font-family: inherit; }
9
- .model-benchmark-body .sly-markdown-widget .markdown-body h2 { font-size: 18px; font-weight: 600; margin-bottom: 0px; border: 0; }
10
- .model-benchmark-body .sly-markdown-widget .markdown-body h3 { color: #949bab; font-size: 18px; margin-bottom: 7px; }
11
- .model-benchmark-body .sly-markdown-widget .markdown-body p { margin-bottom: 12px; }
12
- .model-benchmark-body .el-collapse { margin: 15px 0; box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1); border-radius: 7px; width: fit-content; }
13
- .model-benchmark-body .el-collapse .el-collapse-item__header { background: transparent; padding-right: 15px; }
14
- .model-benchmark-body .model-info-block { display: flex; gap: 10px; align-items: center; margin: 0 0 15px; color: #778592; font-size: 13px; }
15
- .model-benchmark-body .model-info-block > div { display: flex; gap: 4px; align-items: center; }
16
- /* , .model-benchmark-body .sly-markdown-widget .markdown-body>*:last-child */
17
- .model-benchmark-body .sly-iw-notification-box .notification-box.notification-box-info { width: fit-content; }
18
- .model-benchmark-body h1 { font-size: 20px; font-weight: bold; margin-bottom: 5px; }
19
- .model-benchmark-body .overview-info-block { background: #f4f7fb; width: fit-content; border-radius: 12px; padding: 16px; margin-bottom: 20px; }
20
- .model-benchmark-body .overview-info-block ul { list-style: none; padding: 0; }
21
- .model-benchmark-body .overview-info-block ul p { padding: 0; }
22
- .model-benchmark-body .sly-sidebar-widget .main-wrapper .sidebar-panel { top: 10px; }
23
-
24
- </sly-style>
25
-
26
- <sly-iw-sidebar
27
- :options="{ height: 'calc(100vh - 130px)', clearMainPanelPaddings: true, leftSided: false, disableResize: true, sidebarWidth: 300 }"
28
- >
29
- <div slot="sidebar">"""
30
-
31
- for vis in metric_visualizations:
32
- template_str += vis.template_sidebar_str
33
-
34
- template_str += """\n </div>
35
-
36
- <div style="padding-right: 35px;">"""
37
-
38
- for vis in metric_visualizations:
39
- template_str += """\n <div style="margin-top: 20px;">"""
40
- template_str += vis.template_main_str
41
- template_str += """\n </div>"""
42
-
43
- template_str += "\n </div>\n </sly-iw-sidebar>"
44
-
45
- template_str += """\n
46
- <sly-iw-gallery
47
- ref='modal_general'
48
- iw-widget-id='modal_general'
49
- :options="{'isModalWindow': true}"
50
- :actions="{
51
- 'init': {
52
- 'dataSource': '/data/modal_general.json',
53
- },
54
- }"
55
- :command="command"
56
- :data="data"
57
- /> \n
58
- <sly-iw-gallery
59
- ref='modal_general_diff'
60
- iw-widget-id='modal_general_diff'
61
- :options="{'isModalWindow': true}"
62
- :actions="{
63
- 'init': {
64
- 'dataSource': '/data/modal_general_diff.json',
65
- },
66
- 'chart-click': {
67
- 'dataSource': '/data/gallery_explorer_grid_diff_data.json',
68
- 'galleryId': 'modal_general',
69
- 'limit': 3,
70
- },
71
- }"
72
- :command="command"
73
- :data="data"
74
- > \n
75
- <span slot="image-left-header">
76
- <i class="zmdi zmdi-collection-image"></i> Compare with GT
77
- </span>
78
- </sly-iw-gallery>
79
- </div>"""
80
-
81
- return template_str
82
-
83
-
84
- template_markdown_str = """
85
- <div style="margin-top: 10px;">
86
- <sly-iw-markdown
87
- id="{{ widget_id }}"
88
- class="markdown-no-border {{ 'overview-info-block' if is_overview else '' }}"
89
- iw-widget-id="{{ widget_id }}"
90
- :actions="{
91
- 'init': {
92
- 'dataSource': '{{ data_source }}',
93
- },
94
- }"
95
- :command="{{ command }}"
96
- :data="{{ data }}"
97
- />
98
- </div>
99
- """
100
-
101
- template_chart_str = """
102
- <div style="margin-top: 20px; margin-bottom: 20px;">
103
- <sly-iw-chart
104
- iw-widget-id="{{ widget_id }}"{% if switchable %}
105
- v-show="state.{{ radio_group }} === '{{ switch_key }}'"
106
- {% endif %}:actions="{
107
- 'init': {
108
- 'dataSource': '{{ init_data_source }}',
109
- },{% if chart_click_data_source %}
110
- 'chart-click': {
111
- 'dataSource': '{{ chart_click_data_source }}',{% if cls_name in ['outcome_counts'] %}
112
- 'getKey': (payload) => payload.points[0].data.name,{% endif %}{% if cls_name in ['frequently_confused', 'recall', 'precision', 'recall_vs_precision'] %}
113
- 'getKey': (payload) => payload.points[0].label,{% endif %}{% if cls_name in ['pr_curve_by_class'] %}
114
- 'getKey': (payload) => payload.points[0].data.legendgroup,{% endif %}{% if cls_name in ['per_class_avg_precision'] %}
115
- 'getKey': (payload) => payload.points[0].theta,{% endif %}{% if cls_name in ['per_class_outcome_counts'] %}
116
- 'getKey': (payload) => `${payload.points[0].label}${'-'}${payload.points[0].data.name}`,{% endif %}{% if cls_name in ['confusion_matrix', 'per_class_outcome_counts'] %}
117
- 'keySeparator': '{{ key_separator }}',{% endif %}
118
- 'galleryId': 'modal_general',
119
- 'limit': 9
120
- },{% endif %}
121
- }"
122
- :command="{{ command }}"
123
- :data="{{ data }}"
124
- />
125
- </div>
126
-
127
-
128
- """
129
-
130
- template_radiogroup_str = """<el-radio v-model="state.{{ radio_group }}" label="{{ switch_key }}" style="margin-top: 10px;">{{ switch_key }}</el-radio>"""
131
-
132
-
133
- template_gallery_str = """<sly-iw-gallery
134
- iw-widget-id="{{ widget_id }}"
135
- {% if is_table_gallery %}
136
- ref='{{ widget_id }}'
137
- {% endif %}
138
- :actions="{
139
- 'init': {
140
- 'dataSource': '{{ init_data_source }}',
141
- },
142
- {% if gallery_diff_data_source %}
143
- 'chart-click': {
144
- 'dataSource': '{{ gallery_diff_data_source }}',
145
- 'getKey':(payload)=>payload['annotation']['image_id'],
146
- 'galleryId': 'modal_general',
147
- 'limit': 3,
148
- },
149
- {% endif %}
150
- }"
151
- :command="{{ command }}"
152
- :data="{{ data }}"
153
- >
154
- {% if gallery_diff_data_source %}
155
- <span slot="image-left-header">
156
- <i class="zmdi zmdi-collection-image"></i> Compare with GT
157
- </span>
158
- {% endif %}
159
- </sly-iw-gallery>
160
-
161
- {% if gallery_click_data_source %}
162
- <div style="display: flex; justify-content: center; margin-top:10px;" >
163
- <el-button iw-widget-id="btn-1" type="primary" @click="command({
164
- method: 'update-gallery',
165
- payload: {
166
- data: {
167
- 'key': 'explore',
168
- 'limit': 9,
169
- 'dataSource': '{{ gallery_click_data_source }}',
170
- },
171
- 'galleryId': 'modal_general_diff',
172
- },
173
- internalCommand: true
174
- })">Explore all predictions</el-button>
175
- </div> {% endif %}
176
- """
177
-
178
-
179
- template_table_str = """
180
- <div style="margin-top: 20px; margin-bottom: 30px; {{ width }}">
181
- <sly-iw-table
182
- iw-widget-id="{{ widget_id }}"
183
- {% if clickable %}
184
- style="cursor: pointer;"
185
- {% endif %}
186
- :options="{
187
- isRowClickable: '{{ clickable }}' === 'True',
188
- fixColumns: {{ fixColumns }},
189
- showHeaderControls: '{{ showHeaderControls }}' === 'True',
190
- }"
191
- :actions="{
192
- 'init': {
193
- 'dataSource': '{{ init_data_source }}',
194
- },
195
- {% if clickable %}
196
- 'chart-click': {
197
- 'dataSource': '{{ table_click_data }}',
198
- 'galleryId': '{{ table_gallery_id }}',
199
- 'getKey':(payload)=>payload.row[0],
200
- },
201
- {% endif %}
202
- }"
203
- :command="{{ command }}"
204
- :data="{{ data }}"
205
- >
206
- <span
207
- slot="custom-cell-content"
208
- slot-scope="{ row, column, cellValue }"
209
- >
210
- <div
211
- v-if="column === ' ' && '{{ mainColumn }}' === 'Batch size'"
212
- class="fflex"
213
- >
214
- <b>Batch size {{ '{{ cellValue }}' }}</b>
215
- </div>
216
- <div
217
- v-if="column === '{{ mainColumn }}'"
218
- class="fflex"
219
- >
220
- <b>{{ '{{ cellValue }}' }}</b>
221
- </div>
222
- </span>
223
- </sly-iw-table>
224
- </div>
225
- """
226
-
227
- template_notification_str = """
228
- <div style="margin-top: 20px; margin-bottom: 20px;">
229
- <sly-iw-notification
230
- iw-widget-id="{{ widget_id }}"
231
- :data="{{ data }}"
232
- >
233
- <span slot="title">
234
- {{ title }}
235
- </span>
236
-
237
- <span slot="description">
238
- {{ description }}
239
- </span>
240
- </sly-iw-notification>
241
- </div>"""
@@ -1,128 +0,0 @@
1
- from __future__ import annotations
2
-
3
- from typing import Iterator, List, Optional
4
-
5
- from jinja2 import Template
6
-
7
- from supervisely._utils import camel_to_snake, rand_str
8
-
9
-
10
- class Schema:
11
-
12
- def __init__(self, vis_texts, **kw_widgets: Widget) -> None:
13
- for argname, widget in kw_widgets.items():
14
- widget.name = argname
15
- if isinstance(widget, Widget.Notification):
16
- widget.title = getattr(vis_texts, argname)["title"]
17
- widget.description = getattr(vis_texts, argname)["description"]
18
- setattr(self, argname, widget)
19
-
20
- def __iter__(self) -> Iterator:
21
- for attr in vars(self).values():
22
- yield attr
23
-
24
- def __getitem__(self, key) -> Widget:
25
- return getattr(self, key)
26
-
27
- def __repr__(self):
28
- elements = ", ".join(f"{attr.name} ({attr.type})" for attr in self)
29
- return f"Schema({elements})"
30
-
31
-
32
- class BaseWidget:
33
- def __init__(self) -> None:
34
- self.type = camel_to_snake(self.__class__.__name__)
35
- self.id = f"{self.type}_{rand_str(5)}"
36
- self.name = None
37
-
38
-
39
- class Widget:
40
-
41
- class Collapse(BaseWidget):
42
-
43
- def __init__(self, schema: Schema) -> None:
44
- super().__init__()
45
- self.schema = schema
46
- res = "<el-collapse class='mb-6'>"
47
- for subwidget in schema:
48
- res += f"""\n <el-collapse-item title="{subwidget.title}">"""
49
- res += "\n {{ " + f"{subwidget.name}_html" + " }}"
50
- res += "\n </el-collapse-item>"
51
- res += "\n </el-collapse>"
52
- self.template_schema = Template(res)
53
-
54
- class Markdown(BaseWidget):
55
-
56
- def __init__(
57
- self, title: Optional[str] = None, is_header: bool = False, formats: list = []
58
- ) -> None:
59
- self.title = title
60
- self.is_header = is_header
61
- self.formats = formats
62
- super().__init__()
63
-
64
- class Notification(BaseWidget):
65
-
66
- def __init__(self, formats_title: list = [], formats_desc: list = []) -> None:
67
- self.title: str = None
68
- self.description: str = None
69
- self.formats_title: list = formats_title
70
- self.formats_desc: list = formats_desc
71
- super().__init__()
72
-
73
- class Chart(BaseWidget):
74
-
75
- def __init__(
76
- self, switch_key: Optional[str] = None, filters: Optional[List] = None
77
- ) -> None:
78
- self.switch_key = switch_key
79
- filters = filters or [{"confidence": [0.6, 1]}, {"outcome": "TP"}]
80
-
81
- from supervisely.app.widgets.grid_gallery_v2.grid_gallery_v2 import (
82
- GridGalleryV2,
83
- )
84
-
85
- self.gallery = GridGalleryV2(
86
- columns_number=3,
87
- annotations_opacity=0.4,
88
- border_width=4,
89
- enable_zoom=False,
90
- default_tag_filters=filters,
91
- show_zoom_slider=False,
92
- )
93
-
94
- super().__init__()
95
-
96
- class Table(BaseWidget):
97
-
98
- def __init__(self) -> None:
99
- from supervisely.app.widgets.fast_table.fast_table import FastTable
100
-
101
- self.table = FastTable
102
- self.gallery_id = None
103
- self.main_column = ""
104
- self.fixed_columns = 0
105
- self.show_header_controls = True
106
- self.width = None
107
- super().__init__()
108
-
109
- class Gallery(BaseWidget):
110
-
111
- def __init__(self, is_table_gallery: bool = False, filters: Optional[List] = None) -> None:
112
- from supervisely.app.widgets.grid_gallery_v2.grid_gallery_v2 import (
113
- GridGalleryV2,
114
- )
115
-
116
- self.is_table_gallery = is_table_gallery
117
- filters = filters or [{"confidence": [0.6, 1]}]
118
-
119
- self.gallery = GridGalleryV2(
120
- columns_number=3,
121
- annotations_opacity=0.4,
122
- border_width=4,
123
- enable_zoom=False,
124
- default_tag_filters=filters,
125
- show_zoom_slider=False,
126
- )
127
-
128
- super().__init__()