valor-lite 0.33.15__tar.gz → 0.33.17__tar.gz
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 valor-lite might be problematic. Click here for more details.
- {valor_lite-0.33.15/valor_lite.egg-info → valor_lite-0.33.17}/PKG-INFO +12 -4
- valor_lite-0.33.17/examples/text_generation.ipynb +500 -0
- {valor_lite-0.33.15 → valor_lite-0.33.17}/pyproject.toml +9 -4
- valor_lite-0.33.17/tests/classification/test_metric.py +39 -0
- {valor_lite-0.33.15 → valor_lite-0.33.17}/tests/object_detection/test_dataloader.py +55 -4
- valor_lite-0.33.17/tests/object_detection/test_metric.py +39 -0
- {valor_lite-0.33.15 → valor_lite-0.33.17}/tests/semantic_segmentation/test_confusion_matrix.py +62 -0
- valor_lite-0.33.17/tests/semantic_segmentation/test_metric.py +39 -0
- valor_lite-0.33.17/tests/text_generation/conftest.py +240 -0
- valor_lite-0.33.17/tests/text_generation/llm/test_generation.py +140 -0
- valor_lite-0.33.17/tests/text_generation/llm/test_integrations.py +364 -0
- valor_lite-0.33.17/tests/text_generation/llm/test_utilities.py +83 -0
- valor_lite-0.33.17/tests/text_generation/llm/test_validators.py +107 -0
- valor_lite-0.33.17/tests/text_generation/metrics/test_answer_correctness.py +87 -0
- valor_lite-0.33.17/tests/text_generation/metrics/test_answer_relevance.py +109 -0
- valor_lite-0.33.17/tests/text_generation/metrics/test_bias.py +104 -0
- valor_lite-0.33.17/tests/text_generation/metrics/test_context_precision.py +195 -0
- valor_lite-0.33.17/tests/text_generation/metrics/test_context_recall.py +194 -0
- valor_lite-0.33.17/tests/text_generation/metrics/test_context_relevance.py +135 -0
- valor_lite-0.33.17/tests/text_generation/metrics/test_faithfulness.py +155 -0
- valor_lite-0.33.17/tests/text_generation/metrics/test_hallucination.py +118 -0
- valor_lite-0.33.17/tests/text_generation/metrics/test_metric.py +39 -0
- valor_lite-0.33.17/tests/text_generation/metrics/test_rouge.py +242 -0
- valor_lite-0.33.17/tests/text_generation/metrics/test_sentence_bleu.py +224 -0
- valor_lite-0.33.17/tests/text_generation/metrics/test_summary_coherence.py +88 -0
- valor_lite-0.33.17/tests/text_generation/metrics/test_toxicity.py +105 -0
- valor_lite-0.33.17/tests/text_generation/test_evaluator.py +170 -0
- valor_lite-0.33.17/tests/text_generation/test_manager.py +110 -0
- {valor_lite-0.33.15 → valor_lite-0.33.17}/valor_lite/classification/metric.py +20 -0
- {valor_lite-0.33.15 → valor_lite-0.33.17}/valor_lite/object_detection/annotation.py +0 -24
- {valor_lite-0.33.15 → valor_lite-0.33.17}/valor_lite/object_detection/manager.py +72 -81
- {valor_lite-0.33.15 → valor_lite-0.33.17}/valor_lite/object_detection/metric.py +20 -0
- valor_lite-0.33.17/valor_lite/schemas.py +11 -0
- {valor_lite-0.33.15 → valor_lite-0.33.17}/valor_lite/semantic_segmentation/computation.py +2 -2
- {valor_lite-0.33.15 → valor_lite-0.33.17}/valor_lite/semantic_segmentation/metric.py +20 -0
- valor_lite-0.33.17/valor_lite/text_generation/__init__.py +15 -0
- valor_lite-0.33.17/valor_lite/text_generation/annotation.py +56 -0
- valor_lite-0.33.17/valor_lite/text_generation/computation.py +609 -0
- valor_lite-0.33.17/valor_lite/text_generation/llm/__init__.py +0 -0
- valor_lite-0.33.17/valor_lite/text_generation/llm/exceptions.py +14 -0
- valor_lite-0.33.17/valor_lite/text_generation/llm/generation.py +903 -0
- valor_lite-0.33.17/valor_lite/text_generation/llm/instructions.py +814 -0
- valor_lite-0.33.17/valor_lite/text_generation/llm/integrations.py +226 -0
- valor_lite-0.33.17/valor_lite/text_generation/llm/utilities.py +43 -0
- valor_lite-0.33.17/valor_lite/text_generation/llm/validators.py +68 -0
- valor_lite-0.33.17/valor_lite/text_generation/manager.py +697 -0
- valor_lite-0.33.17/valor_lite/text_generation/metric.py +381 -0
- {valor_lite-0.33.15 → valor_lite-0.33.17/valor_lite.egg-info}/PKG-INFO +12 -4
- {valor_lite-0.33.15 → valor_lite-0.33.17}/valor_lite.egg-info/SOURCES.txt +37 -1
- {valor_lite-0.33.15 → valor_lite-0.33.17}/valor_lite.egg-info/requires.txt +12 -2
- valor_lite-0.33.15/valor_lite/schemas.py +0 -17
- {valor_lite-0.33.15 → valor_lite-0.33.17}/LICENSE +0 -0
- {valor_lite-0.33.15 → valor_lite-0.33.17}/README.md +0 -0
- {valor_lite-0.33.15 → valor_lite-0.33.17}/benchmarks/.gitignore +0 -0
- {valor_lite-0.33.15 → valor_lite-0.33.17}/benchmarks/benchmark_classification.py +0 -0
- {valor_lite-0.33.15 → valor_lite-0.33.17}/benchmarks/benchmark_objdet.py +0 -0
- {valor_lite-0.33.15 → valor_lite-0.33.17}/examples/.gitignore +0 -0
- {valor_lite-0.33.15 → valor_lite-0.33.17}/examples/object-detection.ipynb +0 -0
- {valor_lite-0.33.15 → valor_lite-0.33.17}/examples/tabular_classification.ipynb +0 -0
- {valor_lite-0.33.15 → valor_lite-0.33.17}/setup.cfg +0 -0
- {valor_lite-0.33.15 → valor_lite-0.33.17}/tests/__init__.py +0 -0
- {valor_lite-0.33.15 → valor_lite-0.33.17}/tests/classification/__init__.py +0 -0
- {valor_lite-0.33.15 → valor_lite-0.33.17}/tests/classification/conftest.py +0 -0
- {valor_lite-0.33.15 → valor_lite-0.33.17}/tests/classification/test_accuracy.py +0 -0
- {valor_lite-0.33.15 → valor_lite-0.33.17}/tests/classification/test_confusion_matrix.py +0 -0
- {valor_lite-0.33.15 → valor_lite-0.33.17}/tests/classification/test_counts.py +0 -0
- {valor_lite-0.33.15 → valor_lite-0.33.17}/tests/classification/test_dataloader.py +0 -0
- {valor_lite-0.33.15 → valor_lite-0.33.17}/tests/classification/test_evaluator.py +0 -0
- {valor_lite-0.33.15 → valor_lite-0.33.17}/tests/classification/test_f1.py +0 -0
- {valor_lite-0.33.15 → valor_lite-0.33.17}/tests/classification/test_filtering.py +0 -0
- {valor_lite-0.33.15 → valor_lite-0.33.17}/tests/classification/test_precision.py +0 -0
- {valor_lite-0.33.15 → valor_lite-0.33.17}/tests/classification/test_recall.py +0 -0
- {valor_lite-0.33.15 → valor_lite-0.33.17}/tests/classification/test_rocauc.py +0 -0
- {valor_lite-0.33.15 → valor_lite-0.33.17}/tests/classification/test_schemas.py +0 -0
- {valor_lite-0.33.15 → valor_lite-0.33.17}/tests/classification/test_stability.py +0 -0
- {valor_lite-0.33.15 → valor_lite-0.33.17}/tests/object_detection/__init__.py +0 -0
- {valor_lite-0.33.15 → valor_lite-0.33.17}/tests/object_detection/conftest.py +0 -0
- {valor_lite-0.33.15 → valor_lite-0.33.17}/tests/object_detection/test_accuracy.py +0 -0
- {valor_lite-0.33.15 → valor_lite-0.33.17}/tests/object_detection/test_average_precision.py +0 -0
- {valor_lite-0.33.15 → valor_lite-0.33.17}/tests/object_detection/test_average_recall.py +0 -0
- {valor_lite-0.33.15 → valor_lite-0.33.17}/tests/object_detection/test_confusion_matrix.py +0 -0
- {valor_lite-0.33.15 → valor_lite-0.33.17}/tests/object_detection/test_counts.py +0 -0
- {valor_lite-0.33.15 → valor_lite-0.33.17}/tests/object_detection/test_evaluator.py +0 -0
- {valor_lite-0.33.15 → valor_lite-0.33.17}/tests/object_detection/test_f1.py +0 -0
- {valor_lite-0.33.15 → valor_lite-0.33.17}/tests/object_detection/test_filtering.py +0 -0
- {valor_lite-0.33.15 → valor_lite-0.33.17}/tests/object_detection/test_iou.py +0 -0
- {valor_lite-0.33.15 → valor_lite-0.33.17}/tests/object_detection/test_pr_curve.py +0 -0
- {valor_lite-0.33.15 → valor_lite-0.33.17}/tests/object_detection/test_precision.py +0 -0
- {valor_lite-0.33.15 → valor_lite-0.33.17}/tests/object_detection/test_recall.py +0 -0
- {valor_lite-0.33.15 → valor_lite-0.33.17}/tests/object_detection/test_schemas.py +0 -0
- {valor_lite-0.33.15 → valor_lite-0.33.17}/tests/object_detection/test_stability.py +0 -0
- {valor_lite-0.33.15 → valor_lite-0.33.17}/tests/semantic_segmentation/__init__.py +0 -0
- {valor_lite-0.33.15 → valor_lite-0.33.17}/tests/semantic_segmentation/conftest.py +0 -0
- {valor_lite-0.33.15 → valor_lite-0.33.17}/tests/semantic_segmentation/test_accuracy.py +0 -0
- {valor_lite-0.33.15 → valor_lite-0.33.17}/tests/semantic_segmentation/test_annotation.py +0 -0
- {valor_lite-0.33.15 → valor_lite-0.33.17}/tests/semantic_segmentation/test_dataloader.py +0 -0
- {valor_lite-0.33.15 → valor_lite-0.33.17}/tests/semantic_segmentation/test_evaluator.py +0 -0
- {valor_lite-0.33.15 → valor_lite-0.33.17}/tests/semantic_segmentation/test_f1.py +0 -0
- {valor_lite-0.33.15 → valor_lite-0.33.17}/tests/semantic_segmentation/test_filtering.py +0 -0
- {valor_lite-0.33.15 → valor_lite-0.33.17}/tests/semantic_segmentation/test_iou.py +0 -0
- {valor_lite-0.33.15 → valor_lite-0.33.17}/tests/semantic_segmentation/test_precision.py +0 -0
- {valor_lite-0.33.15 → valor_lite-0.33.17}/tests/semantic_segmentation/test_recall.py +0 -0
- {valor_lite-0.33.15 → valor_lite-0.33.17}/tests/semantic_segmentation/test_stability.py +0 -0
- {valor_lite-0.33.15 → valor_lite-0.33.17}/tests/text_generation/__init__.py +0 -0
- {valor_lite-0.33.15/valor_lite → valor_lite-0.33.17/tests/text_generation/llm}/__init__.py +0 -0
- {valor_lite-0.33.15 → valor_lite-0.33.17}/valor_lite/LICENSE +0 -0
- {valor_lite-0.33.15/valor_lite/text_generation → valor_lite-0.33.17/valor_lite}/__init__.py +0 -0
- {valor_lite-0.33.15 → valor_lite-0.33.17}/valor_lite/classification/__init__.py +0 -0
- {valor_lite-0.33.15 → valor_lite-0.33.17}/valor_lite/classification/annotation.py +0 -0
- {valor_lite-0.33.15 → valor_lite-0.33.17}/valor_lite/classification/computation.py +0 -0
- {valor_lite-0.33.15 → valor_lite-0.33.17}/valor_lite/classification/manager.py +0 -0
- {valor_lite-0.33.15 → valor_lite-0.33.17}/valor_lite/classification/utilities.py +0 -0
- {valor_lite-0.33.15 → valor_lite-0.33.17}/valor_lite/object_detection/__init__.py +0 -0
- {valor_lite-0.33.15 → valor_lite-0.33.17}/valor_lite/object_detection/computation.py +0 -0
- {valor_lite-0.33.15 → valor_lite-0.33.17}/valor_lite/object_detection/utilities.py +0 -0
- {valor_lite-0.33.15 → valor_lite-0.33.17}/valor_lite/semantic_segmentation/__init__.py +0 -0
- {valor_lite-0.33.15 → valor_lite-0.33.17}/valor_lite/semantic_segmentation/annotation.py +0 -0
- {valor_lite-0.33.15 → valor_lite-0.33.17}/valor_lite/semantic_segmentation/manager.py +0 -0
- {valor_lite-0.33.15 → valor_lite-0.33.17}/valor_lite/semantic_segmentation/utilities.py +0 -0
- {valor_lite-0.33.15 → valor_lite-0.33.17}/valor_lite.egg-info/dependency_links.txt +0 -0
- {valor_lite-0.33.15 → valor_lite-0.33.17}/valor_lite.egg-info/top_level.txt +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: valor-lite
|
|
3
|
-
Version: 0.33.
|
|
3
|
+
Version: 0.33.17
|
|
4
4
|
Summary: Compute valor metrics locally.
|
|
5
5
|
License: MIT License
|
|
6
6
|
|
|
@@ -28,15 +28,23 @@ Project-URL: homepage, https://www.striveworks.com
|
|
|
28
28
|
Requires-Python: >=3.10
|
|
29
29
|
Description-Content-Type: text/markdown
|
|
30
30
|
License-File: LICENSE
|
|
31
|
-
Requires-Dist:
|
|
31
|
+
Requires-Dist: evaluate
|
|
32
32
|
Requires-Dist: importlib_metadata; python_version < "3.8"
|
|
33
|
-
Requires-Dist:
|
|
34
|
-
Requires-Dist: requests
|
|
33
|
+
Requires-Dist: nltk
|
|
35
34
|
Requires-Dist: numpy
|
|
35
|
+
Requires-Dist: Pillow>=9.1.0
|
|
36
|
+
Requires-Dist: requests
|
|
37
|
+
Requires-Dist: rouge_score
|
|
36
38
|
Requires-Dist: shapely
|
|
39
|
+
Requires-Dist: tqdm
|
|
40
|
+
Provides-Extra: mistral
|
|
41
|
+
Requires-Dist: mistralai>=1.0; extra == "mistral"
|
|
42
|
+
Provides-Extra: openai
|
|
43
|
+
Requires-Dist: openai; extra == "openai"
|
|
37
44
|
Provides-Extra: test
|
|
38
45
|
Requires-Dist: pytest; extra == "test"
|
|
39
46
|
Requires-Dist: coverage; extra == "test"
|
|
47
|
+
Requires-Dist: pre-commit; extra == "test"
|
|
40
48
|
|
|
41
49
|
# valor-lite: Fast, local machine learning evaluation.
|
|
42
50
|
|
|
@@ -0,0 +1,500 @@
|
|
|
1
|
+
{
|
|
2
|
+
"cells": [
|
|
3
|
+
{
|
|
4
|
+
"attachments": {},
|
|
5
|
+
"cell_type": "markdown",
|
|
6
|
+
"metadata": {},
|
|
7
|
+
"source": [
|
|
8
|
+
"# Text Generation Example\n",
|
|
9
|
+
"\n",
|
|
10
|
+
"## Introduction\n",
|
|
11
|
+
"\n",
|
|
12
|
+
"In this notebook, we'll walk-through a detailed example of how you can use Valor to evaluate LLM's.\n",
|
|
13
|
+
"\n",
|
|
14
|
+
"For a conceptual introduction to Valor, [check out our project overview](https://striveworks.github.io/valor/). For a higher-level example notebook, [check out our \"Getting Started\" notebook](https://github.com/Striveworks/valor/blob/main/examples/getting_started.ipynb)."
|
|
15
|
+
]
|
|
16
|
+
},
|
|
17
|
+
{
|
|
18
|
+
"cell_type": "code",
|
|
19
|
+
"execution_count": 1,
|
|
20
|
+
"metadata": {},
|
|
21
|
+
"outputs": [
|
|
22
|
+
{
|
|
23
|
+
"name": "stderr",
|
|
24
|
+
"output_type": "stream",
|
|
25
|
+
"text": [
|
|
26
|
+
"/home/czaloom/valor/.env-valor/lib/python3.10/site-packages/tqdm/auto.py:21: TqdmWarning: IProgress not found. Please update jupyter and ipywidgets. See https://ipywidgets.readthedocs.io/en/stable/user_install.html\n",
|
|
27
|
+
" from .autonotebook import tqdm as notebook_tqdm\n"
|
|
28
|
+
]
|
|
29
|
+
},
|
|
30
|
+
{
|
|
31
|
+
"data": {
|
|
32
|
+
"text/plain": [
|
|
33
|
+
"True"
|
|
34
|
+
]
|
|
35
|
+
},
|
|
36
|
+
"execution_count": 1,
|
|
37
|
+
"metadata": {},
|
|
38
|
+
"output_type": "execute_result"
|
|
39
|
+
}
|
|
40
|
+
],
|
|
41
|
+
"source": [
|
|
42
|
+
"import json\n",
|
|
43
|
+
"import torch\n",
|
|
44
|
+
"from transformers import pipeline\n",
|
|
45
|
+
"from valor_lite.text_generation import Evaluator, QueryResponse, Context, MetricType\n",
|
|
46
|
+
"from dotenv import load_dotenv\n",
|
|
47
|
+
"\n",
|
|
48
|
+
"load_dotenv()"
|
|
49
|
+
]
|
|
50
|
+
},
|
|
51
|
+
{
|
|
52
|
+
"attachments": {},
|
|
53
|
+
"cell_type": "markdown",
|
|
54
|
+
"metadata": {},
|
|
55
|
+
"source": [
|
|
56
|
+
"## Set up an LLM using Huggingface."
|
|
57
|
+
]
|
|
58
|
+
},
|
|
59
|
+
{
|
|
60
|
+
"cell_type": "code",
|
|
61
|
+
"execution_count": 2,
|
|
62
|
+
"metadata": {},
|
|
63
|
+
"outputs": [],
|
|
64
|
+
"source": [
|
|
65
|
+
"class LlamaWrapper:\n",
|
|
66
|
+
"\n",
|
|
67
|
+
" def __init__(\n",
|
|
68
|
+
" self,\n",
|
|
69
|
+
" model_name: str = \"meta-llama/Llama-3.2-1B-Instruct\",\n",
|
|
70
|
+
" ) -> None:\n",
|
|
71
|
+
" self.model_name = model_name\n",
|
|
72
|
+
" self.pipe = pipeline(\n",
|
|
73
|
+
" \"text-generation\", \n",
|
|
74
|
+
" model=model_name, \n",
|
|
75
|
+
" torch_dtype=torch.bfloat16, \n",
|
|
76
|
+
" device_map=\"auto\"\n",
|
|
77
|
+
" )\n",
|
|
78
|
+
"\n",
|
|
79
|
+
" def __call__(\n",
|
|
80
|
+
" self,\n",
|
|
81
|
+
" messages: list[dict[str, str]],\n",
|
|
82
|
+
" ) -> str:\n",
|
|
83
|
+
" output = self.pipe(messages, max_new_tokens=256)\n",
|
|
84
|
+
" return output[0]['generated_text'][-1][\"content\"]"
|
|
85
|
+
]
|
|
86
|
+
},
|
|
87
|
+
{
|
|
88
|
+
"cell_type": "code",
|
|
89
|
+
"execution_count": 3,
|
|
90
|
+
"metadata": {},
|
|
91
|
+
"outputs": [],
|
|
92
|
+
"source": [
|
|
93
|
+
"client = LlamaWrapper()"
|
|
94
|
+
]
|
|
95
|
+
},
|
|
96
|
+
{
|
|
97
|
+
"cell_type": "code",
|
|
98
|
+
"execution_count": 4,
|
|
99
|
+
"metadata": {},
|
|
100
|
+
"outputs": [
|
|
101
|
+
{
|
|
102
|
+
"name": "stderr",
|
|
103
|
+
"output_type": "stream",
|
|
104
|
+
"text": [
|
|
105
|
+
"Setting `pad_token_id` to `eos_token_id`:None for open-end generation.\n"
|
|
106
|
+
]
|
|
107
|
+
},
|
|
108
|
+
{
|
|
109
|
+
"data": {
|
|
110
|
+
"text/plain": [
|
|
111
|
+
"'I\\'m an artificial intelligence model known as Llama. Llama stands for \"Large Language Model Meta AI.\"'"
|
|
112
|
+
]
|
|
113
|
+
},
|
|
114
|
+
"execution_count": 4,
|
|
115
|
+
"metadata": {},
|
|
116
|
+
"output_type": "execute_result"
|
|
117
|
+
}
|
|
118
|
+
],
|
|
119
|
+
"source": [
|
|
120
|
+
"client([{\"role\": \"user\", \"content\": \"Who are you?\"}])"
|
|
121
|
+
]
|
|
122
|
+
},
|
|
123
|
+
{
|
|
124
|
+
"attachments": {},
|
|
125
|
+
"cell_type": "markdown",
|
|
126
|
+
"metadata": {},
|
|
127
|
+
"source": [
|
|
128
|
+
"# Now, lets evaluate a query!"
|
|
129
|
+
]
|
|
130
|
+
},
|
|
131
|
+
{
|
|
132
|
+
"attachments": {},
|
|
133
|
+
"cell_type": "markdown",
|
|
134
|
+
"metadata": {},
|
|
135
|
+
"source": [
|
|
136
|
+
"First, lets choose a model to perform the evaluation requests."
|
|
137
|
+
]
|
|
138
|
+
},
|
|
139
|
+
{
|
|
140
|
+
"cell_type": "code",
|
|
141
|
+
"execution_count": 5,
|
|
142
|
+
"metadata": {},
|
|
143
|
+
"outputs": [],
|
|
144
|
+
"source": [
|
|
145
|
+
"evaluator = Evaluator.openai()\n",
|
|
146
|
+
"# evaluator = Evaluator.mistral()\n",
|
|
147
|
+
"# evaluator = Evaluator(client=LlamaWrapper())"
|
|
148
|
+
]
|
|
149
|
+
},
|
|
150
|
+
{
|
|
151
|
+
"cell_type": "code",
|
|
152
|
+
"execution_count": 6,
|
|
153
|
+
"metadata": {},
|
|
154
|
+
"outputs": [],
|
|
155
|
+
"source": [
|
|
156
|
+
"query = QueryResponse(\n",
|
|
157
|
+
" query=\"Did John Adams get along with Alexander Hamilton?\",\n",
|
|
158
|
+
" response=\"Based on the provided context, John Adams and Alexander Hamilton did not get along. John Adams, during his presidency, had grown independent of his cabinet, often making decisions despite opposition from it. Hamilton, who was accustomed to being regularly consulted by Washington, sent Adams a detailed letter with policy suggestions after his inauguration, which Adams dismissively ignored.\\n\",\n",
|
|
159
|
+
" context=Context(\n",
|
|
160
|
+
" groundtruth=[\n",
|
|
161
|
+
" \"John Adams and Alexander Hamilton did not get along. John Adams had grown independent of his cabinet, often making decisions despite opposition from it.\\n\",\n",
|
|
162
|
+
" ],\n",
|
|
163
|
+
" prediction=[\n",
|
|
164
|
+
" \"\"\"Although aware of Hamilton\\'s influence, Adams was convinced that their retention ensured a smoother succession. Adams maintained the economic programs of Hamilton, who regularly consulted with key cabinet members, especially the powerful Treasury Secretary, Oliver Wolcott Jr. Adams was in other respects quite independent of his cabinet, often making decisions despite opposition from it. Hamilton had grown accustomed to being regularly consulted by Washington. Shortly after Adams was inaugurated, Hamilton sent him a detailed letter with policy suggestions. Adams dismissively ignored it.\\n\\nFailed peace commission and XYZ affair\\nHistorian Joseph Ellis writes that \"[t]he Adams presidency was destined to be dominated by a single question of American policy to an extent seldom if ever encountered by any succeeding occupant of the office.\" That question was whether to make war with France or find peace. Britain and France were at war as a result of the French Revolution. Hamilton and the Federalists strongly favored the British monarchy against what they denounced as the political radicalism and anti-religious frenzy of the French Revolution. Jefferson and the Republicans, with their firm opposition to monarchy, strongly supported the French overthrowing their king. The French had supported Jefferson for president in 1796 and became belligerent at his loss.\"\"\",\n",
|
|
165
|
+
" \"\"\"Led by Revolutionary War veteran John Fries, rural German-speaking farmers protested what they saw as a threat to their liberties. They intimidated tax collectors, who often found themselves unable to go about their business. The disturbance was quickly ended with Hamilton leading the army to restore peace.Fries and two other leaders were arrested, found guilty of treason, and sentenced to hang. They appealed to Adams requesting a pardon. The cabinet unanimously advised Adams to refuse, but he instead granted the pardon, arguing the men had instigated a mere riot as opposed to a rebellion. In his pamphlet attacking Adams before the election, Hamilton wrote that \\\"it was impossible to commit a greater error.\\\"\\n\\nFederalist divisions and peace\\nOn May 5, 1800, Adams's frustrations with the Hamilton wing of the party exploded during a meeting with McHenry, a Hamilton loyalist who was universally regarded, even by Hamilton, as an inept Secretary of War. Adams accused him of subservience to Hamilton and declared that he would rather serve as Jefferson's vice president or minister at The Hague than be beholden to Hamilton for the presidency. McHenry offered to resign at once, and Adams accepted. On May 10, he asked Pickering to resign.\"\"\",\n",
|
|
166
|
+
" \"\"\"Indeed, Adams did not consider himself a strong member of the Federalist Party. He had remarked that Hamilton\\'s economic program, centered around banks, would \"swindle\" the poor and unleash the \"gangrene of avarice.\" Desiring \"a more pliant president than Adams,\" Hamilton maneuvered to tip the election to Pinckney. He coerced South Carolina Federalist electors, pledged to vote for \"favorite son\" Pinckney, to scatter their second votes among candidates other than Adams. Hamilton\\'s scheme was undone when several New England state electors heard of it and agreed not to vote for Pinckney. Adams wrote shortly after the election that Hamilton was a \"proud Spirited, conceited, aspiring Mortal always pretending to Morality, with as debauched Morals as old Franklin who is more his Model than any one I know.\" Throughout his life, Adams made highly critical statements about Hamilton. He made derogatory references to his womanizing, real or alleged, and slurred him as the \"Creole bastard.\"\"\",\n",
|
|
167
|
+
" \"\"\"The pair\\'s exchange was respectful; Adams promised to do all that he could to restore friendship and cordiality \"between People who, tho Seperated [sic] by an Ocean and under different Governments have the Same Language, a Similar Religion and kindred Blood,\" and the King agreed to \"receive with Pleasure, the Assurances of the friendly Dispositions of the United States.\" The King added that although \"he had been the last to consent\" to American independence, he had always done what he thought was right. He startled Adams by commenting that \"There is an Opinion, among Some People, that you are not the most attached of all Your Countrymen, to the manners of France.\" Adams replied, \"That Opinion sir, is not mistaken... I have no Attachments but to my own Country.\" King George responded, \"An honest Man will never have any other.\"\\nAdams was joined by Abigail in London. Suffering the hostility of the King\\'s courtiers, they escaped when they could by seeking out Richard Price, minister of Newington Green Unitarian Church and instigator of the debate over the Revolution within Britain.\"\"\",\n",
|
|
168
|
+
" ],\n",
|
|
169
|
+
" )\n",
|
|
170
|
+
")"
|
|
171
|
+
]
|
|
172
|
+
},
|
|
173
|
+
{
|
|
174
|
+
"cell_type": "code",
|
|
175
|
+
"execution_count": 7,
|
|
176
|
+
"metadata": {},
|
|
177
|
+
"outputs": [
|
|
178
|
+
{
|
|
179
|
+
"name": "stdout",
|
|
180
|
+
"output_type": "stream",
|
|
181
|
+
"text": [
|
|
182
|
+
"{\n",
|
|
183
|
+
" \"type\": \"AnswerCorrectness\",\n",
|
|
184
|
+
" \"value\": 0.6666666666666666,\n",
|
|
185
|
+
" \"parameters\": {\n",
|
|
186
|
+
" \"evaluator\": \"gpt-3.5-turbo\",\n",
|
|
187
|
+
" \"retries\": 0\n",
|
|
188
|
+
" }\n",
|
|
189
|
+
"}\n"
|
|
190
|
+
]
|
|
191
|
+
}
|
|
192
|
+
],
|
|
193
|
+
"source": [
|
|
194
|
+
"metric = evaluator.compute_answer_correctness(query)\n",
|
|
195
|
+
"print(json.dumps(metric.to_dict(), indent=4))"
|
|
196
|
+
]
|
|
197
|
+
},
|
|
198
|
+
{
|
|
199
|
+
"cell_type": "code",
|
|
200
|
+
"execution_count": 8,
|
|
201
|
+
"metadata": {},
|
|
202
|
+
"outputs": [
|
|
203
|
+
{
|
|
204
|
+
"name": "stdout",
|
|
205
|
+
"output_type": "stream",
|
|
206
|
+
"text": [
|
|
207
|
+
"{\n",
|
|
208
|
+
" \"type\": \"AnswerRelevance\",\n",
|
|
209
|
+
" \"value\": 0.16666666666666666,\n",
|
|
210
|
+
" \"parameters\": {\n",
|
|
211
|
+
" \"evaluator\": \"gpt-3.5-turbo\",\n",
|
|
212
|
+
" \"retries\": 0\n",
|
|
213
|
+
" }\n",
|
|
214
|
+
"}\n"
|
|
215
|
+
]
|
|
216
|
+
}
|
|
217
|
+
],
|
|
218
|
+
"source": [
|
|
219
|
+
"metric = evaluator.compute_answer_relevance(query)\n",
|
|
220
|
+
"print(json.dumps(metric.to_dict(), indent=4))"
|
|
221
|
+
]
|
|
222
|
+
},
|
|
223
|
+
{
|
|
224
|
+
"cell_type": "code",
|
|
225
|
+
"execution_count": 9,
|
|
226
|
+
"metadata": {},
|
|
227
|
+
"outputs": [
|
|
228
|
+
{
|
|
229
|
+
"name": "stdout",
|
|
230
|
+
"output_type": "stream",
|
|
231
|
+
"text": [
|
|
232
|
+
"{\n",
|
|
233
|
+
" \"type\": \"Bias\",\n",
|
|
234
|
+
" \"value\": 0.0,\n",
|
|
235
|
+
" \"parameters\": {\n",
|
|
236
|
+
" \"evaluator\": \"gpt-3.5-turbo\",\n",
|
|
237
|
+
" \"retries\": 0\n",
|
|
238
|
+
" }\n",
|
|
239
|
+
"}\n"
|
|
240
|
+
]
|
|
241
|
+
}
|
|
242
|
+
],
|
|
243
|
+
"source": [
|
|
244
|
+
"metric = evaluator.compute_bias(query)\n",
|
|
245
|
+
"print(json.dumps(metric.to_dict(), indent=4))"
|
|
246
|
+
]
|
|
247
|
+
},
|
|
248
|
+
{
|
|
249
|
+
"cell_type": "code",
|
|
250
|
+
"execution_count": 10,
|
|
251
|
+
"metadata": {},
|
|
252
|
+
"outputs": [
|
|
253
|
+
{
|
|
254
|
+
"name": "stdout",
|
|
255
|
+
"output_type": "stream",
|
|
256
|
+
"text": [
|
|
257
|
+
"{\n",
|
|
258
|
+
" \"type\": \"BLEU\",\n",
|
|
259
|
+
" \"value\": 0.3502270395690205,\n",
|
|
260
|
+
" \"parameters\": {\n",
|
|
261
|
+
" \"weights\": [\n",
|
|
262
|
+
" 0.25,\n",
|
|
263
|
+
" 0.25,\n",
|
|
264
|
+
" 0.25,\n",
|
|
265
|
+
" 0.25\n",
|
|
266
|
+
" ]\n",
|
|
267
|
+
" }\n",
|
|
268
|
+
"}\n"
|
|
269
|
+
]
|
|
270
|
+
}
|
|
271
|
+
],
|
|
272
|
+
"source": [
|
|
273
|
+
"metric = evaluator.compute_sentence_bleu(query)\n",
|
|
274
|
+
"print(json.dumps(metric.to_dict(), indent=4))"
|
|
275
|
+
]
|
|
276
|
+
},
|
|
277
|
+
{
|
|
278
|
+
"cell_type": "code",
|
|
279
|
+
"execution_count": 11,
|
|
280
|
+
"metadata": {},
|
|
281
|
+
"outputs": [
|
|
282
|
+
{
|
|
283
|
+
"name": "stdout",
|
|
284
|
+
"output_type": "stream",
|
|
285
|
+
"text": [
|
|
286
|
+
"{\n",
|
|
287
|
+
" \"type\": \"ContextPrecision\",\n",
|
|
288
|
+
" \"value\": 0.8333333333333333,\n",
|
|
289
|
+
" \"parameters\": {\n",
|
|
290
|
+
" \"evaluator\": \"gpt-3.5-turbo\",\n",
|
|
291
|
+
" \"retries\": 0\n",
|
|
292
|
+
" }\n",
|
|
293
|
+
"}\n"
|
|
294
|
+
]
|
|
295
|
+
}
|
|
296
|
+
],
|
|
297
|
+
"source": [
|
|
298
|
+
"metric = evaluator.compute_context_precision(query)\n",
|
|
299
|
+
"print(json.dumps(metric.to_dict(), indent=4))"
|
|
300
|
+
]
|
|
301
|
+
},
|
|
302
|
+
{
|
|
303
|
+
"cell_type": "code",
|
|
304
|
+
"execution_count": 12,
|
|
305
|
+
"metadata": {},
|
|
306
|
+
"outputs": [
|
|
307
|
+
{
|
|
308
|
+
"name": "stdout",
|
|
309
|
+
"output_type": "stream",
|
|
310
|
+
"text": [
|
|
311
|
+
"{\n",
|
|
312
|
+
" \"type\": \"ContextRecall\",\n",
|
|
313
|
+
" \"value\": 0.6666666666666666,\n",
|
|
314
|
+
" \"parameters\": {\n",
|
|
315
|
+
" \"evaluator\": \"gpt-3.5-turbo\",\n",
|
|
316
|
+
" \"retries\": 0\n",
|
|
317
|
+
" }\n",
|
|
318
|
+
"}\n"
|
|
319
|
+
]
|
|
320
|
+
}
|
|
321
|
+
],
|
|
322
|
+
"source": [
|
|
323
|
+
"metric = evaluator.compute_context_recall(query)\n",
|
|
324
|
+
"print(json.dumps(metric.to_dict(), indent=4))"
|
|
325
|
+
]
|
|
326
|
+
},
|
|
327
|
+
{
|
|
328
|
+
"cell_type": "code",
|
|
329
|
+
"execution_count": 13,
|
|
330
|
+
"metadata": {},
|
|
331
|
+
"outputs": [
|
|
332
|
+
{
|
|
333
|
+
"name": "stdout",
|
|
334
|
+
"output_type": "stream",
|
|
335
|
+
"text": [
|
|
336
|
+
"{\n",
|
|
337
|
+
" \"type\": \"Faithfulness\",\n",
|
|
338
|
+
" \"value\": 0.8333333333333334,\n",
|
|
339
|
+
" \"parameters\": {\n",
|
|
340
|
+
" \"evaluator\": \"gpt-3.5-turbo\",\n",
|
|
341
|
+
" \"retries\": 0\n",
|
|
342
|
+
" }\n",
|
|
343
|
+
"}\n"
|
|
344
|
+
]
|
|
345
|
+
}
|
|
346
|
+
],
|
|
347
|
+
"source": [
|
|
348
|
+
"metric = evaluator.compute_faithfulness(query)\n",
|
|
349
|
+
"print(json.dumps(metric.to_dict(), indent=4))"
|
|
350
|
+
]
|
|
351
|
+
},
|
|
352
|
+
{
|
|
353
|
+
"cell_type": "code",
|
|
354
|
+
"execution_count": 14,
|
|
355
|
+
"metadata": {},
|
|
356
|
+
"outputs": [
|
|
357
|
+
{
|
|
358
|
+
"name": "stdout",
|
|
359
|
+
"output_type": "stream",
|
|
360
|
+
"text": [
|
|
361
|
+
"{\n",
|
|
362
|
+
" \"type\": \"Hallucination\",\n",
|
|
363
|
+
" \"value\": 0.5,\n",
|
|
364
|
+
" \"parameters\": {\n",
|
|
365
|
+
" \"evaluator\": \"gpt-3.5-turbo\",\n",
|
|
366
|
+
" \"retries\": 0\n",
|
|
367
|
+
" }\n",
|
|
368
|
+
"}\n"
|
|
369
|
+
]
|
|
370
|
+
}
|
|
371
|
+
],
|
|
372
|
+
"source": [
|
|
373
|
+
"metric = evaluator.compute_hallucination(query)\n",
|
|
374
|
+
"print(json.dumps(metric.to_dict(), indent=4))"
|
|
375
|
+
]
|
|
376
|
+
},
|
|
377
|
+
{
|
|
378
|
+
"cell_type": "code",
|
|
379
|
+
"execution_count": 15,
|
|
380
|
+
"metadata": {},
|
|
381
|
+
"outputs": [
|
|
382
|
+
{
|
|
383
|
+
"name": "stdout",
|
|
384
|
+
"output_type": "stream",
|
|
385
|
+
"text": [
|
|
386
|
+
"{\n",
|
|
387
|
+
" \"type\": \"ROUGE\",\n",
|
|
388
|
+
" \"value\": 0.5925925925925926,\n",
|
|
389
|
+
" \"parameters\": {\n",
|
|
390
|
+
" \"rouge_type\": \"rouge1\",\n",
|
|
391
|
+
" \"use_stemmer\": false\n",
|
|
392
|
+
" }\n",
|
|
393
|
+
"}\n",
|
|
394
|
+
"{\n",
|
|
395
|
+
" \"type\": \"ROUGE\",\n",
|
|
396
|
+
" \"value\": 0.5569620253164557,\n",
|
|
397
|
+
" \"parameters\": {\n",
|
|
398
|
+
" \"rouge_type\": \"rouge2\",\n",
|
|
399
|
+
" \"use_stemmer\": false\n",
|
|
400
|
+
" }\n",
|
|
401
|
+
"}\n",
|
|
402
|
+
"{\n",
|
|
403
|
+
" \"type\": \"ROUGE\",\n",
|
|
404
|
+
" \"value\": 0.5925925925925926,\n",
|
|
405
|
+
" \"parameters\": {\n",
|
|
406
|
+
" \"rouge_type\": \"rougeL\",\n",
|
|
407
|
+
" \"use_stemmer\": false\n",
|
|
408
|
+
" }\n",
|
|
409
|
+
"}\n",
|
|
410
|
+
"{\n",
|
|
411
|
+
" \"type\": \"ROUGE\",\n",
|
|
412
|
+
" \"value\": 0.5925925925925926,\n",
|
|
413
|
+
" \"parameters\": {\n",
|
|
414
|
+
" \"rouge_type\": \"rougeLsum\",\n",
|
|
415
|
+
" \"use_stemmer\": false\n",
|
|
416
|
+
" }\n",
|
|
417
|
+
"}\n"
|
|
418
|
+
]
|
|
419
|
+
}
|
|
420
|
+
],
|
|
421
|
+
"source": [
|
|
422
|
+
"metrics = evaluator.compute_rouge(query)\n",
|
|
423
|
+
"for m in metrics:\n",
|
|
424
|
+
" print(json.dumps(m.to_dict(), indent=4))"
|
|
425
|
+
]
|
|
426
|
+
},
|
|
427
|
+
{
|
|
428
|
+
"cell_type": "code",
|
|
429
|
+
"execution_count": 16,
|
|
430
|
+
"metadata": {},
|
|
431
|
+
"outputs": [
|
|
432
|
+
{
|
|
433
|
+
"name": "stdout",
|
|
434
|
+
"output_type": "stream",
|
|
435
|
+
"text": [
|
|
436
|
+
"{\n",
|
|
437
|
+
" \"type\": \"SummaryCoherence\",\n",
|
|
438
|
+
" \"value\": 4,\n",
|
|
439
|
+
" \"parameters\": {\n",
|
|
440
|
+
" \"evaluator\": \"gpt-3.5-turbo\",\n",
|
|
441
|
+
" \"retries\": 0\n",
|
|
442
|
+
" }\n",
|
|
443
|
+
"}\n"
|
|
444
|
+
]
|
|
445
|
+
}
|
|
446
|
+
],
|
|
447
|
+
"source": [
|
|
448
|
+
"metric = evaluator.compute_summary_coherence(query)\n",
|
|
449
|
+
"print(json.dumps(metric.to_dict(), indent=4))"
|
|
450
|
+
]
|
|
451
|
+
},
|
|
452
|
+
{
|
|
453
|
+
"cell_type": "code",
|
|
454
|
+
"execution_count": 17,
|
|
455
|
+
"metadata": {},
|
|
456
|
+
"outputs": [
|
|
457
|
+
{
|
|
458
|
+
"name": "stdout",
|
|
459
|
+
"output_type": "stream",
|
|
460
|
+
"text": [
|
|
461
|
+
"{\n",
|
|
462
|
+
" \"type\": \"Toxicity\",\n",
|
|
463
|
+
" \"value\": 0.3333333333333333,\n",
|
|
464
|
+
" \"parameters\": {\n",
|
|
465
|
+
" \"evaluator\": \"gpt-3.5-turbo\",\n",
|
|
466
|
+
" \"retries\": 0\n",
|
|
467
|
+
" }\n",
|
|
468
|
+
"}\n"
|
|
469
|
+
]
|
|
470
|
+
}
|
|
471
|
+
],
|
|
472
|
+
"source": [
|
|
473
|
+
"metric = evaluator.compute_toxicity(query)\n",
|
|
474
|
+
"print(json.dumps(metric.to_dict(), indent=4))"
|
|
475
|
+
]
|
|
476
|
+
}
|
|
477
|
+
],
|
|
478
|
+
"metadata": {
|
|
479
|
+
"kernelspec": {
|
|
480
|
+
"display_name": ".env-valor",
|
|
481
|
+
"language": "python",
|
|
482
|
+
"name": "python3"
|
|
483
|
+
},
|
|
484
|
+
"language_info": {
|
|
485
|
+
"codemirror_mode": {
|
|
486
|
+
"name": "ipython",
|
|
487
|
+
"version": 3
|
|
488
|
+
},
|
|
489
|
+
"file_extension": ".py",
|
|
490
|
+
"mimetype": "text/x-python",
|
|
491
|
+
"name": "python",
|
|
492
|
+
"nbconvert_exporter": "python",
|
|
493
|
+
"pygments_lexer": "ipython3",
|
|
494
|
+
"version": "3.10.15"
|
|
495
|
+
},
|
|
496
|
+
"orig_nbformat": 4
|
|
497
|
+
},
|
|
498
|
+
"nbformat": 4,
|
|
499
|
+
"nbformat_minor": 2
|
|
500
|
+
}
|
|
@@ -6,12 +6,15 @@ readme = "README.md"
|
|
|
6
6
|
requires-python = ">=3.10"
|
|
7
7
|
license = { file = "LICENSE" }
|
|
8
8
|
dependencies = [
|
|
9
|
-
"
|
|
9
|
+
"evaluate",
|
|
10
10
|
"importlib_metadata; python_version < '3.8'",
|
|
11
|
-
"
|
|
12
|
-
"requests",
|
|
11
|
+
"nltk",
|
|
13
12
|
"numpy",
|
|
13
|
+
"Pillow >= 9.1.0",
|
|
14
|
+
"requests",
|
|
15
|
+
"rouge_score",
|
|
14
16
|
"shapely",
|
|
17
|
+
"tqdm",
|
|
15
18
|
]
|
|
16
19
|
|
|
17
20
|
[project.urls]
|
|
@@ -22,7 +25,9 @@ requires = ["setuptools>=61.0", "setuptools_scm[toml]>=6.2"]
|
|
|
22
25
|
build-backend = "setuptools.build_meta"
|
|
23
26
|
|
|
24
27
|
[project.optional-dependencies]
|
|
25
|
-
|
|
28
|
+
mistral = ["mistralai >= 1.0"]
|
|
29
|
+
openai = ["openai"]
|
|
30
|
+
test = ["pytest", "coverage", "pre-commit"]
|
|
26
31
|
|
|
27
32
|
[tool.black]
|
|
28
33
|
line-length = 79
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import pytest
|
|
2
|
+
from valor_lite.classification import Metric
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
def test_metric_type_validation():
|
|
6
|
+
|
|
7
|
+
# test type attribute
|
|
8
|
+
with pytest.raises(TypeError):
|
|
9
|
+
Metric(
|
|
10
|
+
type=1234, # type: ignore - testing
|
|
11
|
+
value=1234,
|
|
12
|
+
parameters={},
|
|
13
|
+
)
|
|
14
|
+
|
|
15
|
+
# test value attribute
|
|
16
|
+
with pytest.raises(TypeError):
|
|
17
|
+
Metric(
|
|
18
|
+
type="SomeMetric",
|
|
19
|
+
value=[1, 2, 3], # type: ignore - testing
|
|
20
|
+
parameters={},
|
|
21
|
+
)
|
|
22
|
+
|
|
23
|
+
# test parameters attribute
|
|
24
|
+
with pytest.raises(TypeError):
|
|
25
|
+
Metric(
|
|
26
|
+
type="SomeMetric",
|
|
27
|
+
value=1,
|
|
28
|
+
parameters=123, # type: ignore - testing
|
|
29
|
+
)
|
|
30
|
+
|
|
31
|
+
# test parameter keys
|
|
32
|
+
with pytest.raises(TypeError):
|
|
33
|
+
Metric(
|
|
34
|
+
type="SomeMetric",
|
|
35
|
+
value=1,
|
|
36
|
+
parameters={
|
|
37
|
+
1: "hello",
|
|
38
|
+
}, # type: ignore - testing
|
|
39
|
+
)
|
|
@@ -16,6 +16,49 @@ def test_no_data():
|
|
|
16
16
|
loader.finalize()
|
|
17
17
|
|
|
18
18
|
|
|
19
|
+
def test_iou_computation():
|
|
20
|
+
|
|
21
|
+
detection = Detection(
|
|
22
|
+
uid="uid",
|
|
23
|
+
groundtruths=[
|
|
24
|
+
BoundingBox(xmin=0, xmax=10, ymin=0, ymax=10, labels=["0"]),
|
|
25
|
+
BoundingBox(xmin=100, xmax=110, ymin=100, ymax=110, labels=["0"]),
|
|
26
|
+
BoundingBox(
|
|
27
|
+
xmin=1000, xmax=1100, ymin=1000, ymax=1100, labels=["0"]
|
|
28
|
+
),
|
|
29
|
+
],
|
|
30
|
+
predictions=[
|
|
31
|
+
BoundingBox(
|
|
32
|
+
xmin=1,
|
|
33
|
+
xmax=11,
|
|
34
|
+
ymin=1,
|
|
35
|
+
ymax=11,
|
|
36
|
+
labels=["0", "1", "2"],
|
|
37
|
+
scores=[0.5, 0.25, 0.25],
|
|
38
|
+
),
|
|
39
|
+
BoundingBox(
|
|
40
|
+
xmin=105,
|
|
41
|
+
xmax=116,
|
|
42
|
+
ymin=105,
|
|
43
|
+
ymax=116,
|
|
44
|
+
labels=["0", "1", "2"],
|
|
45
|
+
scores=[0.5, 0.25, 0.25],
|
|
46
|
+
),
|
|
47
|
+
],
|
|
48
|
+
)
|
|
49
|
+
|
|
50
|
+
loader = DataLoader()
|
|
51
|
+
loader.add_bounding_boxes([detection])
|
|
52
|
+
|
|
53
|
+
assert len(loader.pairs) == 1
|
|
54
|
+
|
|
55
|
+
# show that three unique IOUs exist
|
|
56
|
+
unique_ious = np.unique(loader.pairs[0][:, 3])
|
|
57
|
+
assert np.isclose(
|
|
58
|
+
unique_ious, np.array([0.0, 0.12755102, 0.68067227])
|
|
59
|
+
).all()
|
|
60
|
+
|
|
61
|
+
|
|
19
62
|
def test_mixed_annotations(
|
|
20
63
|
rect1: tuple[float, float, float, float],
|
|
21
64
|
rect1_rotated_5_degrees_around_origin: tuple[float, float, float, float],
|
|
@@ -87,7 +130,15 @@ def test_mixed_annotations(
|
|
|
87
130
|
|
|
88
131
|
loader = DataLoader()
|
|
89
132
|
|
|
90
|
-
for
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
133
|
+
for detection in mixed_detections:
|
|
134
|
+
|
|
135
|
+
# anything can be converted to a bbox
|
|
136
|
+
loader.add_bounding_boxes([detection])
|
|
137
|
+
|
|
138
|
+
with pytest.raises(AttributeError) as e:
|
|
139
|
+
loader.add_polygons([detection])
|
|
140
|
+
assert "no attribute 'shape'" in str(e)
|
|
141
|
+
|
|
142
|
+
with pytest.raises(AttributeError) as e:
|
|
143
|
+
loader.add_bitmasks([detection])
|
|
144
|
+
assert "no attribute 'mask'" in str(e)
|