imagebaker 0.0.4__py3-none-any.whl → 0.0.46__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.
- imagebaker/core/__init__.py +0 -0
- imagebaker/core/configs/__init__.py +1 -0
- imagebaker/core/configs/configs.py +156 -0
- imagebaker/core/defs/__init__.py +1 -0
- imagebaker/core/defs/defs.py +258 -0
- imagebaker/core/plugins/__init__.py +0 -0
- imagebaker/core/plugins/base_plugin.py +39 -0
- imagebaker/core/plugins/cosine_plugin.py +39 -0
- imagebaker/layers/__init__.py +3 -0
- imagebaker/layers/annotable_layer.py +847 -0
- imagebaker/layers/base_layer.py +724 -0
- imagebaker/layers/canvas_layer.py +1007 -0
- imagebaker/list_views/__init__.py +3 -0
- imagebaker/list_views/annotation_list.py +203 -0
- imagebaker/list_views/canvas_list.py +185 -0
- imagebaker/list_views/image_list.py +138 -0
- imagebaker/list_views/layer_list.py +390 -0
- imagebaker/list_views/layer_settings.py +219 -0
- imagebaker/models/__init__.py +0 -0
- imagebaker/models/base_model.py +150 -0
- imagebaker/tabs/__init__.py +2 -0
- imagebaker/tabs/baker_tab.py +496 -0
- imagebaker/tabs/layerify_tab.py +837 -0
- imagebaker/utils/__init__.py +0 -0
- imagebaker/utils/image.py +105 -0
- imagebaker/utils/state_utils.py +92 -0
- imagebaker/utils/transform_mask.py +107 -0
- imagebaker/window/__init__.py +1 -0
- imagebaker/window/app.py +136 -0
- imagebaker/window/main_window.py +181 -0
- imagebaker/workers/__init__.py +3 -0
- imagebaker/workers/baker_worker.py +247 -0
- imagebaker/workers/layerify_worker.py +91 -0
- imagebaker/workers/model_worker.py +54 -0
- {imagebaker-0.0.4.dist-info → imagebaker-0.0.46.dist-info}/METADATA +63 -27
- imagebaker-0.0.46.dist-info/RECORD +41 -0
- {imagebaker-0.0.4.dist-info → imagebaker-0.0.46.dist-info}/WHEEL +1 -1
- imagebaker-0.0.4.dist-info/RECORD +0 -7
- {imagebaker-0.0.4.dist-info/licenses → imagebaker-0.0.46.dist-info}/LICENSE +0 -0
- {imagebaker-0.0.4.dist-info → imagebaker-0.0.46.dist-info}/entry_points.txt +0 -0
- {imagebaker-0.0.4.dist-info → imagebaker-0.0.46.dist-info}/top_level.txt +0 -0
@@ -0,0 +1,247 @@
|
|
1
|
+
from PySide6.QtGui import QImage, QPainter, QTransform, QPolygonF, QPen, QPixmap
|
2
|
+
from PySide6.QtCore import (
|
3
|
+
Qt,
|
4
|
+
QPoint,
|
5
|
+
QPointF,
|
6
|
+
Signal,
|
7
|
+
QRectF,
|
8
|
+
QObject,
|
9
|
+
)
|
10
|
+
import sys
|
11
|
+
from pathlib import Path
|
12
|
+
|
13
|
+
from imagebaker.core.defs.defs import BakingResult, Annotation, LayerState
|
14
|
+
from imagebaker.utils.transform_mask import mask_to_polygons, mask_to_rectangles
|
15
|
+
from imagebaker import logger
|
16
|
+
from imagebaker.utils.image import qpixmap_to_numpy
|
17
|
+
|
18
|
+
|
19
|
+
class BakerWorker(QObject):
|
20
|
+
finished = Signal(list) # Emit a list of BakingResult objects
|
21
|
+
error = Signal(str)
|
22
|
+
|
23
|
+
def __init__(
|
24
|
+
self,
|
25
|
+
states: dict[int, list["LayerState"]],
|
26
|
+
layers: list["Layer"],
|
27
|
+
filename: Path,
|
28
|
+
):
|
29
|
+
"""
|
30
|
+
Worker to bake the images and masks for a given set of states.
|
31
|
+
|
32
|
+
Args:
|
33
|
+
states: Dictionary of step -> list of LayerState objects
|
34
|
+
layers: List of Layer objects
|
35
|
+
filename: Path to the output file
|
36
|
+
"""
|
37
|
+
super().__init__()
|
38
|
+
self.states = states # Dictionary of step -> list of states
|
39
|
+
self.layers = layers
|
40
|
+
self.filename = filename
|
41
|
+
|
42
|
+
def process(self):
|
43
|
+
results = []
|
44
|
+
try:
|
45
|
+
for step, states in sorted(self.states.items()):
|
46
|
+
logger.info(f"Processing step {step}")
|
47
|
+
|
48
|
+
# Calculate bounding box for all layers in this step
|
49
|
+
top_left = QPointF(sys.maxsize, sys.maxsize)
|
50
|
+
bottom_right = QPointF(-sys.maxsize, -sys.maxsize)
|
51
|
+
|
52
|
+
for state in states:
|
53
|
+
layer = self._get_layer(state.layer_id)
|
54
|
+
if layer and layer.visible and not layer.image.isNull():
|
55
|
+
layer.layer_state = state
|
56
|
+
layer.update()
|
57
|
+
|
58
|
+
transform = QTransform()
|
59
|
+
transform.translate(layer.position.x(), layer.position.y())
|
60
|
+
transform.rotate(layer.rotation)
|
61
|
+
transform.scale(layer.scale_x, layer.scale_y)
|
62
|
+
|
63
|
+
original_rect = QRectF(QPointF(0, 0), layer.image.size())
|
64
|
+
transformed_rect = transform.mapRect(original_rect)
|
65
|
+
|
66
|
+
top_left.setX(min(top_left.x(), transformed_rect.left()))
|
67
|
+
top_left.setY(min(top_left.y(), transformed_rect.top()))
|
68
|
+
bottom_right.setX(
|
69
|
+
max(bottom_right.x(), transformed_rect.right())
|
70
|
+
)
|
71
|
+
bottom_right.setY(
|
72
|
+
max(bottom_right.y(), transformed_rect.bottom())
|
73
|
+
)
|
74
|
+
|
75
|
+
# Create the output image for this step
|
76
|
+
width = int(bottom_right.x() - top_left.x())
|
77
|
+
height = int(bottom_right.y() - top_left.y())
|
78
|
+
if width <= 0 or height <= 0:
|
79
|
+
continue
|
80
|
+
|
81
|
+
image = QImage(width, height, QImage.Format_ARGB32)
|
82
|
+
image.fill(Qt.transparent)
|
83
|
+
masks = []
|
84
|
+
mask_names = []
|
85
|
+
new_annotations = []
|
86
|
+
|
87
|
+
painter = QPainter(image)
|
88
|
+
try:
|
89
|
+
painter.setRenderHints(
|
90
|
+
QPainter.Antialiasing | QPainter.SmoothPixmapTransform
|
91
|
+
)
|
92
|
+
for state in states:
|
93
|
+
layer = self._get_layer(state.layer_id)
|
94
|
+
|
95
|
+
if layer and layer.visible and not layer.image.isNull():
|
96
|
+
# Draw the layer image with transformations
|
97
|
+
painter.save()
|
98
|
+
try:
|
99
|
+
painter.translate(layer.position - top_left)
|
100
|
+
painter.rotate(layer.rotation)
|
101
|
+
painter.scale(layer.scale_x, layer.scale_y)
|
102
|
+
pixmap_with_alpha = QPixmap(layer.image.size())
|
103
|
+
pixmap_with_alpha.fill(Qt.transparent)
|
104
|
+
|
105
|
+
temp_painter = QPainter(pixmap_with_alpha)
|
106
|
+
try:
|
107
|
+
opacity = layer.opacity / 255.0
|
108
|
+
temp_painter.setOpacity(opacity)
|
109
|
+
temp_painter.drawPixmap(0, 0, layer.image)
|
110
|
+
finally:
|
111
|
+
temp_painter.end()
|
112
|
+
|
113
|
+
painter.drawPixmap(0, 0, pixmap_with_alpha)
|
114
|
+
finally:
|
115
|
+
painter.restore()
|
116
|
+
|
117
|
+
# Draw the drawing states
|
118
|
+
if state.drawing_states:
|
119
|
+
painter.save()
|
120
|
+
try:
|
121
|
+
painter.translate(layer.position - top_left)
|
122
|
+
painter.rotate(layer.rotation)
|
123
|
+
painter.scale(layer.scale_x, layer.scale_y)
|
124
|
+
for drawing_state in state.drawing_states:
|
125
|
+
painter.setPen(
|
126
|
+
QPen(
|
127
|
+
drawing_state.color,
|
128
|
+
drawing_state.size,
|
129
|
+
Qt.SolidLine,
|
130
|
+
Qt.RoundCap,
|
131
|
+
Qt.RoundJoin,
|
132
|
+
)
|
133
|
+
)
|
134
|
+
painter.drawPoint(
|
135
|
+
drawing_state.position - top_left
|
136
|
+
)
|
137
|
+
finally:
|
138
|
+
painter.restore()
|
139
|
+
|
140
|
+
# Generate the layer mask
|
141
|
+
layer_mask = QImage(width, height, QImage.Format_ARGB32)
|
142
|
+
layer_mask.fill(Qt.transparent)
|
143
|
+
mask_painter = QPainter(layer_mask)
|
144
|
+
try:
|
145
|
+
mask_painter.setRenderHints(
|
146
|
+
QPainter.Antialiasing
|
147
|
+
| QPainter.SmoothPixmapTransform
|
148
|
+
)
|
149
|
+
mask_painter.translate(layer.position - top_left)
|
150
|
+
mask_painter.rotate(layer.rotation)
|
151
|
+
mask_painter.scale(layer.scale_x, layer.scale_y)
|
152
|
+
mask_painter.drawPixmap(QPoint(0, 0), layer.image)
|
153
|
+
|
154
|
+
if state.drawing_states:
|
155
|
+
mask_painter.save()
|
156
|
+
try:
|
157
|
+
for drawing_state in state.drawing_states:
|
158
|
+
mask_painter.setPen(
|
159
|
+
QPen(
|
160
|
+
Qt.black,
|
161
|
+
drawing_state.size,
|
162
|
+
Qt.SolidLine,
|
163
|
+
Qt.RoundCap,
|
164
|
+
Qt.RoundJoin,
|
165
|
+
)
|
166
|
+
)
|
167
|
+
mask_painter.drawPoint(
|
168
|
+
drawing_state.position
|
169
|
+
)
|
170
|
+
finally:
|
171
|
+
mask_painter.restore()
|
172
|
+
finally:
|
173
|
+
mask_painter.end()
|
174
|
+
|
175
|
+
# Convert mask to 8-bit
|
176
|
+
mask_arr = qpixmap_to_numpy(layer_mask)
|
177
|
+
alpha_channel = mask_arr[:, :, 3].copy() # Extract alpha
|
178
|
+
|
179
|
+
# Binarize the mask (0 or 255)
|
180
|
+
alpha_channel[alpha_channel > 0] = 255
|
181
|
+
|
182
|
+
masks.append(alpha_channel)
|
183
|
+
mask_names.append(layer.layer_name)
|
184
|
+
|
185
|
+
# Generate annotations
|
186
|
+
if layer.allow_annotation_export:
|
187
|
+
ann: Annotation = layer.annotations[0]
|
188
|
+
new_annotation = self._generate_annotation(
|
189
|
+
ann, alpha_channel
|
190
|
+
)
|
191
|
+
new_annotations.append(new_annotation)
|
192
|
+
finally:
|
193
|
+
painter.end()
|
194
|
+
|
195
|
+
# Save the image
|
196
|
+
filename = self.filename.parent / f"{self.filename.stem}_{step}.png"
|
197
|
+
|
198
|
+
# Append the result
|
199
|
+
results.append(
|
200
|
+
BakingResult(
|
201
|
+
filename=filename,
|
202
|
+
step=step,
|
203
|
+
image=image,
|
204
|
+
masks=masks,
|
205
|
+
mask_names=mask_names,
|
206
|
+
annotations=new_annotations,
|
207
|
+
)
|
208
|
+
)
|
209
|
+
|
210
|
+
# Emit all results
|
211
|
+
self.finished.emit(results)
|
212
|
+
|
213
|
+
except Exception as e:
|
214
|
+
logger.error(f"Error in BakerWorker: {e}")
|
215
|
+
self.error.emit(str(e))
|
216
|
+
traceback.print_exc()
|
217
|
+
|
218
|
+
def _get_layer(self, layer_id):
|
219
|
+
for layer in self.layers:
|
220
|
+
if layer.layer_id == layer_id:
|
221
|
+
return layer
|
222
|
+
return None
|
223
|
+
|
224
|
+
def _generate_annotation(self, ann: Annotation, alpha_channel):
|
225
|
+
"""Generate an annotation based on the alpha channel."""
|
226
|
+
new_annotation = Annotation(
|
227
|
+
label=ann.label,
|
228
|
+
color=ann.color,
|
229
|
+
annotation_id=ann.annotation_id,
|
230
|
+
is_complete=True,
|
231
|
+
visible=True,
|
232
|
+
)
|
233
|
+
|
234
|
+
if ann.points:
|
235
|
+
new_annotation.points = ann.points
|
236
|
+
elif ann.rectangle:
|
237
|
+
xywhs = mask_to_rectangles(alpha_channel, merge_rectangles=True)
|
238
|
+
new_annotation.rectangle = QRectF(
|
239
|
+
xywhs[0][0], xywhs[0][1], xywhs[0][2], xywhs[0][3]
|
240
|
+
)
|
241
|
+
elif ann.polygon:
|
242
|
+
polygon = mask_to_polygons(alpha_channel, merge_polygons=True)
|
243
|
+
poly = QPolygonF([QPointF(p[0], p[1]) for p in polygon[0]])
|
244
|
+
new_annotation.polygon = poly
|
245
|
+
else:
|
246
|
+
logger.info("No annotation found")
|
247
|
+
return new_annotation
|
@@ -0,0 +1,91 @@
|
|
1
|
+
from PySide6.QtCore import (
|
2
|
+
Qt,
|
3
|
+
Signal,
|
4
|
+
QObject,
|
5
|
+
)
|
6
|
+
from PySide6.QtGui import (
|
7
|
+
QColor,
|
8
|
+
QPixmap,
|
9
|
+
QPainter,
|
10
|
+
QImage,
|
11
|
+
)
|
12
|
+
|
13
|
+
|
14
|
+
from imagebaker.core.defs import Annotation
|
15
|
+
from imagebaker import logger
|
16
|
+
|
17
|
+
|
18
|
+
class LayerifyWorker(QObject):
|
19
|
+
finished = Signal(Annotation, QPixmap)
|
20
|
+
error = Signal(str)
|
21
|
+
|
22
|
+
def __init__(self, image, annotations, config):
|
23
|
+
"""
|
24
|
+
Worker to layerify an image based on annotations.
|
25
|
+
|
26
|
+
Args:
|
27
|
+
image (QPixmap): Image to layerify.
|
28
|
+
annotations (List[Annotation]): List of annotations to layerify.
|
29
|
+
config (Config): Config object containing settings.
|
30
|
+
"""
|
31
|
+
super().__init__()
|
32
|
+
self.image = image.copy()
|
33
|
+
self.annotations = annotations
|
34
|
+
self.config = config
|
35
|
+
|
36
|
+
def process(self):
|
37
|
+
try:
|
38
|
+
for annotation in self.annotations:
|
39
|
+
logger.info(f"Layerifying annotation {annotation}")
|
40
|
+
if annotation.rectangle:
|
41
|
+
cropped_image = self.image.copy(annotation.rectangle.toRect())
|
42
|
+
elif annotation.polygon:
|
43
|
+
# Get bounding box and crop
|
44
|
+
bounding_rect = annotation.polygon.boundingRect().toRect()
|
45
|
+
cropped_pixmap = self.image.copy(bounding_rect)
|
46
|
+
|
47
|
+
# Convert to ARGB32 format to ensure alpha channel support
|
48
|
+
cropped_image = cropped_pixmap.toImage().convertToFormat(
|
49
|
+
QImage.Format_ARGB32
|
50
|
+
)
|
51
|
+
|
52
|
+
# Create mask with sharp edges
|
53
|
+
mask = QImage(cropped_image.size(), QImage.Format_ARGB32)
|
54
|
+
mask.fill(Qt.transparent)
|
55
|
+
|
56
|
+
# Translate polygon coordinates
|
57
|
+
translated_poly = annotation.polygon.translated(
|
58
|
+
-bounding_rect.topLeft()
|
59
|
+
)
|
60
|
+
|
61
|
+
# Draw mask without anti-aliasing
|
62
|
+
painter = QPainter(mask)
|
63
|
+
painter.setRenderHint(QPainter.Antialiasing, False)
|
64
|
+
painter.setBrush(QColor(255, 255, 255, 255)) # Opaque white
|
65
|
+
painter.setPen(Qt.NoPen)
|
66
|
+
painter.drawPolygon(translated_poly)
|
67
|
+
painter.end()
|
68
|
+
|
69
|
+
# Apply mask to image
|
70
|
+
for y in range(cropped_image.height()):
|
71
|
+
for x in range(cropped_image.width()):
|
72
|
+
mask_alpha = mask.pixelColor(x, y).alpha()
|
73
|
+
color = cropped_image.pixelColor(x, y)
|
74
|
+
|
75
|
+
# Set alpha to 0 outside polygon, 255 inside
|
76
|
+
color.setAlpha(255 if mask_alpha > 0 else 0)
|
77
|
+
cropped_image.setPixelColor(x, y, color)
|
78
|
+
|
79
|
+
# Convert back to pixmap with proper alpha
|
80
|
+
cropped_image = QPixmap.fromImage(cropped_image)
|
81
|
+
else:
|
82
|
+
cropped_image = self.image
|
83
|
+
|
84
|
+
self.finished.emit(annotation, cropped_image)
|
85
|
+
|
86
|
+
except Exception as e:
|
87
|
+
print(e)
|
88
|
+
import traceback
|
89
|
+
|
90
|
+
traceback.print_exc()
|
91
|
+
self.error.emit(str(e))
|
@@ -0,0 +1,54 @@
|
|
1
|
+
from imagebaker import logger
|
2
|
+
from imagebaker.models.base_model import BaseModel
|
3
|
+
from PySide6.QtCore import QObject, Signal
|
4
|
+
import numpy as np
|
5
|
+
import traceback
|
6
|
+
|
7
|
+
|
8
|
+
class ModelPredictionWorker(QObject):
|
9
|
+
finished = Signal(list)
|
10
|
+
error = Signal(str)
|
11
|
+
|
12
|
+
def __init__(
|
13
|
+
self,
|
14
|
+
model: BaseModel,
|
15
|
+
image: np.ndarray,
|
16
|
+
points: list[int],
|
17
|
+
polygons: list[list[int]],
|
18
|
+
rectangles: list[list[int]],
|
19
|
+
label_hints: list[int],
|
20
|
+
):
|
21
|
+
"""
|
22
|
+
A worker that runs the model prediction in a separate thread.
|
23
|
+
|
24
|
+
Args:
|
25
|
+
model (BaseModel): The model to use for prediction.
|
26
|
+
image (np.ndarray): The image to predict on.
|
27
|
+
points (list[int]): The points to predict on.
|
28
|
+
polygons (list[list[int]]): The polygons to predict on.
|
29
|
+
rectangles (list[list[int]]): The rectangles to predict on.
|
30
|
+
label_hints (list[int]): The label hints to use.
|
31
|
+
"""
|
32
|
+
super().__init__()
|
33
|
+
self.model = model
|
34
|
+
self.image = image
|
35
|
+
self.points = points
|
36
|
+
self.polygons = polygons
|
37
|
+
self.rectangles = rectangles
|
38
|
+
self.label_hints = label_hints
|
39
|
+
|
40
|
+
def process(self):
|
41
|
+
try:
|
42
|
+
result = self.model.predict(
|
43
|
+
self.image,
|
44
|
+
self.points,
|
45
|
+
self.rectangles,
|
46
|
+
self.polygons,
|
47
|
+
self.label_hints,
|
48
|
+
)
|
49
|
+
self.finished.emit(result)
|
50
|
+
except Exception as e:
|
51
|
+
self.error.emit(str(e))
|
52
|
+
traceback.print_exc()
|
53
|
+
logger.error(f"Model error: {e}")
|
54
|
+
return
|
@@ -1,10 +1,11 @@
|
|
1
|
-
Metadata-Version: 2.
|
1
|
+
Metadata-Version: 2.1
|
2
2
|
Name: imagebaker
|
3
|
-
Version: 0.0.
|
3
|
+
Version: 0.0.46
|
4
4
|
Summary: A package for baking images.
|
5
|
-
|
5
|
+
Home-page: https://github.com/q-viper/Image-Baker
|
6
|
+
Author: Ramkrishna Acharya
|
7
|
+
Author-email: qramkrishna@gmail.com
|
6
8
|
License: MIT
|
7
|
-
Project-URL: Homepage, https://github.com/q-viper/Image-Baker
|
8
9
|
Classifier: Programming Language :: Python :: 3
|
9
10
|
Classifier: License :: OSI Approved :: MIT License
|
10
11
|
Classifier: Operating System :: OS Independent
|
@@ -26,9 +27,22 @@ Requires-Dist: mkdocs-material>=9.0; extra == "docs"
|
|
26
27
|
Requires-Dist: mkdocstrings[python]>=0.21; extra == "docs"
|
27
28
|
Requires-Dist: pymdown-extensions>=8.0; extra == "docs"
|
28
29
|
Requires-Dist: mkdocs-awesome-pages-plugin; extra == "docs"
|
29
|
-
Dynamic: license-file
|
30
30
|
|
31
31
|
# Image-Baker
|
32
|
+

|
33
|
+

|
34
|
+

|
35
|
+

|
36
|
+
<!--  -->
|
37
|
+

|
38
|
+
|
39
|
+
|
40
|
+
<p align="center">
|
41
|
+
<img src="assets/demo.gif" alt="Centered Demo" />
|
42
|
+
</p>
|
43
|
+
|
44
|
+
|
45
|
+
*An example of baked images. (Each object is a layer and an annotation will also be extracted for all layers.)*
|
32
46
|
|
33
47
|
Let's bake an image.
|
34
48
|
|
@@ -37,15 +51,12 @@ Let's bake an image.
|
|
37
51
|
When training computer vision models (especially for detection and segmentation), labeling large amounts of data is crucial for better model performance. Often, the process involves multiple cycles of labeling, training, and evaluation. By generating multiple realistic labeled datasets from a single image, the time spent on labeling can be significantly reduced.
|
38
52
|
|
39
53
|
## What's up with the name?
|
40
|
-
|
41
|
-
The concept involves extracting portions of an image (e.g., objects of interest) using tools like polygons or models such as Segment Anything. These extractions are treated as layers, which can then be copied, pasted, and manipulated to create multiple instances of the desired object. By combining these layers step by step, a new labeled image with annotations in JSON format is created. The term "Baking" refers to the process of merging these layers into a single cohesive image.
|
54
|
+
The concept involves extracting portions of an image (e.g., objects of interest) using tools like polygons or models such as Segment Anything. These extractions are treated as layers, which can then be copied, pasted, and manipulated to create multiple instances of the desired object. By combining these layers step by step, a new labeled image with annotations in JSON format is created. The term "baking" refers to the process of merging these layers into a single cohesive image.
|
42
55
|
|
43
56
|
## Getting Started
|
44
|
-
|
45
57
|
### Installation
|
46
|
-
|
47
58
|
#### Using PIP
|
48
|
-
This project is also available
|
59
|
+
This project is also available on the PyPI server.
|
49
60
|
|
50
61
|
```bash
|
51
62
|
pip install imagebaker
|
@@ -61,25 +72,29 @@ pip install -e .
|
|
61
72
|
```
|
62
73
|
|
63
74
|
### First Run
|
64
|
-
|
65
75
|
Run the following command to launch the GUI:
|
66
76
|
|
67
|
-
|
68
|
-
imagebaker
|
69
|
-
```
|
77
|
+
`imagebaker`
|
70
78
|
|
71
|
-
|
79
|
+
By default, the above command will not run any models on the backend. So please take a look into the example of model definition at [examples/loaded_models.py](examples/loaded_models.py). Then we need to pass it as:
|
72
80
|
|
73
|
-
|
74
|
-
python examples/app.py
|
75
|
-
```
|
81
|
+
`imagebaker --models-file examples/loaded_models.py`
|
76
82
|
|
77
|
-
|
83
|
+
For more options, please do: `imagebaker --help` It should give the following options.
|
84
|
+
|
85
|
+

|
86
|
+
|
87
|
+
|
88
|
+
* **`--configs-file`** allows us to define custom configs. The custom configs have to inherit LayerConfig and CanvasConfig defined at [imagebaker/core/configs/configs.py](imagebaker/core/configs/configs.py). An example is available at [examples](examples/).
|
78
89
|
|
90
|
+
After cloning and going to the project directory, the following code should work.
|
91
|
+
`imagebaker --models-file examples/loaded_models.py --configs-file examples/example_config.py`
|
92
|
+
|
93
|
+
## Features
|
79
94
|
- **Annotating Images**: Load a folder of images and annotate them using bounding boxes or polygons.
|
80
95
|
- **Model Testing**: Define models for detection, segmentation, and prompts (e.g., points or rectangles) by following the base model structure in [imagebaker/models/base_model.py](imagebaker/models/base_model.py). See [examples/loaded_models.py](examples/loaded_models.py) for a working example.
|
81
96
|
- **Layerifying**: Crop images based on annotations to create reusable layers. Each cropped image represents a single layer.
|
82
|
-
- **Baking States**: Arrange layers to create image variations by dragging, rotating, adjusting opacity, and more. Save the state using the
|
97
|
+
- **Baking States**: Arrange layers to create image variations by dragging, rotating, adjusting opacity, and more. Save the state using the Save State button or Ctrl + S.
|
83
98
|
- **Playing States**: Replay saved states, export them locally, or use them for further predictions.
|
84
99
|
- **Exporting States**: Export the final annotated JSON and the baked multilayer image.
|
85
100
|
|
@@ -89,29 +104,50 @@ python examples/app.py
|
|
89
104
|
* **Delete**: Delete selected annotation/layer.
|
90
105
|
* **Left Click**: Select an annotation/layer on mouse position.
|
91
106
|
* **Left Click + Drag**: Drag a selected annotation/layer.
|
92
|
-
* **Double Left Click**: When using
|
93
|
-
* **Right Click**: Deselect an annotation/layer. While
|
94
|
-
* **Ctrl + Mouse Wheel**: Zoom In/Out on the mouse position i.e
|
107
|
+
* **Double Left Click**: When using polygon annotation, completes the polygon.
|
108
|
+
* **Right Click**: Deselect an annotation/layer. While annotating the polygon, undo the last point.
|
109
|
+
* **Ctrl + Mouse Wheel**: Zoom In/Out on the mouse position, i.e., resize the viewport.
|
95
110
|
* **Ctrl + Drag**: If done on the background, the viewport is panned.
|
96
111
|
* **Ctrl + S**: Save State on Baker Tab.
|
97
112
|
* **Ctrl + D**: Draw Mode on Baker Tab. Drawing can happen on a selected or main layer.
|
98
113
|
* **Ctrl + E**: Erase Mode on Baker Tab.
|
99
|
-
* **Wheel**: Change size of the drawing pointer.
|
100
|
-
|
114
|
+
* **Wheel**: Change the size of the drawing pointer.
|
101
115
|
|
102
116
|
## Demo
|
117
|
+
### Annotation Page
|
118
|
+
This is where the loading of the image folder and annotation, connection with the model running in the backend, and layerifying happen.
|
103
119
|
|
104
|
-
|
120
|
+

|
121
|
+
|
122
|
+
### Baker Page
|
123
|
+
This is where the layer baking happens. And the extraction of the layers as well.
|
124
|
+
|
125
|
+

|
126
|
+
|
127
|
+
An example of drawing:
|
128
|
+
|
129
|
+

|
130
|
+
|
131
|
+
### Annotated
|
132
|
+
|
133
|
+
The JSON and the baked image will be exported to the local folder, and in debug mode, the annotations and the mask for each layer will be exported too.
|
134
|
+
|
135
|
+

|
136
|
+
|
137
|
+
### Demo Video
|
105
138
|
|
106
139
|
To see the tool in action, check out the demo video below:
|
107
140
|
|
141
|
+
|
108
142
|
[](https://youtu.be/WckMT0r-2Lc)
|
109
143
|
|
144
|
+
|
110
145
|
Click on the image above to play the video on YouTube.
|
111
146
|
|
112
147
|
|
113
148
|
## Contributions
|
114
149
|
|
150
|
+
|
115
151
|
Contributions are welcome!
|
116
152
|
|
117
|
-
Do you find this project to be useful and looking for some features that
|
153
|
+
Do you find this project to be useful and are you looking for some features that are not implemented yet? Feel free to open issues or submit pull requests to improve the project.
|
@@ -0,0 +1,41 @@
|
|
1
|
+
imagebaker/__init__.py,sha256=UeXmuH87AJb0MVzWgT4HXNtl99XxS7HGenLyI9K93go,127
|
2
|
+
imagebaker/core/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
3
|
+
imagebaker/core/configs/__init__.py,sha256=iyR_GOVMFw3XJSm7293YfyTnaLZa7pLQMfn5tGxVofI,31
|
4
|
+
imagebaker/core/configs/configs.py,sha256=5KRZfLShu4JqV459n5dX4AlbIlkySyAmJr8OzYG4X7Q,4850
|
5
|
+
imagebaker/core/defs/__init__.py,sha256=NqV7gYIlRkaS7nx_UTNPSNZbdPrx4w-VurKOKyRLbKY,28
|
6
|
+
imagebaker/core/defs/defs.py,sha256=nIg2ZQADbpcyC0ZOl54L14yLZ38-SUnfMkklCDfhN3E,8257
|
7
|
+
imagebaker/core/plugins/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
8
|
+
imagebaker/core/plugins/base_plugin.py,sha256=ROa1HTwV5LgGL-40CHKk_5MZYI5QAT1MzpYO7Fx-9P0,1084
|
9
|
+
imagebaker/core/plugins/cosine_plugin.py,sha256=IXBfvaoxrvf-hytg_dT1zFmOfDbcWXBZ7NvIFPJ2tWQ,1251
|
10
|
+
imagebaker/layers/__init__.py,sha256=q1kUDHhUXEGBOdu6CHDfqCnE2mraLHRqh0DFHYTbnRY,158
|
11
|
+
imagebaker/layers/annotable_layer.py,sha256=8Y35JvgSQMBTkvjG8VlD1xQgTsskyMwjU6ETU_xalAw,32819
|
12
|
+
imagebaker/layers/base_layer.py,sha256=uncseSxTbLKnV84hAPbJLDbBMV0nu1gQ4N-SLHoGB6s,25486
|
13
|
+
imagebaker/layers/canvas_layer.py,sha256=47R-g3NAzAQ720tWrIZUYIAupxImdORVYK5BFIRopqo,40414
|
14
|
+
imagebaker/list_views/__init__.py,sha256=Aa9slE6do8eYgZp77wrofpd_mlBDwxgF3adMyHYFanE,144
|
15
|
+
imagebaker/list_views/annotation_list.py,sha256=Wx2MbDGxcGeqss9TccFWVVYvlDo9hsefBMQBi4s72is,7436
|
16
|
+
imagebaker/list_views/canvas_list.py,sha256=JYSYR0peGyJFJ6amL1894KsUHETPUkR3qAWdGL50Lbc,6717
|
17
|
+
imagebaker/list_views/image_list.py,sha256=o4yGNXRffPJOZxd_c9JIK9MVzJkeWtXbZUF7pAVmfzw,4813
|
18
|
+
imagebaker/list_views/layer_list.py,sha256=fLx3Ry72fas1W5y_V84hSp41ARneogQN3qjfYTOcpxY,14476
|
19
|
+
imagebaker/list_views/layer_settings.py,sha256=38E39z-rEdl0YSe2C_k4wd5CgHPETQeJE5VvJLfFQ-k,8454
|
20
|
+
imagebaker/models/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
21
|
+
imagebaker/models/base_model.py,sha256=ZfZ_VgP-jzfmEAdOycVtOYkr03m8EyXWdmK0-50MxIk,4197
|
22
|
+
imagebaker/tabs/__init__.py,sha256=ijg7MA17RvcHA2AuZE4OgRJXWxjecaUAlfASKAoCQ6Q,86
|
23
|
+
imagebaker/tabs/baker_tab.py,sha256=kIVoF4w_Ch1YNdHtHsNZKfr46tZWBDSj5xrrEkF1piM,20752
|
24
|
+
imagebaker/tabs/layerify_tab.py,sha256=L8FqZf5JHHYc8BCRKwLWIRdgUSq2YvS7XiJ5Zd5kkTo,32427
|
25
|
+
imagebaker/utils/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
26
|
+
imagebaker/utils/image.py,sha256=fq7g3DqSdjF9okxZ3fe5kF4Hxn32rqhvVqxy8yI5bnI,3067
|
27
|
+
imagebaker/utils/state_utils.py,sha256=sI0R3ht4W_kQGwOpzUdBjy6M4PaKaAQlj-_MM6pidfM,3584
|
28
|
+
imagebaker/utils/transform_mask.py,sha256=k8MfTgM5-_U2TvDHQHRelz-leGFX6OcsllV6-J4BKfw,3651
|
29
|
+
imagebaker/window/__init__.py,sha256=FIxtUR1qnbQMYzppQv7tEfv1-ueHhpu0Z7xuWZR794w,44
|
30
|
+
imagebaker/window/app.py,sha256=e6FGO_BnvkiQC9JN3AmqkgbF72zzZS0hc7PFc43QiVc,4725
|
31
|
+
imagebaker/window/main_window.py,sha256=GM5Pf7wpR8u99FarL7eqyc09Khwi6TWEgka6MvrjP6Y,6978
|
32
|
+
imagebaker/workers/__init__.py,sha256=XfXENwAYyNg9q_zR-gOsYJGjzwg_iIb_gING8ydnp9c,154
|
33
|
+
imagebaker/workers/baker_worker.py,sha256=JyV1Hu4mzbYhmogc7K3U24adklmT3x3V0ZNMxe7iT-w,10697
|
34
|
+
imagebaker/workers/layerify_worker.py,sha256=EOqKvhdACtf3y5Ljy6M7MvddAjlZW5DNfBFMtNPD-us,3223
|
35
|
+
imagebaker/workers/model_worker.py,sha256=Tlg6_D977iK-kuGCNdQY4OnGiP8QqWY7adpRNXZw4rA,1636
|
36
|
+
imagebaker-0.0.46.dist-info/LICENSE,sha256=1vkysFPOnT7y4LsoFTv9YsopIrQvBc2l6vUOfv4KKLc,1082
|
37
|
+
imagebaker-0.0.46.dist-info/METADATA,sha256=eQ78w8cbBe1zk2PCQlStYW5BzoMj1hO3yxlHnm7xVfA,6733
|
38
|
+
imagebaker-0.0.46.dist-info/WHEEL,sha256=tZoeGjtWxWRfdplE7E3d45VPlLNQnvbKiYnx7gwAy8A,92
|
39
|
+
imagebaker-0.0.46.dist-info/entry_points.txt,sha256=IDjZHJCiiHpH5IUTByT2en0nMbnnnlrJZ5FPFehUvQM,61
|
40
|
+
imagebaker-0.0.46.dist-info/top_level.txt,sha256=Gg-eILTlqJXwVQr0saSwsx3-H4SPdZ2agBZaufe194s,11
|
41
|
+
imagebaker-0.0.46.dist-info/RECORD,,
|
@@ -1,7 +0,0 @@
|
|
1
|
-
imagebaker/__init__.py,sha256=UeXmuH87AJb0MVzWgT4HXNtl99XxS7HGenLyI9K93go,127
|
2
|
-
imagebaker-0.0.4.dist-info/licenses/LICENSE,sha256=1vkysFPOnT7y4LsoFTv9YsopIrQvBc2l6vUOfv4KKLc,1082
|
3
|
-
imagebaker-0.0.4.dist-info/METADATA,sha256=PHVvDdO8aGlw333C7SLYIh6i3oMAT6epQ8uWfqDnnJo,4715
|
4
|
-
imagebaker-0.0.4.dist-info/WHEEL,sha256=CmyFI0kx5cdEMTLiONQRbGQwjIoR1aIYB7eCAQ4KPJ0,91
|
5
|
-
imagebaker-0.0.4.dist-info/entry_points.txt,sha256=IDjZHJCiiHpH5IUTByT2en0nMbnnnlrJZ5FPFehUvQM,61
|
6
|
-
imagebaker-0.0.4.dist-info/top_level.txt,sha256=Gg-eILTlqJXwVQr0saSwsx3-H4SPdZ2agBZaufe194s,11
|
7
|
-
imagebaker-0.0.4.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|