kuko6 commited on
Commit
1ba3c27
·
1 Parent(s): 71d5563

Updated cleaning pipeline

Browse files
Files changed (9) hide show
  1. README.md +12 -9
  2. app.py +101 -17
  3. cleaning.py +66 -10
  4. data/A498 sf. 5uM AXT M75 10x 03.tif +3 -0
  5. main.py +2 -4
  6. pyproject.toml +2 -1
  7. requirements.txt +1 -0
  8. test copy.ipynb +0 -0
  9. uv.lock +37 -7
README.md CHANGED
@@ -4,7 +4,7 @@ emoji: 🧑‍🔬
4
  colorFrom: pink
5
  colorTo: yellow
6
  sdk: gradio
7
- sdk_version: 6.19.0
8
  python_version: "3.10"
9
  app_file: app.py
10
  pinned: false
@@ -12,17 +12,19 @@ pinned: false
12
 
13
  # Image cleanup
14
 
15
- Script for removing dark, low-saturation debris from IHC images with OpenCV
16
- inpainting.
17
 
18
  ```bash
19
  uv sync
20
  uv run python main.py data/example.png
21
  ```
22
 
23
- PNG, JPEG, TIFF, and TIF inputs are supported. Cleaned images are written to
24
- `out/cleaned/` with `_cleaned` added before the original extension, and masks
25
- are written to `out/masks/` as PNG files.
 
 
26
 
27
  An optional Gradio interface is also available:
28
 
@@ -31,12 +33,13 @@ uv run python app.py
31
  ```
32
 
33
  Open the local URL printed in the terminal, upload an input image, and select
34
- **Clean image**. TIFF inputs are converted to PNG previews in the interface,
35
- and the cleaned file can be downloaded with the original extension.
 
36
 
37
  For batch processing, open the **Image directory** tab and select a folder.
38
  The app processes all uploaded images, including `.tif` and `.tiff` files, and
39
- returns a ZIP archive.
40
 
41
  Project layout:
42
 
 
4
  colorFrom: pink
5
  colorTo: yellow
6
  sdk: gradio
7
+ sdk_version: 6.22.0
8
  python_version: "3.10"
9
  app_file: app.py
10
  pinned: false
 
12
 
13
  # Image cleanup
14
 
15
+ Script for detecting dark, low-saturation debris in IHC images and creating
16
+ exclusion masks plus OpenCV-inpainted QC previews.
17
 
18
  ```bash
19
  uv sync
20
  uv run python main.py data/example.png
21
  ```
22
 
23
+ PNG, JPEG, TIFF, and TIF inputs are supported. Inpainted QC images are written
24
+ to `out/cleaned/` with `_cleaned` added before the original extension, and
25
+ debris-exclusion masks are written to `out/masks/` as PNG files. Preserve the
26
+ original image and exclude masked pixels when quantifying DAB; do not quantify
27
+ the synthetic pixels in the inpainted QC image.
28
 
29
  An optional Gradio interface is also available:
30
 
 
33
  ```
34
 
35
  Open the local URL printed in the terminal, upload an input image, and select
36
+ **Create mask and QC preview**. TIFF inputs are percentile-scaled to PNG
37
+ previews in the interface. The full-resolution mask and inpainted QC file can
38
+ both be downloaded; the uploaded source image remains unchanged.
39
 
40
  For batch processing, open the **Image directory** tab and select a folder.
41
  The app processes all uploaded images, including `.tif` and `.tiff` files, and
42
+ returns a ZIP archive containing `masks/` and `qc_cleaned/` folders.
43
 
44
  Project layout:
45
 
app.py CHANGED
@@ -5,9 +5,10 @@ from uuid import uuid4
5
 
6
  import cv2
7
  import gradio as gr
 
8
 
9
  from cleaning import (
10
- clean_image,
11
  cleaned_image_name,
12
  read_image_rgb,
13
  write_image_rgb,
@@ -17,6 +18,7 @@ _BATCH_OUTPUTS = tempfile.TemporaryDirectory(prefix="ihc-cleaner-")
17
  _EXAMPLE_IMAGES = [["data/example.png"], ["data/example.tiff"]]
18
  _IMAGE_FILE_TYPES = ["image", ".tif", ".tiff"]
19
  _PREVIEW_MAX_DIMENSION = 1200
 
20
 
21
 
22
  def _uploaded_path(file_path: str | Path | None) -> Path:
@@ -38,11 +40,26 @@ def _preview_image(image):
38
  return cv2.resize(image, preview_size, interpolation=cv2.INTER_AREA)
39
 
40
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
41
  def preview_image(file_path: str | Path | None):
42
  if not file_path:
43
- return None, None, None
44
 
45
- return _preview_image(read_image_rgb(file_path)), None, None
46
 
47
 
48
  def clean_uploaded_image(file_path: str | Path | None):
@@ -51,11 +68,29 @@ def clean_uploaded_image(file_path: str | Path | None):
51
  output_dir.mkdir(parents=True)
52
 
53
  image_rgb = read_image_rgb(image_path)
54
- cleaned_rgb = clean_image(image_rgb)
 
 
 
 
 
 
 
 
 
55
  cleaned_path = output_dir / cleaned_image_name(image_path)
 
56
  write_image_rgb(cleaned_path, cleaned_rgb)
 
 
57
 
58
- return _preview_image(image_rgb), _preview_image(cleaned_rgb), str(cleaned_path)
 
 
 
 
 
 
59
 
60
 
61
  def clean_directory(image_paths: list[str] | None) -> tuple[str, str]:
@@ -64,31 +99,48 @@ def clean_directory(image_paths: list[str] | None) -> tuple[str, str]:
64
 
65
  batch_dir = Path(_BATCH_OUTPUTS.name) / uuid4().hex
66
  cleaned_dir = batch_dir / "cleaned"
 
67
  cleaned_dir.mkdir(parents=True)
 
68
 
69
  used_names: set[str] = set()
70
 
71
  for image_path_string in image_paths:
72
  image_path = Path(image_path_string)
73
- cleaned_rgb = clean_image(read_image_rgb(image_path))
 
 
74
 
75
  output_name = cleaned_image_name(image_path, used_names)
76
  write_image_rgb(cleaned_dir / output_name, cleaned_rgb)
 
 
 
 
77
 
78
  archive_path = batch_dir / "cleaned_images.zip"
79
  with zipfile.ZipFile(archive_path, "w", zipfile.ZIP_DEFLATED) as archive:
80
- for cleaned_path in sorted(cleaned_dir.iterdir()):
81
- archive.write(cleaned_path, arcname=cleaned_path.name)
 
 
82
 
83
  count = len(used_names)
84
- return str(archive_path), f"Cleaned {count} image{'s' if count != 1 else ''}."
 
 
 
 
85
 
86
 
87
  def build_app() -> gr.Blocks:
88
  with gr.Blocks(title="Image Cleanup") as app:
89
  gr.Markdown(
90
  "# Image Cleanup\n"
91
- "Upload an input image to remove dark, low-saturation artifacts."
 
 
 
92
  )
93
 
94
  with gr.Tab("Single image"):
@@ -98,8 +150,12 @@ def build_app() -> gr.Blocks:
98
  file_types=_IMAGE_FILE_TYPES,
99
  type="filepath",
100
  )
 
 
 
 
101
  cleaned_file = gr.File(
102
- label="Cleaned file",
103
  interactive=False,
104
  )
105
  with gr.Row():
@@ -109,17 +165,33 @@ def build_app() -> gr.Blocks:
109
  buttons=["fullscreen"],
110
  interactive=False,
111
  )
 
 
 
 
 
 
112
  cleaned_preview = gr.Image(
113
- label="Cleaned image",
114
  format="png",
115
  buttons=["fullscreen"],
116
  interactive=False,
117
  )
118
 
119
  with gr.Row():
120
- clean_button = gr.Button("Clean image", variant="primary")
 
 
 
121
  gr.ClearButton(
122
- [input_image, input_preview, cleaned_preview, cleaned_file]
 
 
 
 
 
 
 
123
  )
124
 
125
  gr.Examples(
@@ -131,14 +203,26 @@ def build_app() -> gr.Blocks:
131
  input_image.change(
132
  fn=preview_image,
133
  inputs=input_image,
134
- outputs=[input_preview, cleaned_preview, cleaned_file],
 
 
 
 
 
 
135
  api_name=False,
136
  )
137
 
138
  clean_button.click(
139
  fn=clean_uploaded_image,
140
  inputs=input_image,
141
- outputs=[input_preview, cleaned_preview, cleaned_file],
 
 
 
 
 
 
142
  api_name="clean_image",
143
  )
144
 
@@ -155,7 +239,7 @@ def build_app() -> gr.Blocks:
155
  )
156
  batch_status = gr.Textbox(label="Status", interactive=False)
157
  batch_download = gr.File(
158
- label="Cleaned images",
159
  interactive=False,
160
  )
161
 
 
5
 
6
  import cv2
7
  import gradio as gr
8
+ import numpy as np
9
 
10
  from cleaning import (
11
+ clean_image_and_mask,
12
  cleaned_image_name,
13
  read_image_rgb,
14
  write_image_rgb,
 
18
  _EXAMPLE_IMAGES = [["data/example.png"], ["data/example.tiff"]]
19
  _IMAGE_FILE_TYPES = ["image", ".tif", ".tiff"]
20
  _PREVIEW_MAX_DIMENSION = 1200
21
+ _MASK_OUTLINE_KERNEL_SIZE = 3
22
 
23
 
24
  def _uploaded_path(file_path: str | Path | None) -> Path:
 
40
  return cv2.resize(image, preview_size, interpolation=cv2.INTER_AREA)
41
 
42
 
43
+ def _mask_outline(image: np.ndarray, debris_mask: np.ndarray) -> np.ndarray:
44
+ outline_kernel = np.ones(
45
+ (_MASK_OUTLINE_KERNEL_SIZE, _MASK_OUTLINE_KERNEL_SIZE),
46
+ dtype=np.uint8,
47
+ )
48
+ boundary = cv2.morphologyEx(
49
+ debris_mask,
50
+ cv2.MORPH_GRADIENT,
51
+ outline_kernel,
52
+ ) > 0
53
+ outlined = image.copy()
54
+ outlined[boundary] = [0, 255, 0]
55
+ return outlined
56
+
57
+
58
  def preview_image(file_path: str | Path | None):
59
  if not file_path:
60
+ return None, None, None, None, None
61
 
62
+ return _preview_image(read_image_rgb(file_path)), None, None, None, None
63
 
64
 
65
  def clean_uploaded_image(file_path: str | Path | None):
 
68
  output_dir.mkdir(parents=True)
69
 
70
  image_rgb = read_image_rgb(image_path)
71
+ cleaned_rgb, debris_mask = clean_image_and_mask(image_rgb)
72
+ input_preview = _preview_image(image_rgb)
73
+ preview_mask = debris_mask
74
+ if preview_mask.shape != input_preview.shape[:2]:
75
+ preview_mask = cv2.resize(
76
+ preview_mask,
77
+ (input_preview.shape[1], input_preview.shape[0]),
78
+ interpolation=cv2.INTER_NEAREST,
79
+ )
80
+ mask_outline = _mask_outline(input_preview, preview_mask)
81
  cleaned_path = output_dir / cleaned_image_name(image_path)
82
+ mask_path = output_dir / f"{image_path.stem}_debris_mask.png"
83
  write_image_rgb(cleaned_path, cleaned_rgb)
84
+ if not cv2.imwrite(str(mask_path), debris_mask):
85
+ raise OSError(f"Could not write debris mask: {mask_path}")
86
 
87
+ return (
88
+ input_preview,
89
+ mask_outline,
90
+ _preview_image(cleaned_rgb),
91
+ str(mask_path),
92
+ str(cleaned_path),
93
+ )
94
 
95
 
96
  def clean_directory(image_paths: list[str] | None) -> tuple[str, str]:
 
99
 
100
  batch_dir = Path(_BATCH_OUTPUTS.name) / uuid4().hex
101
  cleaned_dir = batch_dir / "cleaned"
102
+ masks_dir = batch_dir / "masks"
103
  cleaned_dir.mkdir(parents=True)
104
+ masks_dir.mkdir(parents=True)
105
 
106
  used_names: set[str] = set()
107
 
108
  for image_path_string in image_paths:
109
  image_path = Path(image_path_string)
110
+ cleaned_rgb, debris_mask = clean_image_and_mask(
111
+ read_image_rgb(image_path)
112
+ )
113
 
114
  output_name = cleaned_image_name(image_path, used_names)
115
  write_image_rgb(cleaned_dir / output_name, cleaned_rgb)
116
+ mask_name = f"{Path(output_name).stem}_debris_mask.png"
117
+ mask_path = masks_dir / mask_name
118
+ if not cv2.imwrite(str(mask_path), debris_mask):
119
+ raise OSError(f"Could not write debris mask: {mask_path}")
120
 
121
  archive_path = batch_dir / "cleaned_images.zip"
122
  with zipfile.ZipFile(archive_path, "w", zipfile.ZIP_DEFLATED) as archive:
123
+ for output_path in sorted(cleaned_dir.iterdir()):
124
+ archive.write(output_path, arcname=f"qc_cleaned/{output_path.name}")
125
+ for output_path in sorted(masks_dir.iterdir()):
126
+ archive.write(output_path, arcname=f"masks/{output_path.name}")
127
 
128
  count = len(used_names)
129
+ return (
130
+ str(archive_path),
131
+ f"Created QC previews and debris masks for {count} "
132
+ f"image{'s' if count != 1 else ''}.",
133
+ )
134
 
135
 
136
  def build_app() -> gr.Blocks:
137
  with gr.Blocks(title="Image Cleanup") as app:
138
  gr.Markdown(
139
  "# Image Cleanup\n"
140
+ "Create a debris-exclusion mask and an inpainted QC preview. "
141
+ "The green outline shows the boundary of the expanded mask. "
142
+ "Use the original image with the mask for DAB quantification; "
143
+ "do not quantify the inpainted preview."
144
  )
145
 
146
  with gr.Tab("Single image"):
 
150
  file_types=_IMAGE_FILE_TYPES,
151
  type="filepath",
152
  )
153
+ mask_file = gr.File(
154
+ label="Debris mask",
155
+ interactive=False,
156
+ )
157
  cleaned_file = gr.File(
158
+ label="Cleaned image file",
159
  interactive=False,
160
  )
161
  with gr.Row():
 
165
  buttons=["fullscreen"],
166
  interactive=False,
167
  )
168
+ outline_preview = gr.Image(
169
+ label="Mask outline (green = boundary)",
170
+ format="png",
171
+ buttons=["fullscreen"],
172
+ interactive=False,
173
+ )
174
  cleaned_preview = gr.Image(
175
+ label="Cleaned image preview",
176
  format="png",
177
  buttons=["fullscreen"],
178
  interactive=False,
179
  )
180
 
181
  with gr.Row():
182
+ clean_button = gr.Button(
183
+ "Clean image",
184
+ variant="primary",
185
+ )
186
  gr.ClearButton(
187
+ [
188
+ input_image,
189
+ input_preview,
190
+ outline_preview,
191
+ cleaned_preview,
192
+ mask_file,
193
+ cleaned_file,
194
+ ]
195
  )
196
 
197
  gr.Examples(
 
203
  input_image.change(
204
  fn=preview_image,
205
  inputs=input_image,
206
+ outputs=[
207
+ input_preview,
208
+ outline_preview,
209
+ cleaned_preview,
210
+ mask_file,
211
+ cleaned_file,
212
+ ],
213
  api_name=False,
214
  )
215
 
216
  clean_button.click(
217
  fn=clean_uploaded_image,
218
  inputs=input_image,
219
+ outputs=[
220
+ input_preview,
221
+ outline_preview,
222
+ cleaned_preview,
223
+ mask_file,
224
+ cleaned_file,
225
+ ],
226
  api_name="clean_image",
227
  )
228
 
 
239
  )
240
  batch_status = gr.Textbox(label="Status", interactive=False)
241
  batch_download = gr.File(
242
+ label="QC images and debris masks",
243
  interactive=False,
244
  )
245
 
cleaning.py CHANGED
@@ -4,10 +4,16 @@ import cv2
4
  import numpy as np
5
 
6
  TIFF_EXTENSIONS = {".tif", ".tiff"}
 
 
 
 
 
7
 
8
 
9
  def _as_rgb_uint8(image: np.ndarray) -> np.ndarray:
10
  image = np.asarray(image)
 
11
 
12
  if image.ndim == 3 and image.shape[2] == 1:
13
  image = image[:, :, 0]
@@ -25,11 +31,24 @@ def _as_rgb_uint8(image: np.ndarray) -> np.ndarray:
25
  if image.dtype != np.uint8:
26
  image = image.astype(np.float32)
27
  if image.size:
28
- max_value = float(np.nanmax(image))
29
- if max_value <= 1:
 
 
 
 
 
30
  image *= 255
31
- elif max_value > 255:
32
- image *= 255 / max_value
 
 
 
 
 
 
 
 
33
  image = np.clip(image, 0, 255).astype(np.uint8)
34
 
35
  return image
@@ -129,17 +148,54 @@ def create_debris_mask(image: np.ndarray) -> np.ndarray:
129
  hsv = cv2.cvtColor(image, cv2.COLOR_RGB2HSV)
130
  _, saturation, value = cv2.split(hsv)
131
 
132
- debris_mask = ((value < 60) & (saturation < 50)).astype(np.uint8) * 255
133
-
134
- kernel = cv2.getStructuringElement(cv2.MORPH_ELLIPSE, (3, 3))
135
- debris_mask = cv2.morphologyEx(debris_mask, cv2.MORPH_OPEN, kernel)
136
- return cv2.dilate(debris_mask, kernel)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
137
 
138
 
139
  def clean_image(image: np.ndarray | None) -> np.ndarray:
 
 
 
 
 
 
 
140
  if image is None:
141
  raise ValueError("An input image is required.")
142
 
143
  image = _as_rgb_uint8(image)
144
  debris_mask = create_debris_mask(image)
145
- return cv2.inpaint(image, debris_mask, 3, cv2.INPAINT_NS)
 
 
 
 
 
 
 
4
  import numpy as np
5
 
6
  TIFF_EXTENSIONS = {".tif", ".tiff"}
7
+ DEBRIS_VALUE_MAX = 60
8
+ DEBRIS_SATURATION_MAX = 15
9
+ DEBRIS_MASK_EXPANSION = 10
10
+ INPAINT_RADIUS = 5
11
+ PREVIEW_PERCENTILES = (1.0, 99.5)
12
 
13
 
14
  def _as_rgb_uint8(image: np.ndarray) -> np.ndarray:
15
  image = np.asarray(image)
16
+ source_dtype = image.dtype
17
 
18
  if image.ndim == 3 and image.shape[2] == 1:
19
  image = image[:, :, 0]
 
31
  if image.dtype != np.uint8:
32
  image = image.astype(np.float32)
33
  if image.size:
34
+ finite_values = image[np.isfinite(image)]
35
+ if not finite_values.size:
36
+ raise ValueError("Image contains no finite pixel values.")
37
+
38
+ min_value = float(np.min(finite_values))
39
+ max_value = float(np.max(finite_values))
40
+ if 0 <= min_value and max_value <= 1:
41
  image *= 255
42
+ elif (
43
+ np.issubdtype(source_dtype, np.integer)
44
+ and np.iinfo(source_dtype).max > 255
45
+ ) or max_value > 255:
46
+ low, high = np.nanpercentile(image, PREVIEW_PERCENTILES)
47
+ if high > low:
48
+ image = (image - low) * (255 / (high - low))
49
+ else:
50
+ image = np.zeros_like(image)
51
+ image = np.nan_to_num(image, nan=0, posinf=255, neginf=0)
52
  image = np.clip(image, 0, 255).astype(np.uint8)
53
 
54
  return image
 
148
  hsv = cv2.cvtColor(image, cv2.COLOR_RGB2HSV)
149
  _, saturation, value = cv2.split(hsv)
150
 
151
+ debris_mask = (
152
+ (value < DEBRIS_VALUE_MAX)
153
+ & (saturation < DEBRIS_SATURATION_MAX)
154
+ ).astype(np.uint8) * 255
155
+
156
+ cleanup_kernel = cv2.getStructuringElement(cv2.MORPH_ELLIPSE, (3, 3))
157
+ debris_mask = cv2.morphologyEx(
158
+ debris_mask,
159
+ cv2.MORPH_OPEN,
160
+ cleanup_kernel,
161
+ )
162
+
163
+ # Inpainting needs a solid mask that extends beyond the dark boundary.
164
+ # Otherwise, unmasked holes and edge pixels are used as source pixels and
165
+ # the reconstructed region remains dark.
166
+ contours, _ = cv2.findContours(
167
+ debris_mask,
168
+ cv2.RETR_EXTERNAL,
169
+ cv2.CHAIN_APPROX_SIMPLE,
170
+ )
171
+ filled_mask = np.zeros_like(debris_mask)
172
+ cv2.drawContours(filled_mask, contours, -1, 255, cv2.FILLED)
173
+
174
+ expansion_size = 2 * DEBRIS_MASK_EXPANSION + 1
175
+ expansion_kernel = cv2.getStructuringElement(
176
+ cv2.MORPH_ELLIPSE,
177
+ (expansion_size, expansion_size),
178
+ )
179
+ return cv2.dilate(filled_mask, expansion_kernel)
180
 
181
 
182
  def clean_image(image: np.ndarray | None) -> np.ndarray:
183
+ cleaned_image, _ = clean_image_and_mask(image)
184
+ return cleaned_image
185
+
186
+
187
+ def clean_image_and_mask(
188
+ image: np.ndarray | None,
189
+ ) -> tuple[np.ndarray, np.ndarray]:
190
  if image is None:
191
  raise ValueError("An input image is required.")
192
 
193
  image = _as_rgb_uint8(image)
194
  debris_mask = create_debris_mask(image)
195
+ cleaned_image = cv2.inpaint(
196
+ image,
197
+ debris_mask,
198
+ INPAINT_RADIUS,
199
+ cv2.INPAINT_TELEA,
200
+ )
201
+ return cleaned_image, debris_mask
data/A498 sf. 5uM AXT M75 10x 03.tif ADDED

Git LFS Details

  • SHA256: e6cb837a4bc99e66a6a1c3ddd25c7bb21048580bbf73b95cb1635ba4e01e2376
  • Pointer size: 133 Bytes
  • Size of remote file: 55 MB
main.py CHANGED
@@ -4,9 +4,8 @@ from pathlib import Path
4
  import cv2
5
 
6
  from cleaning import (
7
- clean_image,
8
  cleaned_image_name,
9
- create_debris_mask,
10
  read_image_rgb,
11
  write_image_rgb,
12
  )
@@ -25,8 +24,7 @@ def main(
25
  for image_path_string in image_paths:
26
  image_path = Path(image_path_string)
27
  image_rgb = read_image_rgb(image_path)
28
- debris_mask = create_debris_mask(image_rgb)
29
- cleaned_rgb = clean_image(image_rgb)
30
 
31
  cv2.imwrite(str(masks_dir / f"{image_path.stem}_mask.png"), debris_mask)
32
  cleaned_path = cleaned_dir / cleaned_image_name(image_path)
 
4
  import cv2
5
 
6
  from cleaning import (
7
+ clean_image_and_mask,
8
  cleaned_image_name,
 
9
  read_image_rgb,
10
  write_image_rgb,
11
  )
 
24
  for image_path_string in image_paths:
25
  image_path = Path(image_path_string)
26
  image_rgb = read_image_rgb(image_path)
27
+ cleaned_rgb, debris_mask = clean_image_and_mask(image_rgb)
 
28
 
29
  cv2.imwrite(str(masks_dir / f"{image_path.stem}_mask.png"), debris_mask)
30
  cleaned_path = cleaned_dir / cleaned_image_name(image_path)
pyproject.toml CHANGED
@@ -27,11 +27,12 @@ dependencies = [
27
  "fastjsonschema==2.21.2",
28
  "fonttools==4.63.0",
29
  "fqdn==1.5.1",
30
- "gradio>=5.0,<7",
31
  "h11==0.16.0",
32
  "httpcore==1.0.9",
33
  "httpx==0.28.1",
34
  "idna==3.18",
 
35
  "imageio==2.37.3",
36
  "ipykernel==7.3.0",
37
  "ipython==9.14.1",
 
27
  "fastjsonschema==2.21.2",
28
  "fonttools==4.63.0",
29
  "fqdn==1.5.1",
30
+ "gradio>=6.22,<7",
31
  "h11==0.16.0",
32
  "httpcore==1.0.9",
33
  "httpx==0.28.1",
34
  "idna==3.18",
35
+ "imagecodecs==2026.6.26",
36
  "imageio==2.37.3",
37
  "ipykernel==7.3.0",
38
  "ipython==9.14.1",
requirements.txt CHANGED
@@ -1,3 +1,4 @@
1
  numpy==2.2.6
2
  opencv-python-headless==4.13.0.92
 
3
  tifffile==2025.5.10
 
1
  numpy==2.2.6
2
  opencv-python-headless==4.13.0.92
3
+ imagecodecs==2026.6.26
4
  tifffile==2025.5.10
test copy.ipynb ADDED
The diff for this file is too large to render. See raw diff
 
uv.lock CHANGED
@@ -656,7 +656,7 @@ wheels = [
656
 
657
  [[package]]
658
  name = "gradio"
659
- version = "6.19.0"
660
  source = { registry = "https://pypi.org/simple" }
661
  dependencies = [
662
  { name = "anyio" },
@@ -688,14 +688,14 @@ dependencies = [
688
  { name = "typing-extensions" },
689
  { name = "uvicorn" },
690
  ]
691
- sdist = { url = "https://files.pythonhosted.org/packages/e0/c4/07ebe72aea259e9e49b660d8890679a459dc76081e659570bba8662677c4/gradio-6.19.0.tar.gz", hash = "sha256:04d0ad1450b3e34683dee76934b47d93b7b655bb506e1e9e9b7b7ab4c9eb8090", size = 47125070, upload-time = "2026-06-17T19:30:22.042Z" }
692
  wheels = [
693
- { url = "https://files.pythonhosted.org/packages/81/c5/eaafbf58bffbd28ce940af11a173aacba888ddc4f7b022de2b85bace2842/gradio-6.19.0-py3-none-any.whl", hash = "sha256:da6c947afca06392f31068c9077e74763a4eb2b81097879dd88b2a1bf28b518e", size = 31278296, upload-time = "2026-06-17T19:30:18.321Z" },
694
  ]
695
 
696
  [[package]]
697
  name = "gradio-client"
698
- version = "2.5.0"
699
  source = { registry = "https://pypi.org/simple" }
700
  dependencies = [
701
  { name = "fsspec" },
@@ -704,9 +704,9 @@ dependencies = [
704
  { name = "packaging" },
705
  { name = "typing-extensions" },
706
  ]
707
- sdist = { url = "https://files.pythonhosted.org/packages/e8/e6/6b6029f5fe2ad7f1211105d530e34d991014c2cae463f9223033031cfc4f/gradio_client-2.5.0.tar.gz", hash = "sha256:4cde99bad62149595c30c90876ca2e405e3a13687ecf895474f3412cb476673d", size = 59013, upload-time = "2026-04-20T23:16:21.518Z" }
708
  wheels = [
709
- { url = "https://files.pythonhosted.org/packages/78/81/0a861b8e1ff42960139c6cd4c7dd591292fa09ea1ae2d87677441cba4c00/gradio_client-2.5.0-py3-none-any.whl", hash = "sha256:d43e2179c29076292a76485ad7ed2e6eaa19d14ac58283bd7f5beabfe4ca958c", size = 59952, upload-time = "2026-04-20T23:16:20.186Z" },
710
  ]
711
 
712
  [[package]]
@@ -864,6 +864,7 @@ dependencies = [
864
  { name = "httpcore" },
865
  { name = "httpx" },
866
  { name = "idna" },
 
867
  { name = "imageio" },
868
  { name = "ipykernel" },
869
  { name = "ipython" },
@@ -977,11 +978,12 @@ requires-dist = [
977
  { name = "fastjsonschema", specifier = "==2.21.2" },
978
  { name = "fonttools", specifier = "==4.63.0" },
979
  { name = "fqdn", specifier = "==1.5.1" },
980
- { name = "gradio", specifier = ">=5.0,<7" },
981
  { name = "h11", specifier = "==0.16.0" },
982
  { name = "httpcore", specifier = "==1.0.9" },
983
  { name = "httpx", specifier = "==0.28.1" },
984
  { name = "idna", specifier = "==3.18" },
 
985
  { name = "imageio", specifier = "==2.37.3" },
986
  { name = "ipykernel", specifier = "==7.3.0" },
987
  { name = "ipython", specifier = "==9.14.1" },
@@ -1069,6 +1071,34 @@ requires-dist = [
1069
  { name = "widgetsnbextension", specifier = "==4.0.15" },
1070
  ]
1071
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1072
  [[package]]
1073
  name = "imageio"
1074
  version = "2.37.3"
 
656
 
657
  [[package]]
658
  name = "gradio"
659
+ version = "6.22.0"
660
  source = { registry = "https://pypi.org/simple" }
661
  dependencies = [
662
  { name = "anyio" },
 
688
  { name = "typing-extensions" },
689
  { name = "uvicorn" },
690
  ]
691
+ sdist = { url = "https://files.pythonhosted.org/packages/f6/ca/ef9c8ace3917963f0cd503a959b44e2d7f84e032c67f65846c4eee9a637c/gradio-6.22.0.tar.gz", hash = "sha256:81c58b4ff3e6bd2c01c51767a9f5288126bcadbeda9512c8158fb7f7dcac0f63", size = 44543579, upload-time = "2026-07-31T03:03:31.396Z" }
692
  wheels = [
693
+ { url = "https://files.pythonhosted.org/packages/c9/f0/ea1aba81d6a853aa90225934583efce03d8fc14b12cf9d9726ba1ad6ecbf/gradio-6.22.0-py3-none-any.whl", hash = "sha256:9bed11d8f410d5e47529060c3c09da0bc83caa960eb7458cc8fbac7d45e5c2a6", size = 30709716, upload-time = "2026-07-31T03:03:27.273Z" },
694
  ]
695
 
696
  [[package]]
697
  name = "gradio-client"
698
+ version = "2.6.0"
699
  source = { registry = "https://pypi.org/simple" }
700
  dependencies = [
701
  { name = "fsspec" },
 
704
  { name = "packaging" },
705
  { name = "typing-extensions" },
706
  ]
707
+ sdist = { url = "https://files.pythonhosted.org/packages/d6/a2/09b994dca27f17ffc0fdd33ee34f1f455a2ac5eec298499d0c21ebb6d918/gradio_client-2.6.0.tar.gz", hash = "sha256:e648110efa31347bb8b1abda150a7a975b40a9658fdd8562803e2ad6a300d033", size = 60674, upload-time = "2026-07-29T19:39:50.915Z" }
708
  wheels = [
709
+ { url = "https://files.pythonhosted.org/packages/5d/29/80957aef2f107e5357cb3d8d5d07f40302962c9b829f9e8f970b80bec502/gradio_client-2.6.0-py3-none-any.whl", hash = "sha256:4493a6425560dd23d1eb5427a13290819135c664c5ed9f184eb517b1ea263291", size = 61654, upload-time = "2026-07-29T19:39:49.788Z" },
710
  ]
711
 
712
  [[package]]
 
864
  { name = "httpcore" },
865
  { name = "httpx" },
866
  { name = "idna" },
867
+ { name = "imagecodecs" },
868
  { name = "imageio" },
869
  { name = "ipykernel" },
870
  { name = "ipython" },
 
978
  { name = "fastjsonschema", specifier = "==2.21.2" },
979
  { name = "fonttools", specifier = "==4.63.0" },
980
  { name = "fqdn", specifier = "==1.5.1" },
981
+ { name = "gradio", specifier = ">=6.22,<7" },
982
  { name = "h11", specifier = "==0.16.0" },
983
  { name = "httpcore", specifier = "==1.0.9" },
984
  { name = "httpx", specifier = "==0.28.1" },
985
  { name = "idna", specifier = "==3.18" },
986
+ { name = "imagecodecs", specifier = "==2026.6.26" },
987
  { name = "imageio", specifier = "==2.37.3" },
988
  { name = "ipykernel", specifier = "==7.3.0" },
989
  { name = "ipython", specifier = "==9.14.1" },
 
1071
  { name = "widgetsnbextension", specifier = "==4.0.15" },
1072
  ]
1073
 
1074
+ [[package]]
1075
+ name = "imagecodecs"
1076
+ version = "2026.6.26"
1077
+ source = { registry = "https://pypi.org/simple" }
1078
+ dependencies = [
1079
+ { name = "numpy" },
1080
+ ]
1081
+ sdist = { url = "https://files.pythonhosted.org/packages/98/9f/b436418349779e1c18cc27575360cad03dd492bc574ae9e297832bc48cab/imagecodecs-2026.6.26.tar.gz", hash = "sha256:da95b145f6b4f746acc9e0b8707b164eefc6a36ade3b6e70f74d102e9affad8c", size = 9669990, upload-time = "2026-06-28T18:27:01.957Z" }
1082
+ wheels = [
1083
+ { url = "https://files.pythonhosted.org/packages/7e/03/89bf1a370dca9860b13414f63d7106600c527305d9d8c0369c15a93ca794/imagecodecs-2026.6.26-cp312-abi3-macosx_10_15_x86_64.whl", hash = "sha256:468314982db54c9c6c32567b159de5d97cf5273763cdede53e320414787ad80a", size = 15387254, upload-time = "2026-06-28T18:26:00.528Z" },
1084
+ { url = "https://files.pythonhosted.org/packages/05/47/826d50cd4378a6982d8a750300b9adc81c3458c4c1bdfd979affc8ce5492/imagecodecs-2026.6.26-cp312-abi3-macosx_11_0_arm64.whl", hash = "sha256:2d3298028a74d748e5b7a00bd736d41cdf2372861376e4af916818e853ca5fc6", size = 12696122, upload-time = "2026-06-28T18:26:03.714Z" },
1085
+ { url = "https://files.pythonhosted.org/packages/c6/52/ccd8a8a71bb2d0ed9fd4a2592028ab129f6b41c6f2b0ef6c1b9251ec7c88/imagecodecs-2026.6.26-cp312-abi3-manylinux_2_28_aarch64.whl", hash = "sha256:73b4310cab61edf5c74ec5cb19672963c2ceb42239877256ca30eb1b70849cf3", size = 27215507, upload-time = "2026-06-28T18:26:07.479Z" },
1086
+ { url = "https://files.pythonhosted.org/packages/d8/3a/29fa169992185df4f1e98b3a1d2b70aac5903170c33f6d66cae68f488c01/imagecodecs-2026.6.26-cp312-abi3-manylinux_2_28_x86_64.whl", hash = "sha256:6e9e57171ce7cdf884e7d45d25427f77275321a0ddbd26941c5c90b242d2b597", size = 28855566, upload-time = "2026-06-28T18:26:11.7Z" },
1087
+ { url = "https://files.pythonhosted.org/packages/29/c7/27d82b105d871ceb6de3a68afbee5f95551b8fba796e4e6e35e334f994f4/imagecodecs-2026.6.26-cp312-abi3-win32.whl", hash = "sha256:091b66cfe11e37e5a037ff64b262bede3898f779ebd9cbf0d4a108613577ab15", size = 16568720, upload-time = "2026-06-28T18:26:15.259Z" },
1088
+ { url = "https://files.pythonhosted.org/packages/c8/e2/8d27dbe855293380194aa794cbcce1df2d23039058b3d917817aaa3f5547/imagecodecs-2026.6.26-cp312-abi3-win_amd64.whl", hash = "sha256:0758a273acd197e236e67f1597d630924f62c12f5b74837dc7eef2db72c1a888", size = 21275600, upload-time = "2026-06-28T18:26:19.678Z" },
1089
+ { url = "https://files.pythonhosted.org/packages/ab/38/3d0d0a4abc3ba607f23a3237a1cb6f7737dbd1b39498364f01f62c004e8b/imagecodecs-2026.6.26-cp312-abi3-win_arm64.whl", hash = "sha256:8bbf132cce699c6b282106e97edc65946d788ccca79f6ba8f5cd1b8a3f43423c", size = 16849832, upload-time = "2026-06-28T18:26:22.797Z" },
1090
+ { url = "https://files.pythonhosted.org/packages/f4/30/040baf3050ee9803608ff9694a4a4dc9ec868e222fe4c5c8de481388ffb0/imagecodecs-2026.6.26-cp314-cp314t-macosx_10_15_x86_64.whl", hash = "sha256:46980597f48fe790f81e286cf662f0323d0022203cbe48f77c3be608f510de85", size = 15803759, upload-time = "2026-06-28T18:26:25.873Z" },
1091
+ { url = "https://files.pythonhosted.org/packages/ff/e8/042eeac7c78565f1b4c14ba3dc6a96aad9b958e008a1e291a1cbf72123e9/imagecodecs-2026.6.26-cp314-cp314t-macosx_11_0_arm64.whl", hash = "sha256:c48767bbc6ed0b40df3607cafdf59dac6f4467b91c26e835744d7ee4085cfdf7", size = 13164944, upload-time = "2026-06-28T18:26:29.33Z" },
1092
+ { url = "https://files.pythonhosted.org/packages/1d/dd/0e0c86df9a55a0a90ced8cf5214abb459015cda5f2e713e0495ccd9bf23f/imagecodecs-2026.6.26-cp314-cp314t-manylinux_2_28_aarch64.whl", hash = "sha256:9c130cf207efcb35acf74d6040317d217294640e478aa733fb51be758bcaddbc", size = 32436234, upload-time = "2026-06-28T18:26:33.35Z" },
1093
+ { url = "https://files.pythonhosted.org/packages/b9/9a/2d63eb2ffa46863bf0ea05884ce1ea2a73a5153b428937b8cbe4faa81536/imagecodecs-2026.6.26-cp314-cp314t-manylinux_2_28_x86_64.whl", hash = "sha256:014f5f809418eb3dfe29badd4af29ddeeaba8b5eabda4bd502e2292727e4094f", size = 33446845, upload-time = "2026-06-28T18:26:38.238Z" },
1094
+ { url = "https://files.pythonhosted.org/packages/14/68/ece973cd5b1d8305b95ad827b3c6033aed166c5ce93780b6092dbfd5deec/imagecodecs-2026.6.26-cp314-cp314t-win32.whl", hash = "sha256:daa276e5645750404a28a911dcbfb94c7d32b2d8903b5f05167474ea02bd5b40", size = 17330378, upload-time = "2026-06-28T18:26:42.172Z" },
1095
+ { url = "https://files.pythonhosted.org/packages/ad/e6/ab2e9ee84e44768ceb73bb9301988ea4ab9022f02ef9d824d6ebb641a0fb/imagecodecs-2026.6.26-cp314-cp314t-win_amd64.whl", hash = "sha256:0718d75672768871aa6adac2129c8f74c167fb4a3da25f660f3afc94b420304f", size = 22122461, upload-time = "2026-06-28T18:26:45.622Z" },
1096
+ { url = "https://files.pythonhosted.org/packages/58/53/7943321eb84c6d39e71ca47e689557a976c6ebafec48b759b3be0bd7c601/imagecodecs-2026.6.26-cp314-cp314t-win_arm64.whl", hash = "sha256:69b90b7b729d33cd9417d3d572d3092d2d49f7974638ee00e2cdc3ed1fba11d6", size = 17657147, upload-time = "2026-06-28T18:26:48.924Z" },
1097
+ { url = "https://files.pythonhosted.org/packages/f8/de/130820754c21c00dfdc6852661de2bb30161b5a439a8643a446dae97a02f/imagecodecs-2026.6.26-cp315-cp315t-win32.whl", hash = "sha256:a10c347225f5fb1b9d1a36cfadccad9b173609c30e0dd3f68706675d6f4f9b58", size = 17330338, upload-time = "2026-06-28T18:26:52.04Z" },
1098
+ { url = "https://files.pythonhosted.org/packages/a7/df/b4f6f2a9e9102ca674673cb1b432bbebfe2d99acb6364390768024d56ae6/imagecodecs-2026.6.26-cp315-cp315t-win_amd64.whl", hash = "sha256:85ab027a8bc900f13b1cdaac05bb602ea58749731ae18743a7956642a7da7a2c", size = 22116857, upload-time = "2026-06-28T18:26:55.65Z" },
1099
+ { url = "https://files.pythonhosted.org/packages/2e/c4/d87b33e8df5c6ec19f5cd1d5ab39195b2077ac21536ff5146c20d3fb8694/imagecodecs-2026.6.26-cp315-cp315t-win_arm64.whl", hash = "sha256:41e18fcd2124c083b00f988eeb9c5cf89274e5c2f473ee03d54761b71048085c", size = 17651071, upload-time = "2026-06-28T18:26:59.305Z" },
1100
+ ]
1101
+
1102
  [[package]]
1103
  name = "imageio"
1104
  version = "2.37.3"