cat-llm 0.0.22__tar.gz → 0.0.24__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.
- {cat_llm-0.0.22 → cat_llm-0.0.24}/PKG-INFO +1 -1
- {cat_llm-0.0.22 → cat_llm-0.0.24}/src/catllm/CERAD_functions.py +15 -7
- {cat_llm-0.0.22 → cat_llm-0.0.24}/src/catllm/__about__.py +1 -1
- {cat_llm-0.0.22 → cat_llm-0.0.24}/src/catllm/__init__.py +1 -1
- {cat_llm-0.0.22 → cat_llm-0.0.24}/src/catllm/cat_llm.py +3 -3
- {cat_llm-0.0.22 → cat_llm-0.0.24}/LICENSE +0 -0
- {cat_llm-0.0.22 → cat_llm-0.0.24}/README.md +0 -0
- {cat_llm-0.0.22 → cat_llm-0.0.24}/pyproject.toml +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: cat-llm
|
|
3
|
-
Version: 0.0.
|
|
3
|
+
Version: 0.0.24
|
|
4
4
|
Summary: A tool for categorizing text data and images using LLMs and vision models
|
|
5
5
|
Project-URL: Documentation, https://github.com/chrissoria/cat-llm#readme
|
|
6
6
|
Project-URL: Issues, https://github.com/chrissoria/cat-llm/issues
|
|
@@ -1,10 +1,13 @@
|
|
|
1
|
-
#
|
|
2
|
-
|
|
1
|
+
# a function specifically for CERAD Constructional Praxis test
|
|
2
|
+
# specifically for pictures of drawings of shapes like circles, diamonds, rectangles, and cubes
|
|
3
|
+
def cerad_drawn_score(
|
|
3
4
|
shape,
|
|
4
5
|
image_input,
|
|
5
6
|
api_key,
|
|
6
7
|
user_model="gpt-4o-2024-11-20",
|
|
7
8
|
creativity=0,
|
|
9
|
+
reference_in_image=False,
|
|
10
|
+
provide_reference=False,
|
|
8
11
|
safety=False,
|
|
9
12
|
filename="categorized_data.csv",
|
|
10
13
|
model_source="OpenAI"
|
|
@@ -21,7 +24,7 @@ def cerad_score(
|
|
|
21
24
|
shape = shape.lower()
|
|
22
25
|
|
|
23
26
|
if shape == "circle":
|
|
24
|
-
categories = ["
|
|
27
|
+
categories = ["The image contains a drawing that clearly represents a circle",
|
|
25
28
|
"The drawing does not resemble a circle",
|
|
26
29
|
"The drawing resembles a circle",
|
|
27
30
|
"The circle is closed",
|
|
@@ -30,7 +33,7 @@ def cerad_score(
|
|
|
30
33
|
"The circle is almost circular",
|
|
31
34
|
"None of the above descriptions apply"]
|
|
32
35
|
elif shape == "diamond":
|
|
33
|
-
categories = ["
|
|
36
|
+
categories = ["The image contains a drawing that clearly represents a diamond shape",
|
|
34
37
|
"It has a drawing of a square",
|
|
35
38
|
"A drawn shape DOES NOT resemble a diamond",
|
|
36
39
|
"A drawn shape resembles a diamond",
|
|
@@ -39,7 +42,7 @@ def cerad_score(
|
|
|
39
42
|
"If a diamond is drawn it's more elaborate than a simple diamond (such as overlapping diamonds or a diamond with an extras lines inside)",
|
|
40
43
|
"None of the above descriptions apply"]
|
|
41
44
|
elif shape == "rectangles" or shape == "overlapping rectangles":
|
|
42
|
-
categories = ["
|
|
45
|
+
categories = ["The image contains a drawing that clearly represents overlapping rectangles",
|
|
43
46
|
"A drawn shape DOES NOT resemble a overlapping rectangles",
|
|
44
47
|
"A drawn shape resembles a overlapping rectangles",
|
|
45
48
|
"Rectangle 1 has 4 sides",
|
|
@@ -87,7 +90,7 @@ def cerad_score(
|
|
|
87
90
|
link1 = []
|
|
88
91
|
extracted_jsons = []
|
|
89
92
|
|
|
90
|
-
for i, img_path in enumerate(tqdm(image_files, desc="
|
|
93
|
+
for i, img_path in enumerate(tqdm(image_files, desc="Scoring images"), start=0):
|
|
91
94
|
# Check validity first
|
|
92
95
|
if img_path is None or not os.path.exists(img_path):
|
|
93
96
|
link1.append("Skipped NaN input or invalid path")
|
|
@@ -101,6 +104,11 @@ def cerad_score(
|
|
|
101
104
|
# Handle extension safely
|
|
102
105
|
ext = Path(img_path).suffix.lstrip(".").lower()
|
|
103
106
|
encoded_image = f"data:image/{ext};base64,{encoded}"
|
|
107
|
+
|
|
108
|
+
if reference_in_image:
|
|
109
|
+
reference_text = f"This image contains a perfect reference image of a {shape}. Next to is a drawing that is meant to be similar to the reference {shape}.\n\n"
|
|
110
|
+
else:
|
|
111
|
+
reference_text = f"Image is expected to show within it a drawing of a {shape}.\n\n"
|
|
104
112
|
|
|
105
113
|
prompt = [
|
|
106
114
|
{
|
|
@@ -109,7 +117,7 @@ def cerad_score(
|
|
|
109
117
|
f"You are an image-tagging assistant trained in the CERAD Constructional Praxis test.\n"
|
|
110
118
|
f"Task ► Examine the attached image and decide, **for each category below**, "
|
|
111
119
|
f"whether it is PRESENT (1) or NOT PRESENT (0).\n\n"
|
|
112
|
-
f"
|
|
120
|
+
f"{reference_text}"
|
|
113
121
|
f"Categories:\n{categories_str}\n\n"
|
|
114
122
|
f"Output format ► Respond with **only** a JSON object whose keys are the "
|
|
115
123
|
f"quoted category numbers ('1', '2', …) and whose values are 1 or 0. "
|
|
@@ -1094,7 +1094,7 @@ def cerad_score(
|
|
|
1094
1094
|
shape = shape.lower()
|
|
1095
1095
|
|
|
1096
1096
|
if shape == "circle":
|
|
1097
|
-
categories = ["
|
|
1097
|
+
categories = ["The image contains a drawing that clearly represents a circle",
|
|
1098
1098
|
"The drawing does not resemble a circle",
|
|
1099
1099
|
"The drawing resembles a circle",
|
|
1100
1100
|
"The circle is closed",
|
|
@@ -1103,7 +1103,7 @@ def cerad_score(
|
|
|
1103
1103
|
"The circle is almost circular",
|
|
1104
1104
|
"None of the above descriptions apply"]
|
|
1105
1105
|
elif shape == "diamond":
|
|
1106
|
-
categories = ["
|
|
1106
|
+
categories = ["The image contains a drawing that clearly represents a diamond shape",
|
|
1107
1107
|
"It has a drawing of a square",
|
|
1108
1108
|
"A drawn shape DOES NOT resemble a diamond",
|
|
1109
1109
|
"A drawn shape resembles a diamond",
|
|
@@ -1112,7 +1112,7 @@ def cerad_score(
|
|
|
1112
1112
|
"If a diamond is drawn it's more elaborate than a simple diamond (such as overlapping diamonds or a diamond with an extras lines inside)",
|
|
1113
1113
|
"None of the above descriptions apply"]
|
|
1114
1114
|
elif shape == "rectangles" or shape == "overlapping rectangles":
|
|
1115
|
-
categories = ["
|
|
1115
|
+
categories = ["The image contains a drawing that clearly represents overlapping rectangles",
|
|
1116
1116
|
"A drawn shape DOES NOT resemble a overlapping rectangles",
|
|
1117
1117
|
"A drawn shape resembles a overlapping rectangles",
|
|
1118
1118
|
"Rectangle 1 has 4 sides",
|
|
File without changes
|
|
File without changes
|
|
File without changes
|