party -d cpu --threads 2 ocr -i 516100238_0002.xml 516100238_0002_ocr.xml
Downloading 10.5281/zenodo.14616981 ━━━━━━━━━━━━━ 0% 0/0 bytes -:--:-- 0:00:00
Compiling model ✓
Files 0% 0/1 -:--:-- 0:00:42
Processing 516100238_0002.xml ━━━━━━━━━━━━━━━━━━━━━━━━━ 0% 0/0 -:--:-- 0:00:42
╭───────────────────── Traceback (most recent call last) ──────────────────────╮
│ /home/stweil/venv3.11_party/bin/party:8 in <module> │
│ │
│ 5 from party.cli import cli │
│ 6 if __name__ == '__main__': │
│ 7 │ sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0]) │
│ ❱ 8 │ sys.exit(cli()) │
│ 9 │
│ │
│ /home/stweil/venv3.11_party/lib/python3.11/site-packages/click/core.py:1161 │
│ in __call__ │
│ │
│ /home/stweil/venv3.11_party/lib/python3.11/site-packages/click/core.py:1082 │
│ in main │
│ │
│ /home/stweil/venv3.11_party/lib/python3.11/site-packages/click/core.py:1697 │
│ in invoke │
│ │
│ /home/stweil/venv3.11_party/lib/python3.11/site-packages/click/core.py:1443 │
│ in invoke │
│ │
│ /home/stweil/venv3.11_party/lib/python3.11/site-packages/click/core.py:788 │
│ in invoke │
│ │
│ /home/stweil/venv3.11_party/lib/python3.11/site-packages/click/decorators.py │
│ :33 in new_func │
│ │
│ /home/stweil/venv3.11_party/lib/python3.11/site-packages/party/cli/pred.py:1 │
│ 93 in ocr │
│ │
│ 190 │ │ │ │ │ │ │ │ │ │ batch_size=batch_size) │
│ 191 │ │ │ │ │
│ 192 │ │ │ │ preds = [] │
│ ❱ 193 │ │ │ │ for pred in predictor: │
│ 194 │ │ │ │ │ logger.info(f'pred: {pred}') │
│ 195 │ │ │ │ │ preds.append(pred.prediction) │
│ 196 │ │ │ │ │ progress.update(rec_prog, advance=1) │
│ │
│ /home/stweil/venv3.11_party/lib/python3.11/site-packages/party/pred.py:152 │
│ in __next__ │
│ │
│ 149 │ │ │ │ │ │ │ bounds.lines) │
│ 150 │ │
│ 151 │ def __next__(self): │
│ ❱ 152 │ │ pred_str, line = next(self._pred) │
│ 153 │ │ if self.prompt_mode == 'curves': │
│ 154 │ │ │ return BaselineOCRRecord(prediction=pred_str, │
│ 155 │ │ │ │ │ │ │ │ │ cuts=tuple(), │
│ │
│ /home/stweil/venv3.11_party/lib/python3.11/site-packages/torch/utils/_contex │
│ tlib.py:36 in generator_context │
│ │
│ 33 │ │ try: │
│ 34 │ │ │ # Issuing `None` to a generator fires it up │
│ 35 │ │ │ with ctx_factory(): │
│ ❱ 36 │ │ │ │ response = gen.send(None) │
│ 37 │ │ │ │
│ 38 │ │ │ while True: │
│ 39 │ │ │ │ try: │
│ │
│ /home/stweil/venv3.11_party/lib/python3.11/site-packages/party/fusion.py:631 │
│ in predict_string │
│ │
│ 628 │ │ │
│ 629 │ │ """ │
│ 630 │ │ tokenizer = OctetTokenizer() │
│ ❱ 631 │ │ for preds in self.predict_tokens(encoder_input=encoder_input, │
│ 632 │ │ │ │ │ │ │ │ │ │ curves=curves, │
│ 633 │ │ │ │ │ │ │ │ │ │ boxes=boxes, │
│ 634 │ │ │ │ │ │ │ │ │ │ eos_id=eos_id): │
│ │
│ /home/stweil/venv3.11_party/lib/python3.11/site-packages/torch/utils/_contex │
│ tlib.py:36 in generator_context │
│ │
│ 33 │ │ try: │
│ 34 │ │ │ # Issuing `None` to a generator fires it up │
│ 35 │ │ │ with ctx_factory(): │
│ ❱ 36 │ │ │ │ response = gen.send(None) │
│ 37 │ │ │ │
│ 38 │ │ │ while True: │
│ 39 │ │ │ │ try: │
│ │
│ /home/stweil/venv3.11_party/lib/python3.11/site-packages/party/fusion.py:558 │
│ in predict_tokens │
│ │
│ 555 │ │ │ │ │ │ │ │ dtype=next(self.encoder.parameters() │
│ 556 │ │ │ │
│ 557 │ │ │ # add line embeddings to encoder hidden states │
│ ❱ 558 │ │ │ line_embeds = self.line_embedding(batch).unsqueeze(1).expa │
│ 559 │ │ │ exp_encoder_hidden_states = encoder_hidden_states[:bsz, .. │
│ 560 │ │ │ │
│ 561 │ │ │ # prefill step │
│ │
│ /home/stweil/venv3.11_party/lib/python3.11/site-packages/torch/nn/modules/mo │
│ dule.py:1736 in _wrapped_call_impl │
│ │
│ 1733 │ │ if self._compiled_call_impl is not None: │
│ 1734 │ │ │ return self._compiled_call_impl(*args, **kwargs) # type: │
│ 1735 │ │ else: │
│ ❱ 1736 │ │ │ return self._call_impl(*args, **kwargs) │
│ 1737 │ │
│ 1738 │ # torchrec tests the code consistency with the following code │
│ 1739 │ # fmt: off │
│ │
│ /home/stweil/venv3.11_party/lib/python3.11/site-packages/torch/nn/modules/mo │
│ dule.py:1747 in _call_impl │
│ │
│ 1744 │ │ if not (self._backward_hooks or self._backward_pre_hooks or s │
│ 1745 │ │ │ │ or _global_backward_pre_hooks or _global_backward_hoo │
│ 1746 │ │ │ │ or _global_forward_hooks or _global_forward_pre_hooks │
│ ❱ 1747 │ │ │ return forward_call(*args, **kwargs) │
│ 1748 │ │ │
│ 1749 │ │ result = None │
│ 1750 │ │ called_always_called_hooks = set() │
│ │
│ /home/stweil/venv3.11_party/lib/python3.11/site-packages/party/modules/promp │
│ t.py:79 in forward │
│ │
│ 76 │ │ embeddings = torch.empty((0, self.embed_dim), │
│ 77 │ │ │ │ │ │ │ │ device=self.point_embeddings.weight.de │
│ 78 │ │ if curves is not None: │
│ ❱ 79 │ │ │ curve_embeddings = self._embed_curves(curves) │
│ 80 │ │ │ embeddings = torch.cat([embeddings, curve_embeddings]) │
│ 81 │ │ if boxes is not None: │
│ 82 │ │ │ box_embeddings = self._embed_boxes(boxes) │
│ │
│ /home/stweil/venv3.11_party/lib/python3.11/site-packages/party/modules/promp │
│ t.py:55 in _embed_curves │
│ │
│ 52 │ def _embed_curves(self, curves: torch.FloatTensor): │
│ 53 │ │ point_embedding = self._positional_embed(curves) │
│ 54 │ │ point_embedding += self.point_embeddings.weight[:4] │
│ ❱ 55 │ │ return point_embedding.view(curves.shape[0], -1) │
│ 56 │ │
│ 57 │ def _embed_boxes(self, boxes: torch.FloatTensor): │
│ 58 │ │ box_embedding = self._positional_embed(boxes) │
│ │
│ /home/stweil/venv3.11_party/lib/python3.11/site-packages/lightning/fabric/ut │
│ ilities/init.py:54 in __torch_function__ │
│ │
│ 51 │ ) -> Any: │
│ 52 │ │ kwargs = kwargs or {} │
│ 53 │ │ if not self.enabled: │
│ ❱ 54 │ │ │ return func(*args, **kwargs) │
│ 55 │ │ if getattr(func, "__module__", None) == "torch.nn.init": │
│ 56 │ │ │ if "tensor" in kwargs: │
│ 57 │ │ │ │ return kwargs["tensor"] │
│ │
│ /home/stweil/venv3.11_party/lib/python3.11/site-packages/torch/utils/_device │
│ .py:106 in __torch_function__ │
│ │
│ 103 │ │ kwargs = kwargs or {} │
│ 104 │ │ if func in _device_constructors() and kwargs.get('device') is │
│ 105 │ │ │ kwargs['device'] = self.device │
│ ❱ 106 │ │ return func(*args, **kwargs) │
│ 107 │
│ 108 # NB: This is directly called from C++ in torch/csrc/Device.cpp │
│ 109 def device_decorator(device, func): │
│ │
│ /home/stweil/venv3.11_party/lib/python3.11/site-packages/torch/utils/_device │
│ .py:106 in __torch_function__ │
│ │
│ 103 │ │ kwargs = kwargs or {} │
│ 104 │ │ if func in _device_constructors() and kwargs.get('device') is │
│ 105 │ │ │ kwargs['device'] = self.device │
│ ❱ 106 │ │ return func(*args, **kwargs) │
│ 107 │
│ 108 # NB: This is directly called from C++ in torch/csrc/Device.cpp │
│ 109 def device_decorator(device, func): │
╰──────────────────────────────────────────────────────────────────────────────╯
RuntimeError: cannot reshape tensor of 0 elements into shape [0, -1] because the
unspecified dimension size -1 can be any value and is ambiguous
The image 516100238_0002.jpg can be processed with
kraken --input 516100238_0002.jpg 516100238_0002.xml- --alto segment -blto create an ALTO file 516100238_0002.xml, but party fails with this ALTO file: