vislearnlabpy 0.0.3.2__tar.gz → 0.0.3.4__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.
- {vislearnlabpy-0.0.3.2/src/vislearnlabpy.egg-info → vislearnlabpy-0.0.3.4}/PKG-INFO +1 -1
- {vislearnlabpy-0.0.3.2 → vislearnlabpy-0.0.3.4}/pyproject.toml +1 -1
- {vislearnlabpy-0.0.3.2 → vislearnlabpy-0.0.3.4}/src/vislearnlabpy/drawings/svg_render_helpers.py +24 -8
- {vislearnlabpy-0.0.3.2 → vislearnlabpy-0.0.3.4}/src/vislearnlabpy/extractions/drawingtask_extractor.py +29 -13
- {vislearnlabpy-0.0.3.2 → vislearnlabpy-0.0.3.4/src/vislearnlabpy.egg-info}/PKG-INFO +1 -1
- {vislearnlabpy-0.0.3.2 → vislearnlabpy-0.0.3.4}/LICENSE +0 -0
- {vislearnlabpy-0.0.3.2 → vislearnlabpy-0.0.3.4}/README.md +0 -0
- {vislearnlabpy-0.0.3.2 → vislearnlabpy-0.0.3.4}/setup.cfg +0 -0
- {vislearnlabpy-0.0.3.2 → vislearnlabpy-0.0.3.4}/src/vislearnlabpy/__init__.py +0 -0
- {vislearnlabpy-0.0.3.2 → vislearnlabpy-0.0.3.4}/src/vislearnlabpy/drawings/drawing.py +0 -0
- {vislearnlabpy-0.0.3.2 → vislearnlabpy-0.0.3.4}/src/vislearnlabpy/embeddings/embedding_store.py +0 -0
- {vislearnlabpy-0.0.3.2 → vislearnlabpy-0.0.3.4}/src/vislearnlabpy/embeddings/generate_embeddings.py +0 -0
- {vislearnlabpy-0.0.3.2 → vislearnlabpy-0.0.3.4}/src/vislearnlabpy/embeddings/similarity_generator.py +0 -0
- {vislearnlabpy-0.0.3.2 → vislearnlabpy-0.0.3.4}/src/vislearnlabpy/embeddings/similarity_utils.py +0 -0
- {vislearnlabpy-0.0.3.2 → vislearnlabpy-0.0.3.4}/src/vislearnlabpy/embeddings/stimuli_loader.py +0 -0
- {vislearnlabpy-0.0.3.2 → vislearnlabpy-0.0.3.4}/src/vislearnlabpy/embeddings/utils.py +0 -0
- {vislearnlabpy-0.0.3.2 → vislearnlabpy-0.0.3.4}/src/vislearnlabpy/extractions/mongo_extractor.py +0 -0
- {vislearnlabpy-0.0.3.2 → vislearnlabpy-0.0.3.4}/src/vislearnlabpy/models/clip_model.py +0 -0
- {vislearnlabpy-0.0.3.2 → vislearnlabpy-0.0.3.4}/src/vislearnlabpy/models/feature_generator.py +0 -0
- {vislearnlabpy-0.0.3.2 → vislearnlabpy-0.0.3.4}/src/vislearnlabpy/models/multimodal_model.py +0 -0
- {vislearnlabpy-0.0.3.2 → vislearnlabpy-0.0.3.4}/src/vislearnlabpy.egg-info/SOURCES.txt +0 -0
- {vislearnlabpy-0.0.3.2 → vislearnlabpy-0.0.3.4}/src/vislearnlabpy.egg-info/dependency_links.txt +0 -0
- {vislearnlabpy-0.0.3.2 → vislearnlabpy-0.0.3.4}/src/vislearnlabpy.egg-info/requires.txt +0 -0
- {vislearnlabpy-0.0.3.2 → vislearnlabpy-0.0.3.4}/src/vislearnlabpy.egg-info/top_level.txt +0 -0
{vislearnlabpy-0.0.3.2 → vislearnlabpy-0.0.3.4}/src/vislearnlabpy/drawings/svg_render_helpers.py
RENAMED
|
@@ -79,9 +79,10 @@ def render_and_save(Verts,
|
|
|
79
79
|
|
|
80
80
|
'''
|
|
81
81
|
for i, verts in enumerate(Verts):
|
|
82
|
-
#
|
|
82
|
+
# Skip all but the last iteration if last_stroke_only is True
|
|
83
83
|
if last_stroke_only and i != len(Verts) - 1:
|
|
84
84
|
continue
|
|
85
|
+
|
|
85
86
|
codes = Codes[i]
|
|
86
87
|
fig = plt.figure(figsize=(stroke_settings.imsize, stroke_settings.imsize), frameon=False)
|
|
87
88
|
ax = plt.subplot(111)
|
|
@@ -97,14 +98,29 @@ def render_and_save(Verts,
|
|
|
97
98
|
hspace=0, wspace=0)
|
|
98
99
|
|
|
99
100
|
### render sketch so far
|
|
100
|
-
if
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
101
|
+
if last_stroke_only:
|
|
102
|
+
# Render all strokes for the final image
|
|
103
|
+
for stroke_idx in range(len(Verts)):
|
|
104
|
+
stroke_verts = Verts[stroke_idx]
|
|
105
|
+
stroke_codes = Codes[stroke_idx]
|
|
106
|
+
if len(stroke_verts) > 0:
|
|
107
|
+
path = Path(stroke_verts, stroke_codes)
|
|
108
|
+
patch = patches.PathPatch(path, facecolor='none',
|
|
109
|
+
edgecolor=stroke_settings.edgecolor,
|
|
110
|
+
lw=stroke_settings.line_width)
|
|
111
|
+
ax.add_patch(patch)
|
|
112
|
+
else:
|
|
113
|
+
# Render only current stroke
|
|
114
|
+
if len(verts) > 0:
|
|
115
|
+
path = Path(verts, codes)
|
|
116
|
+
patch = patches.PathPatch(path, facecolor='none',
|
|
117
|
+
edgecolor=stroke_settings.edgecolor,
|
|
118
|
+
lw=stroke_settings.line_width)
|
|
119
|
+
ax.add_patch(patch)
|
|
120
|
+
|
|
121
|
+
plt.gca().invert_yaxis() # y values increase as you go down in image
|
|
105
122
|
|
|
106
123
|
## save out as png
|
|
107
|
-
## maybe to make it not render every single thing, use plt.ioff
|
|
108
124
|
os.makedirs(save_dir, exist_ok=True)
|
|
109
125
|
if not last_stroke_only:
|
|
110
126
|
# saving stroke count and not index so i+1
|
|
@@ -112,11 +128,11 @@ def render_and_save(Verts,
|
|
|
112
128
|
else:
|
|
113
129
|
# not including stroke count in the name since we're only saving the final stroke
|
|
114
130
|
fname = f'{base_filename}.png'
|
|
131
|
+
|
|
115
132
|
filepath = os.path.join(save_dir, fname)
|
|
116
133
|
fig.savefig(filepath, bbox_inches='tight', pad_inches=0.0)
|
|
117
134
|
plt.close(fig)
|
|
118
135
|
|
|
119
|
-
|
|
120
136
|
def polyline_pathmaker(lines):
|
|
121
137
|
x = []
|
|
122
138
|
y = []
|
|
@@ -75,15 +75,15 @@ class StrokeData:
|
|
|
75
75
|
|
|
76
76
|
class DrawingsExtractor():
|
|
77
77
|
@staticmethod
|
|
78
|
-
def
|
|
79
|
-
|
|
80
|
-
return
|
|
78
|
+
def get_default_transformation_settings():
|
|
79
|
+
default_settings = ImgExtractionSettings()
|
|
80
|
+
return default_settings
|
|
81
81
|
|
|
82
82
|
@staticmethod
|
|
83
|
-
def save_transformed(imgData, fname,
|
|
84
|
-
if
|
|
85
|
-
|
|
86
|
-
|
|
83
|
+
def save_transformed(imgData, fname, transform_settings=None):
|
|
84
|
+
if transform_settings is None:
|
|
85
|
+
transform_settings = DrawingsExtractor.get_default_transformation_settings()
|
|
86
|
+
transform = ImageExtractor.get_transformations(transform_settings)
|
|
87
87
|
img_bytes = base64.b64decode(imgData)
|
|
88
88
|
img = Image.open(io.BytesIO(img_bytes))
|
|
89
89
|
img = transform(img)
|
|
@@ -99,9 +99,10 @@ class DrawingsExtractor():
|
|
|
99
99
|
return _im
|
|
100
100
|
|
|
101
101
|
@staticmethod
|
|
102
|
-
def save_transformed_file(fname,
|
|
103
|
-
if
|
|
104
|
-
|
|
102
|
+
def save_transformed_file(fname, transform_settings=None):
|
|
103
|
+
if transform_settings is None:
|
|
104
|
+
transform_settings = DrawingsExtractor.get_default_transformation()
|
|
105
|
+
transform = ImageExtractor.get_transformations(transform_settings)
|
|
105
106
|
img = Image.open(fname)
|
|
106
107
|
img = transform(img)
|
|
107
108
|
img.save(fname)
|
|
@@ -354,7 +355,7 @@ class DrawingTaskExtractor(MongoExtractor):
|
|
|
354
355
|
age_part, participant_part = self._age_participant_parts(age, participant_id, session_id)
|
|
355
356
|
return f"{category}_{extraction_type}_{age_part}{participant_part}{session_id}"
|
|
356
357
|
|
|
357
|
-
def extract_images(self, image_dir=None, imsize=224, transform_file=False, highres=False, stroke_settings=StrokeSettings(), transform_settings=None):
|
|
358
|
+
def extract_images(self, image_dir=None, imsize=224, transform_file=False, highres=False, stroke_settings=StrokeSettings(), transform_settings=None, **filters):
|
|
358
359
|
if image_dir is None:
|
|
359
360
|
image_dir = os.path.join(self.output_dir, 'sketches_full_dataset')
|
|
360
361
|
# Initialize tracking variables
|
|
@@ -365,9 +366,20 @@ class DrawingTaskExtractor(MongoExtractor):
|
|
|
365
366
|
# Initialize data storage
|
|
366
367
|
trials = []
|
|
367
368
|
query = {'dataType': 'finalImage'}
|
|
369
|
+
query.update({
|
|
370
|
+
save_format_to_field_map.get(key, key): {'$in': values}
|
|
371
|
+
for key, values in filters.items()
|
|
372
|
+
if values # only include if values is non-empty
|
|
373
|
+
})
|
|
368
374
|
# Get all sessions
|
|
369
|
-
|
|
370
|
-
|
|
375
|
+
sessions_to_render_with_cats = list(set([
|
|
376
|
+
(doc['sessionId'], doc['category'])
|
|
377
|
+
for doc in self.collection.find(self._add_date_query(query), {'sessionId': 1, 'category': 1})
|
|
378
|
+
if 'category' in doc
|
|
379
|
+
]))
|
|
380
|
+
# unprocessed sessions with categoriess to account for previous saves that don't include all categories
|
|
381
|
+
sessions_to_render = self._render_unprocessed_sessions_with_cats(f'AllDescriptives_images',
|
|
382
|
+
sessions_to_render_with_cats)
|
|
371
383
|
|
|
372
384
|
time_start = time.time()
|
|
373
385
|
|
|
@@ -392,6 +404,8 @@ class DrawingTaskExtractor(MongoExtractor):
|
|
|
392
404
|
for imrec in image_recs:
|
|
393
405
|
if 'category' not in imrec or imrec['category'] is None:
|
|
394
406
|
continue
|
|
407
|
+
if 'category' in filters and imrec['category'] not in filters['category']:
|
|
408
|
+
continue
|
|
395
409
|
participant_id_col = self._participant_id_col(imrec)
|
|
396
410
|
if participant_id_col is None:
|
|
397
411
|
logger.warning(f"Participant ID not found in image record, skipping: {imrec}")
|
|
@@ -441,6 +455,8 @@ class DrawingTaskExtractor(MongoExtractor):
|
|
|
441
455
|
stroke_settings=stroke_settings,
|
|
442
456
|
last_stroke_only=True)
|
|
443
457
|
if transform_file:
|
|
458
|
+
if transform_settings is None:
|
|
459
|
+
transform_settings = ImgExtractionSettings(resize_dim=768)
|
|
444
460
|
DrawingsExtractor.save_transformed_file(fname, transform_settings)
|
|
445
461
|
|
|
446
462
|
else:
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{vislearnlabpy-0.0.3.2 → vislearnlabpy-0.0.3.4}/src/vislearnlabpy/embeddings/embedding_store.py
RENAMED
|
File without changes
|
{vislearnlabpy-0.0.3.2 → vislearnlabpy-0.0.3.4}/src/vislearnlabpy/embeddings/generate_embeddings.py
RENAMED
|
File without changes
|
{vislearnlabpy-0.0.3.2 → vislearnlabpy-0.0.3.4}/src/vislearnlabpy/embeddings/similarity_generator.py
RENAMED
|
File without changes
|
{vislearnlabpy-0.0.3.2 → vislearnlabpy-0.0.3.4}/src/vislearnlabpy/embeddings/similarity_utils.py
RENAMED
|
File without changes
|
{vislearnlabpy-0.0.3.2 → vislearnlabpy-0.0.3.4}/src/vislearnlabpy/embeddings/stimuli_loader.py
RENAMED
|
File without changes
|
|
File without changes
|
{vislearnlabpy-0.0.3.2 → vislearnlabpy-0.0.3.4}/src/vislearnlabpy/extractions/mongo_extractor.py
RENAMED
|
File without changes
|
|
File without changes
|
{vislearnlabpy-0.0.3.2 → vislearnlabpy-0.0.3.4}/src/vislearnlabpy/models/feature_generator.py
RENAMED
|
File without changes
|
{vislearnlabpy-0.0.3.2 → vislearnlabpy-0.0.3.4}/src/vislearnlabpy/models/multimodal_model.py
RENAMED
|
File without changes
|
|
File without changes
|
{vislearnlabpy-0.0.3.2 → vislearnlabpy-0.0.3.4}/src/vislearnlabpy.egg-info/dependency_links.txt
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|