Skip to content

Question: there may be something wrong with my anomalib. #2399

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
1 task done
1312354o opened this issue Oct 28, 2024 · 2 comments
Closed
1 task done

Question: there may be something wrong with my anomalib. #2399

1312354o opened this issue Oct 28, 2024 · 2 comments

Comments

@1312354o
Copy link

Describe the bug

Anomalib seems to not working when I tried to run the code from get_started document using EfficientAd.

Dataset

MVTec

Model

Other (please specify in the field below)

Steps to reproduce the behavior

When follow the step from document using:

model2 = EfficientAd()
datamodule2 = MVTec(train_batch_size=1)
engine2 = Engine(max_epochs=5)
engine2.train(datamodule=datamodule2, model=model2)

The program throw RecursionError: maximum recursion depth exceeded
It outputs multiple lines of
efficientad_pretrained_weights.zip: 0.00B [00:00, ?B/s]
efficientad_pretrained_weights.zip: 0.00B [00:00, ?B/s]
efficientad_pretrained_weights.zip: 0.00B [00:00, ?B/s]
......................

Then I tried manually load these pretrained weights:

model2.prepare_pretrained_model()
model2.prepare_imagenette_data(image_size=(256,256))

datamodule2 = MVTec(train_batch_size=1)
engine2 = Engine(max_epochs=5)
engine2.train(datamodule=datamodule2, model=model2)

However this also didn't work.
It output multiple lines of
Calculate teacher channel mean & std: 0%| | 0/209 [00:00<?, ?it/s]
Calculate teacher channel mean & std: 0%| | 0/209 [00:00<?, ?it/s]
Calculate teacher channel mean & std: 0%| | 0/209 [00:00<?, ?it/s]
........
Calculate teacher channel mean & std: 0%| | 1/209 [00:00<01:19, 2.62it/s
.......(also too much lines)
And the program again threw an recursion error of exceeding limits.

OS information

OS information:

  • OS: Ubuntu 22.04 on WSL
  • Anomalib version: anomalib==1.1.1
  • PyTorch version: torch==2.5.0
  • GPU models and configuration: GeForce RTX 4070 laptop

Expected behavior

It just works.

Screenshots

No response

Pip/GitHub

pip

What version/branch did you use?

No response

Configuration YAML

Not using YAML

Logs

Trainer already configured with model summary callbacks: [<class 'lightning.pytorch.callbacks.rich_model_summary.RichModelSummary'>]. Skipping setting a default `ModelSummary` callback.
GPU available: True (cuda), used: True
TPU available: False, using: 0 TPU cores
HPU available: False, using: 0 HPUs
F1Score class exists for backwards compatibility. It will be removed in v1.1. Please use BinaryF1Score from torchmetrics instead
F1Score class exists for backwards compatibility. It will be removed in v1.1. Please use BinaryF1Score from torchmetrics instead
LOCAL_RANK: 0 - CUDA_VISIBLE_DEVICES: [0]

{
	"name": "RecursionError",
	"message": "maximum recursion depth exceeded",
	"stack": "---------------------------------------------------------------------------
RecursionError                            Traceback (most recent call last)
File ~/anamalib/.venv/lib/python3.12/site-packages/tqdm/std.py:1191, in tqdm.__iter__(self)
   1190 if dt >= mininterval and cur_t >= min_start_t:
-> 1191     self.update(n - last_print_n)
   1192     last_print_n = self.last_print_n

File ~/anamalib/.venv/lib/python3.12/site-packages/tqdm/std.py:1242, in tqdm.update(self, n)
   1241     self._ema_dt(dt)
-> 1242 self.refresh(lock_args=self.lock_args)
   1243 if self.dynamic_miniters:
   1244     # If no `miniters` was specified, adjust automatically to the
   1245     # maximum iteration rate seen so far between two prints.
   1246     # e.g.: After running `tqdm.update(5)`, subsequent
   1247     # calls to `tqdm.update()` will only cause an update after
   1248     # at least 5 more iterations.

File ~/anamalib/.venv/lib/python3.12/site-packages/tqdm/std.py:1347, in tqdm.refresh(self, nolock, lock_args)
   1346         self._lock.acquire()
-> 1347 self.display()
   1348 if not nolock:

File ~/anamalib/.venv/lib/python3.12/site-packages/tqdm/std.py:1495, in tqdm.display(self, msg, pos)
   1494     self.moveto(pos)
-> 1495 self.sp(self.__str__() if msg is None else msg)
   1496 if pos:

File ~/anamalib/.venv/lib/python3.12/site-packages/tqdm/std.py:459, in tqdm.status_printer.<locals>.print_status(s)
    458 len_s = disp_len(s)
--> 459 fp_write('\\r' + s + (' ' * max(last_len[0] - len_s, 0)))
    460 last_len[0] = len_s

File ~/anamalib/.venv/lib/python3.12/site-packages/tqdm/std.py:453, in tqdm.status_printer.<locals>.fp_write(s)
    452 fp.write(str(s))
--> 453 fp_flush()

File ~/anamalib/.venv/lib/python3.12/site-packages/tqdm/utils.py:196, in DisableOnWriteError.disable_on_exception.<locals>.inner(*args, **kwargs)
    195 try:
--> 196     return func(*args, **kwargs)
    197 except OSError as e:

File ~/anamalib/.venv/lib/python3.12/site-packages/rich/file_proxy.py:53, in FileProxy.flush(self)
     52 if output:
---> 53     self.__console.print(output)
     54 del self.__buffer[:]

File ~/anamalib/.venv/lib/python3.12/site-packages/rich/console.py:1678, in Console.print(self, sep, end, style, justify, overflow, no_wrap, emoji, markup, highlight, width, height, crop, soft_wrap, new_line_start, *objects)
   1677 render_hooks = self._render_hooks[:]
-> 1678 with self:
   1679     renderables = self._collect_renderables(
   1680         objects,
   1681         sep,
   (...)
   1686         highlight=highlight,
   1687     )

File ~/anamalib/.venv/lib/python3.12/site-packages/rich/console.py:864, in Console.__exit__(self, exc_type, exc_value, traceback)
    863 \"\"\"Exit buffer context.\"\"\"
--> 864 self._exit_buffer()

File ~/anamalib/.venv/lib/python3.12/site-packages/rich/console.py:822, in Console._exit_buffer(self)
    821 self._buffer_index -= 1
--> 822 self._check_buffer()

File ~/anamalib/.venv/lib/python3.12/site-packages/rich/console.py:2019, in Console._check_buffer(self)
   2018 try:
-> 2019     self._write_buffer()
   2020 except BrokenPipeError:

File ~/anamalib/.venv/lib/python3.12/site-packages/rich/console.py:2035, in Console._write_buffer(self)
   2033 from .jupyter import display
-> 2035 display(self._buffer, self._render_buffer(self._buffer[:]))
   2036 del self._buffer[:]

File ~/anamalib/.venv/lib/python3.12/site-packages/rich/jupyter.py:91, in display(segments, text)
     89     from IPython.display import display as ipython_display
---> 91     ipython_display(jupyter_renderable)
     92 except ModuleNotFoundError:
     93     # Handle the case where the Console has force_jupyter=True,
     94     # but IPython is not installed.

File ~/anamalib/.venv/lib/python3.12/site-packages/IPython/core/display_functions.py:305, in display(include, exclude, metadata, transient, display_id, raw, clear, *objs, **kwargs)
    304             _merge(md_dict, metadata)
--> 305         publish_display_data(data=format_dict, metadata=md_dict, **kwargs)
    306 if display_id:

File ~/anamalib/.venv/lib/python3.12/site-packages/IPython/core/display_functions.py:93, in publish_display_data(data, metadata, source, transient, **kwargs)
     91     kwargs['transient'] = transient
---> 93 display_pub.publish(
     94     data=data,
     95     metadata=metadata,
     96     **kwargs
     97 )

File ~/anamalib/.venv/lib/python3.12/site-packages/ipykernel/zmqshell.py:103, in ZMQDisplayPublisher.publish(self, data, metadata, transient, update)
     88 \"\"\"Publish a display-data message
     89 
     90 Parameters
   (...)
    101     If True, send an update_display_data message instead of display_data.
    102 \"\"\"
--> 103 self._flush_streams()
    104 if metadata is None:

File ~/anamalib/.venv/lib/python3.12/site-packages/ipykernel/zmqshell.py:67, in ZMQDisplayPublisher._flush_streams(self)
     66 sys.stdout.flush()
---> 67 sys.stderr.flush()

File ~/anamalib/.venv/lib/python3.12/site-packages/rich/file_proxy.py:53, in FileProxy.flush(self)
     52 if output:
---> 53     self.__console.print(output)
     54 del self.__buffer[:]

File ~/anamalib/.venv/lib/python3.12/site-packages/rich/console.py:1678, in Console.print(self, sep, end, style, justify, overflow, no_wrap, emoji, markup, highlight, width, height, crop, soft_wrap, new_line_start, *objects)
   1677 render_hooks = self._render_hooks[:]
-> 1678 with self:
   1679     renderables = self._collect_renderables(
   1680         objects,
   1681         sep,
   (...)
   1686         highlight=highlight,
   1687     )

File ~/anamalib/.venv/lib/python3.12/site-packages/rich/console.py:864, in Console.__exit__(self, exc_type, exc_value, traceback)
    863 \"\"\"Exit buffer context.\"\"\"
--> 864 self._exit_buffer()

File ~/anamalib/.venv/lib/python3.12/site-packages/rich/console.py:822, in Console._exit_buffer(self)
    821 self._buffer_index -= 1
--> 822 self._check_buffer()

File ~/anamalib/.venv/lib/python3.12/site-packages/rich/console.py:2019, in Console._check_buffer(self)
   2018 try:
-> 2019     self._write_buffer()
   2020 except BrokenPipeError:

File ~/anamalib/.venv/lib/python3.12/site-packages/rich/console.py:2035, in Console._write_buffer(self)
   2033 from .jupyter import display
-> 2035 display(self._buffer, self._render_buffer(self._buffer[:]))
   2036 del self._buffer[:]

File ~/anamalib/.venv/lib/python3.12/site-packages/rich/jupyter.py:91, in display(segments, text)
     89     from IPython.display import display as ipython_display
---> 91     ipython_display(jupyter_renderable)
     92 except ModuleNotFoundError:
     93     # Handle the case where the Console has force_jupyter=True,
     94     # but IPython is not installed.

File ~/anamalib/.venv/lib/python3.12/site-packages/IPython/core/display_functions.py:305, in display(include, exclude, metadata, transient, display_id, raw, clear, *objs, **kwargs)
    304             _merge(md_dict, metadata)
--> 305         publish_display_data(data=format_dict, metadata=md_dict, **kwargs)
    306 if display_id:

File ~/anamalib/.venv/lib/python3.12/site-packages/IPython/core/display_functions.py:93, in publish_display_data(data, metadata, source, transient, **kwargs)
     91     kwargs['transient'] = transient
---> 93 display_pub.publish(
     94     data=data,
     95     metadata=metadata,
     96     **kwargs
     97 )

File ~/anamalib/.venv/lib/python3.12/site-packages/ipykernel/zmqshell.py:103, in ZMQDisplayPublisher.publish(self, data, metadata, transient, update)
     88 \"\"\"Publish a display-data message
     89 
     90 Parameters
   (...)
    101     If True, send an update_display_data message instead of display_data.
    102 \"\"\"
--> 103 self._flush_streams()
    104 if metadata is None:

File ~/anamalib/.venv/lib/python3.12/site-packages/ipykernel/zmqshell.py:67, in ZMQDisplayPublisher._flush_streams(self)
     66 sys.stdout.flush()
---> 67 sys.stderr.flush()

    [... skipping similar frames: Console.__exit__ at line 864 (266 times), Console._check_buffer at line 2019 (266 times), Console._exit_buffer at line 822 (266 times), Console._write_buffer at line 2035 (266 times), FileProxy.flush at line 53 (266 times), Console.print at line 1678 (266 times), ZMQDisplayPublisher._flush_streams at line 67 (265 times), display at line 91 (265 times), display at line 305 (265 times), ZMQDisplayPublisher.publish at line 103 (265 times), publish_display_data at line 93 (265 times)]

File ~/anamalib/.venv/lib/python3.12/site-packages/rich/jupyter.py:91, in display(segments, text)
     89     from IPython.display import display as ipython_display
---> 91     ipython_display(jupyter_renderable)
     92 except ModuleNotFoundError:
     93     # Handle the case where the Console has force_jupyter=True,
     94     # but IPython is not installed.

File ~/anamalib/.venv/lib/python3.12/site-packages/IPython/core/display_functions.py:305, in display(include, exclude, metadata, transient, display_id, raw, clear, *objs, **kwargs)
    304             _merge(md_dict, metadata)
--> 305         publish_display_data(data=format_dict, metadata=md_dict, **kwargs)
    306 if display_id:

File ~/anamalib/.venv/lib/python3.12/site-packages/IPython/core/display_functions.py:93, in publish_display_data(data, metadata, source, transient, **kwargs)
     91     kwargs['transient'] = transient
---> 93 display_pub.publish(
     94     data=data,
     95     metadata=metadata,
     96     **kwargs
     97 )

File ~/anamalib/.venv/lib/python3.12/site-packages/ipykernel/zmqshell.py:103, in ZMQDisplayPublisher.publish(self, data, metadata, transient, update)
     88 \"\"\"Publish a display-data message
     89 
     90 Parameters
   (...)
    101     If True, send an update_display_data message instead of display_data.
    102 \"\"\"
--> 103 self._flush_streams()
    104 if metadata is None:

File ~/anamalib/.venv/lib/python3.12/site-packages/ipykernel/zmqshell.py:67, in ZMQDisplayPublisher._flush_streams(self)
     66 sys.stdout.flush()
---> 67 sys.stderr.flush()

File ~/anamalib/.venv/lib/python3.12/site-packages/rich/file_proxy.py:53, in FileProxy.flush(self)
     52 if output:
---> 53     self.__console.print(output)
     54 del self.__buffer[:]

File ~/anamalib/.venv/lib/python3.12/site-packages/rich/console.py:1678, in Console.print(self, sep, end, style, justify, overflow, no_wrap, emoji, markup, highlight, width, height, crop, soft_wrap, new_line_start, *objects)
   1677 render_hooks = self._render_hooks[:]
-> 1678 with self:
   1679     renderables = self._collect_renderables(
   1680         objects,
   1681         sep,
   (...)
   1686         highlight=highlight,
   1687     )

File ~/anamalib/.venv/lib/python3.12/site-packages/rich/console.py:864, in Console.__exit__(self, exc_type, exc_value, traceback)
    863 \"\"\"Exit buffer context.\"\"\"
--> 864 self._exit_buffer()

File ~/anamalib/.venv/lib/python3.12/site-packages/rich/console.py:822, in Console._exit_buffer(self)
    821 self._buffer_index -= 1
--> 822 self._check_buffer()

File ~/anamalib/.venv/lib/python3.12/site-packages/rich/console.py:2019, in Console._check_buffer(self)
   2018 try:
-> 2019     self._write_buffer()
   2020 except BrokenPipeError:

File ~/anamalib/.venv/lib/python3.12/site-packages/rich/console.py:2035, in Console._write_buffer(self)
   2033 from .jupyter import display
-> 2035 display(self._buffer, self._render_buffer(self._buffer[:]))
   2036 del self._buffer[:]

File ~/anamalib/.venv/lib/python3.12/site-packages/rich/jupyter.py:86, in display(segments, text)
     85 \"\"\"Render segments to Jupyter.\"\"\"
---> 86 html = _render_segments(segments)
     87 jupyter_renderable = JupyterRenderable(html, text)

File ~/anamalib/.venv/lib/python3.12/site-packages/rich/jupyter.py:67, in _render_segments(segments)
     66 theme = DEFAULT_TERMINAL_THEME
---> 67 for text, style, control in Segment.simplify(segments):
     68     if control:

File ~/anamalib/.venv/lib/python3.12/site-packages/rich/segment.py:540, in Segment.simplify(cls, segments)
    539 for segment in iter_segments:
--> 540     if last_segment.style == segment.style and not segment.control:
    541         last_segment = _Segment(
    542             last_segment.text + segment.text, last_segment.style
    543         )

File ~/anamalib/.venv/lib/python3.12/site-packages/rich/style.py:425, in Style.__eq__(self, other)
    424     return NotImplemented
--> 425 return self.__hash__() == other.__hash__()

RecursionError: maximum recursion depth exceeded

During handling of the above exception, another exception occurred:

RecursionError                            Traceback (most recent call last)
Cell In[17], line 3
      1 datamodule2 = MVTec(train_batch_size=1)
      2 engine2 = Engine(max_epochs=5)
----> 3 engine2.train(datamodule=datamodule2, model=model2)

File ~/anamalib/.venv/lib/python3.12/site-packages/anomalib/engine/engine.py:863, in Engine.train(self, model, train_dataloaders, val_dataloaders, test_dataloaders, datamodule, ckpt_path)
    861     self.trainer.validate(model, val_dataloaders, None, verbose=False, datamodule=datamodule)
    862 else:
--> 863     self.trainer.fit(model, train_dataloaders, val_dataloaders, datamodule, ckpt_path)
    864 self.trainer.test(model, test_dataloaders, ckpt_path=ckpt_path, datamodule=datamodule)

File ~/anamalib/.venv/lib/python3.12/site-packages/lightning/pytorch/trainer/trainer.py:538, in Trainer.fit(self, model, train_dataloaders, val_dataloaders, datamodule, ckpt_path)
    536 self.state.status = TrainerStatus.RUNNING
    537 self.training = True
--> 538 call._call_and_handle_interrupt(
    539     self, self._fit_impl, model, train_dataloaders, val_dataloaders, datamodule, ckpt_path
    540 )

File ~/anamalib/.venv/lib/python3.12/site-packages/lightning/pytorch/trainer/call.py:47, in _call_and_handle_interrupt(trainer, trainer_fn, *args, **kwargs)
     45     if trainer.strategy.launcher is not None:
     46         return trainer.strategy.launcher.launch(trainer_fn, *args, trainer=trainer, **kwargs)
---> 47     return trainer_fn(*args, **kwargs)
     49 except _TunerExitException:
     50     _call_teardown_hook(trainer)

File ~/anamalib/.venv/lib/python3.12/site-packages/lightning/pytorch/trainer/trainer.py:574, in Trainer._fit_impl(self, model, train_dataloaders, val_dataloaders, datamodule, ckpt_path)
    567 assert self.state.fn is not None
    568 ckpt_path = self._checkpoint_connector._select_ckpt_path(
    569     self.state.fn,
    570     ckpt_path,
    571     model_provided=True,
    572     model_connected=self.lightning_module is not None,
    573 )
--> 574 self._run(model, ckpt_path=ckpt_path)
    576 assert self.state.stopped
    577 self.training = False

File ~/anamalib/.venv/lib/python3.12/site-packages/lightning/pytorch/trainer/trainer.py:981, in Trainer._run(self, model, ckpt_path)
    976 self._signal_connector.register_signal_handlers()
    978 # ----------------------------
    979 # RUN THE TRAINER
    980 # ----------------------------
--> 981 results = self._run_stage()
    983 # ----------------------------
    984 # POST-Training CLEAN UP
    985 # ----------------------------
    986 log.debug(f\"{self.__class__.__name__}: trainer tearing down\")

File ~/anamalib/.venv/lib/python3.12/site-packages/lightning/pytorch/trainer/trainer.py:1025, in Trainer._run_stage(self)
   1023         self._run_sanity_check()
   1024     with torch.autograd.set_detect_anomaly(self._detect_anomaly):
-> 1025         self.fit_loop.run()
   1026     return None
   1027 raise RuntimeError(f\"Unexpected state {self.state}\")

File ~/anamalib/.venv/lib/python3.12/site-packages/lightning/pytorch/loops/fit_loop.py:201, in _FitLoop.run(self)
    199     return
    200 self.reset()
--> 201 self.on_run_start()
    202 while not self.done:
    203     try:

File ~/anamalib/.venv/lib/python3.12/site-packages/lightning/pytorch/loops/fit_loop.py:328, in _FitLoop.on_run_start(self)
    325     trainer.training = True
    327 call._call_callback_hooks(trainer, \"on_train_start\")
--> 328 call._call_lightning_module_hook(trainer, \"on_train_start\")
    329 call._call_strategy_hook(trainer, \"on_train_start\")

File ~/anamalib/.venv/lib/python3.12/site-packages/lightning/pytorch/trainer/call.py:167, in _call_lightning_module_hook(trainer, hook_name, pl_module, *args, **kwargs)
    164 pl_module._current_fx_name = hook_name
    166 with trainer.profiler.profile(f\"[LightningModule]{pl_module.__class__.__name__}.{hook_name}\"):
--> 167     output = fn(*args, **kwargs)
    169 # restore current_fx when nested context
    170 pl_module._current_fx_name = prev_fx_name

File ~/anamalib/.venv/lib/python3.12/site-packages/anomalib/models/image/efficient_ad/lightning_model.py:256, in EfficientAd.on_train_start(self)
    254 self.prepare_imagenette_data(image_size)
    255 if not self.model.is_set(self.model.mean_std):
--> 256     channel_mean_std = self.teacher_channel_mean_std(self.trainer.datamodule.train_dataloader())
    257     self.model.mean_std.update(channel_mean_std)

File ~/anamalib/.venv/lib/python3.12/site-packages/torch/utils/_contextlib.py:116, in context_decorator.<locals>.decorate_context(*args, **kwargs)
    113 @functools.wraps(func)
    114 def decorate_context(*args, **kwargs):
    115     with ctx_factory():
--> 116         return func(*args, **kwargs)

File ~/anamalib/.venv/lib/python3.12/site-packages/anomalib/models/image/efficient_ad/lightning_model.py:138, in EfficientAd.teacher_channel_mean_std(self, dataloader)
    135 chanel_sum: torch.Tensor | None = None
    136 chanel_sum_sqr: torch.Tensor | None = None
--> 138 for batch in tqdm.tqdm(dataloader, desc=\"Calculate teacher channel mean & std\", position=0, leave=True):
    139     y = self.model.teacher(batch[\"image\"].to(self.device))
    140     if not arrays_defined:

File ~/anamalib/.venv/lib/python3.12/site-packages/tqdm/std.py:1196, in tqdm.__iter__(self)
   1194 finally:
   1195     self.n = n
-> 1196     self.close()

File ~/anamalib/.venv/lib/python3.12/site-packages/tqdm/std.py:1302, in tqdm.close(self)
   1299 if leave:
   1300     # stats for overall rate (no weighted average)
   1301     self._ema_dt = lambda: None
-> 1302     self.display(pos=0)
   1303     fp_write('\
')
   1304 else:
   1305     # clear previous display

File ~/anamalib/.venv/lib/python3.12/site-packages/tqdm/std.py:1495, in tqdm.display(self, msg, pos)
   1493 if pos:
   1494     self.moveto(pos)
-> 1495 self.sp(self.__str__() if msg is None else msg)
   1496 if pos:
   1497     self.moveto(-pos)

File ~/anamalib/.venv/lib/python3.12/site-packages/tqdm/std.py:459, in tqdm.status_printer.<locals>.print_status(s)
    457 def print_status(s):
    458     len_s = disp_len(s)
--> 459     fp_write('\\r' + s + (' ' * max(last_len[0] - len_s, 0)))
    460     last_len[0] = len_s

File ~/anamalib/.venv/lib/python3.12/site-packages/tqdm/std.py:453, in tqdm.status_printer.<locals>.fp_write(s)
    451 def fp_write(s):
    452     fp.write(str(s))
--> 453     fp_flush()

File ~/anamalib/.venv/lib/python3.12/site-packages/tqdm/utils.py:196, in DisableOnWriteError.disable_on_exception.<locals>.inner(*args, **kwargs)
    194 def inner(*args, **kwargs):
    195     try:
--> 196         return func(*args, **kwargs)
    197     except OSError as e:
    198         if e.errno != 5:

File ~/anamalib/.venv/lib/python3.12/site-packages/rich/file_proxy.py:53, in FileProxy.flush(self)
     51 output = \"\".join(self.__buffer)
     52 if output:
---> 53     self.__console.print(output)
     54 del self.__buffer[:]

File ~/anamalib/.venv/lib/python3.12/site-packages/rich/console.py:1678, in Console.print(self, sep, end, style, justify, overflow, no_wrap, emoji, markup, highlight, width, height, crop, soft_wrap, new_line_start, *objects)
   1676     crop = False
   1677 render_hooks = self._render_hooks[:]
-> 1678 with self:
   1679     renderables = self._collect_renderables(
   1680         objects,
   1681         sep,
   (...)
   1686         highlight=highlight,
   1687     )
   1688     for hook in render_hooks:

File ~/anamalib/.venv/lib/python3.12/site-packages/rich/console.py:864, in Console.__exit__(self, exc_type, exc_value, traceback)
    862 def __exit__(self, exc_type: Any, exc_value: Any, traceback: Any) -> None:
    863     \"\"\"Exit buffer context.\"\"\"
--> 864     self._exit_buffer()

File ~/anamalib/.venv/lib/python3.12/site-packages/rich/console.py:822, in Console._exit_buffer(self)
    820 \"\"\"Leave buffer context, and render content if required.\"\"\"
    821 self._buffer_index -= 1
--> 822 self._check_buffer()

File ~/anamalib/.venv/lib/python3.12/site-packages/rich/console.py:2019, in Console._check_buffer(self)
   2016     return
   2018 try:
-> 2019     self._write_buffer()
   2020 except BrokenPipeError:
   2021     self.on_broken_pipe()

File ~/anamalib/.venv/lib/python3.12/site-packages/rich/console.py:2035, in Console._write_buffer(self)
   2032 if self.is_jupyter:  # pragma: no cover
   2033     from .jupyter import display
-> 2035     display(self._buffer, self._render_buffer(self._buffer[:]))
   2036     del self._buffer[:]
   2037 else:

File ~/anamalib/.venv/lib/python3.12/site-packages/rich/jupyter.py:91, in display(segments, text)
     88 try:
     89     from IPython.display import display as ipython_display
---> 91     ipython_display(jupyter_renderable)
     92 except ModuleNotFoundError:
     93     # Handle the case where the Console has force_jupyter=True,
     94     # but IPython is not installed.
     95     pass

File ~/anamalib/.venv/lib/python3.12/site-packages/IPython/core/display_functions.py:305, in display(include, exclude, metadata, transient, display_id, raw, clear, *objs, **kwargs)
    302         if metadata:
    303             # kwarg-specified metadata gets precedence
    304             _merge(md_dict, metadata)
--> 305         publish_display_data(data=format_dict, metadata=md_dict, **kwargs)
    306 if display_id:
    307     return DisplayHandle(display_id)

File ~/anamalib/.venv/lib/python3.12/site-packages/IPython/core/display_functions.py:93, in publish_display_data(data, metadata, source, transient, **kwargs)
     90 if transient:
     91     kwargs['transient'] = transient
---> 93 display_pub.publish(
     94     data=data,
     95     metadata=metadata,
     96     **kwargs
     97 )

File ~/anamalib/.venv/lib/python3.12/site-packages/ipykernel/zmqshell.py:103, in ZMQDisplayPublisher.publish(self, data, metadata, transient, update)
     81 def publish(
     82     self,
     83     data,
   (...)
     86     update=False,
     87 ):
     88     \"\"\"Publish a display-data message
     89 
     90     Parameters
   (...)
    101         If True, send an update_display_data message instead of display_data.
    102     \"\"\"
--> 103     self._flush_streams()
    104     if metadata is None:
    105         metadata = {}

File ~/anamalib/.venv/lib/python3.12/site-packages/ipykernel/zmqshell.py:67, in ZMQDisplayPublisher._flush_streams(self)
     65 \"\"\"flush IO Streams prior to display\"\"\"
     66 sys.stdout.flush()
---> 67 sys.stderr.flush()

File ~/anamalib/.venv/lib/python3.12/site-packages/rich/file_proxy.py:53, in FileProxy.flush(self)
     51 output = \"\".join(self.__buffer)
     52 if output:
---> 53     self.__console.print(output)
     54 del self.__buffer[:]

File ~/anamalib/.venv/lib/python3.12/site-packages/rich/console.py:1678, in Console.print(self, sep, end, style, justify, overflow, no_wrap, emoji, markup, highlight, width, height, crop, soft_wrap, new_line_start, *objects)
   1676     crop = False
   1677 render_hooks = self._render_hooks[:]
-> 1678 with self:
   1679     renderables = self._collect_renderables(
   1680         objects,
   1681         sep,
   (...)
   1686         highlight=highlight,
   1687     )
   1688     for hook in render_hooks:

File ~/anamalib/.venv/lib/python3.12/site-packages/rich/console.py:864, in Console.__exit__(self, exc_type, exc_value, traceback)
    862 def __exit__(self, exc_type: Any, exc_value: Any, traceback: Any) -> None:
    863     \"\"\"Exit buffer context.\"\"\"
--> 864     self._exit_buffer()

File ~/anamalib/.venv/lib/python3.12/site-packages/rich/console.py:822, in Console._exit_buffer(self)
    820 \"\"\"Leave buffer context, and render content if required.\"\"\"
    821 self._buffer_index -= 1
--> 822 self._check_buffer()

File ~/anamalib/.venv/lib/python3.12/site-packages/rich/console.py:2019, in Console._check_buffer(self)
   2016     return
   2018 try:
-> 2019     self._write_buffer()
   2020 except BrokenPipeError:
   2021     self.on_broken_pipe()

File ~/anamalib/.venv/lib/python3.12/site-packages/rich/console.py:2035, in Console._write_buffer(self)
   2032 if self.is_jupyter:  # pragma: no cover
   2033     from .jupyter import display
-> 2035     display(self._buffer, self._render_buffer(self._buffer[:]))
   2036     del self._buffer[:]
   2037 else:

File ~/anamalib/.venv/lib/python3.12/site-packages/rich/jupyter.py:91, in display(segments, text)
     88 try:
     89     from IPython.display import display as ipython_display
---> 91     ipython_display(jupyter_renderable)
     92 except ModuleNotFoundError:
     93     # Handle the case where the Console has force_jupyter=True,
     94     # but IPython is not installed.
     95     pass

File ~/anamalib/.venv/lib/python3.12/site-packages/IPython/core/display_functions.py:305, in display(include, exclude, metadata, transient, display_id, raw, clear, *objs, **kwargs)
    302         if metadata:
    303             # kwarg-specified metadata gets precedence
    304             _merge(md_dict, metadata)
--> 305         publish_display_data(data=format_dict, metadata=md_dict, **kwargs)
    306 if display_id:
    307     return DisplayHandle(display_id)

File ~/anamalib/.venv/lib/python3.12/site-packages/IPython/core/display_functions.py:93, in publish_display_data(data, metadata, source, transient, **kwargs)
     90 if transient:
     91     kwargs['transient'] = transient
---> 93 display_pub.publish(
     94     data=data,
     95     metadata=metadata,
     96     **kwargs
     97 )

File ~/anamalib/.venv/lib/python3.12/site-packages/ipykernel/zmqshell.py:103, in ZMQDisplayPublisher.publish(self, data, metadata, transient, update)
     81 def publish(
     82     self,
     83     data,
   (...)
     86     update=False,
     87 ):
     88     \"\"\"Publish a display-data message
     89 
     90     Parameters
   (...)
    101         If True, send an update_display_data message instead of display_data.
    102     \"\"\"
--> 103     self._flush_streams()
    104     if metadata is None:
    105         metadata = {}

File ~/anamalib/.venv/lib/python3.12/site-packages/ipykernel/zmqshell.py:67, in ZMQDisplayPublisher._flush_streams(self)
     65 \"\"\"flush IO Streams prior to display\"\"\"
     66 sys.stdout.flush()
---> 67 sys.stderr.flush()

    [... skipping similar frames: Console.__exit__ at line 864 (266 times), Console._check_buffer at line 2019 (266 times), Console._exit_buffer at line 822 (266 times), Console._write_buffer at line 2035 (266 times), display at line 91 (266 times), FileProxy.flush at line 53 (266 times), Console.print at line 1678 (266 times), ZMQDisplayPublisher._flush_streams at line 67 (265 times), display at line 305 (265 times), ZMQDisplayPublisher.publish at line 103 (265 times), publish_display_data at line 93 (265 times)]

File ~/anamalib/.venv/lib/python3.12/site-packages/IPython/core/display_functions.py:305, in display(include, exclude, metadata, transient, display_id, raw, clear, *objs, **kwargs)
    302         if metadata:
    303             # kwarg-specified metadata gets precedence
    304             _merge(md_dict, metadata)
--> 305         publish_display_data(data=format_dict, metadata=md_dict, **kwargs)
    306 if display_id:
    307     return DisplayHandle(display_id)

File ~/anamalib/.venv/lib/python3.12/site-packages/IPython/core/display_functions.py:93, in publish_display_data(data, metadata, source, transient, **kwargs)
     90 if transient:
     91     kwargs['transient'] = transient
---> 93 display_pub.publish(
     94     data=data,
     95     metadata=metadata,
     96     **kwargs
     97 )

File ~/anamalib/.venv/lib/python3.12/site-packages/ipykernel/zmqshell.py:103, in ZMQDisplayPublisher.publish(self, data, metadata, transient, update)
     81 def publish(
     82     self,
     83     data,
   (...)
     86     update=False,
     87 ):
     88     \"\"\"Publish a display-data message
     89 
     90     Parameters
   (...)
    101         If True, send an update_display_data message instead of display_data.
    102     \"\"\"
--> 103     self._flush_streams()
    104     if metadata is None:
    105         metadata = {}

File ~/anamalib/.venv/lib/python3.12/site-packages/ipykernel/zmqshell.py:67, in ZMQDisplayPublisher._flush_streams(self)
     65 \"\"\"flush IO Streams prior to display\"\"\"
     66 sys.stdout.flush()
---> 67 sys.stderr.flush()

File ~/anamalib/.venv/lib/python3.12/site-packages/rich/file_proxy.py:53, in FileProxy.flush(self)
     51 output = \"\".join(self.__buffer)
     52 if output:
---> 53     self.__console.print(output)
     54 del self.__buffer[:]

File ~/anamalib/.venv/lib/python3.12/site-packages/rich/console.py:1678, in Console.print(self, sep, end, style, justify, overflow, no_wrap, emoji, markup, highlight, width, height, crop, soft_wrap, new_line_start, *objects)
   1676     crop = False
   1677 render_hooks = self._render_hooks[:]
-> 1678 with self:
   1679     renderables = self._collect_renderables(
   1680         objects,
   1681         sep,
   (...)
   1686         highlight=highlight,
   1687     )
   1688     for hook in render_hooks:

File ~/anamalib/.venv/lib/python3.12/site-packages/rich/console.py:864, in Console.__exit__(self, exc_type, exc_value, traceback)
    862 def __exit__(self, exc_type: Any, exc_value: Any, traceback: Any) -> None:
    863     \"\"\"Exit buffer context.\"\"\"
--> 864     self._exit_buffer()

File ~/anamalib/.venv/lib/python3.12/site-packages/rich/console.py:822, in Console._exit_buffer(self)
    820 \"\"\"Leave buffer context, and render content if required.\"\"\"
    821 self._buffer_index -= 1
--> 822 self._check_buffer()

File ~/anamalib/.venv/lib/python3.12/site-packages/rich/console.py:2019, in Console._check_buffer(self)
   2016     return
   2018 try:
-> 2019     self._write_buffer()
   2020 except BrokenPipeError:
   2021     self.on_broken_pipe()

File ~/anamalib/.venv/lib/python3.12/site-packages/rich/console.py:2035, in Console._write_buffer(self)
   2032 if self.is_jupyter:  # pragma: no cover
   2033     from .jupyter import display
-> 2035     display(self._buffer, self._render_buffer(self._buffer[:]))
   2036     del self._buffer[:]
   2037 else:

File ~/anamalib/.venv/lib/python3.12/site-packages/rich/jupyter.py:91, in display(segments, text)
     88 try:
     89     from IPython.display import display as ipython_display
---> 91     ipython_display(jupyter_renderable)
     92 except ModuleNotFoundError:
     93     # Handle the case where the Console has force_jupyter=True,
     94     # but IPython is not installed.
     95     pass

File ~/anamalib/.venv/lib/python3.12/site-packages/IPython/core/display_functions.py:298, in display(include, exclude, metadata, transient, display_id, raw, clear, *objs, **kwargs)
    296     publish_display_data(data=obj, metadata=metadata, **kwargs)
    297 else:
--> 298     format_dict, md_dict = format(obj, include=include, exclude=exclude)
    299     if not format_dict:
    300         # nothing to display (e.g. _ipython_display_ took over)
    301         continue

File ~/anamalib/.venv/lib/python3.12/site-packages/IPython/core/formatters.py:148, in DisplayFormatter.format(self, obj, include, exclude)
    145 format_dict = {}
    146 md_dict = {}
--> 148 if self.ipython_display_formatter(obj):
    149     # object handled itself, don't proceed
    150     return {}, {}
    152 format_dict, md_dict = self.mimebundle_formatter(obj, include=include, exclude=exclude)

File ~/anamalib/.venv/lib/python3.12/site-packages/traitlets/traitlets.py:687, in TraitType.__get__(self, obj, cls)
    685     return self
    686 else:
--> 687     return t.cast(G, self.get(obj, cls))

File ~/anamalib/.venv/lib/python3.12/site-packages/traitlets/traitlets.py:666, in TraitType.get(self, obj, cls)
    664     raise TraitError(\"Unexpected error in TraitType: default value not set properly\") from e
    665 else:
--> 666     return t.cast(G, value)

RecursionError: maximum recursion depth exceeded"
}

Code of Conduct

  • I agree to follow this project's Code of Conduct
@1312354o
Copy link
Author

Actually the same bug as that of issue #2145 due to using notebook. Brutally remove callback helps.

@samet-akcay
Copy link
Contributor

This has actually been addressed in #2283.

If you are using the PyPI version of Anomalib, v1.2.0 will address this issue, which will be on PyPI on 31st of October.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants