Object of type 'LazyFilter' has no len()
See original GitHub issueIβm running into this weird issue, and Iβm not sure why adding manifests should create a lazy iterator?
In [5]: m = prepare_ali_meeting('/export/c01/corpora6/AliMeeting')
Preparing Train: 100%|ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ| 209/209 [02:56<00:00, 1.19it/s]
WARNING:root:Removed 241 supervisions starting after the end of the recording.
WARNING:root:Trimmed 5 supervisions exceeding the end of the recording.
WARNING:root:SupervisionSet contains 2 supervisions that start at 0 for recording R1019_M4026 (channel 0). Did you forget to set supervision start times?
WARNING:root:SupervisionSet contains 2 supervisions that start at 0 for recording R1019_M4028 (channel 0). Did you forget to set supervision start times?
WARNING:root:SupervisionSet contains 2 supervisions that start at 0 for recording R1019_M4030 (channel 0). Did you forget to set supervision start times?
WARNING:root:SupervisionSet contains 4 supervisions that start at 0 for recording R1019_M4031 (channel 0). Did you forget to set supervision start times?
WARNING:root:SupervisionSet contains 2 supervisions that start at 0 for recording R1019_M4033 (channel 0). Did you forget to set supervision start times?
WARNING:root:SupervisionSet contains 2 supervisions that start at 0 for recording R1019_M4035 (channel 0). Did you forget to set supervision start times?
WARNING:root:SupervisionSet contains 2 supervisions that start at 0 for recording R1019_M4039 (channel 0). Did you forget to set supervision start times?
WARNING:root:SupervisionSet contains 2 supervisions that start at 0 for recording R1019_M4041 (channel 0). Did you forget to set supervision start times?
WARNING:root:SupervisionSet contains 2 supervisions that start at 0 for recording R1019_M4043 (channel 0). Did you forget to set supervision start times?
WARNING:root:SupervisionSet contains 2 supervisions that start at 0 for recording R1019_M4051 (channel 0). Did you forget to set supervision start times?
WARNING:root:SupervisionSet contains 4 supervisions that start at 0 for recording R1019_M4052 (channel 0). Did you forget to set supervision start times?
WARNING:root:SupervisionSet contains 2 supervisions that start at 0 for recording R1021_M1935 (channel 0). Did you forget to set supervision start times?
WARNING:root:SupervisionSet contains 2 supervisions that start at 0 for recording R1021_M1942 (channel 0). Did you forget to set supervision start times?
WARNING:root:SupervisionSet contains 2 supervisions that start at 0 for recording R1021_M1944 (channel 0). Did you forget to set supervision start times?
WARNING:root:SupervisionSet contains 2 supervisions that start at 0 for recording R1021_M1959 (channel 0). Did you forget to set supervision start times?
WARNING:root:SupervisionSet contains 2 supervisions that start at 0 for recording R1021_M1961 (channel 0). Did you forget to set supervision start times?
Preparing Eval: 100%|βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ| 8/8 [00:00<00:00, 10.20it/s]
Preparing Test: 100%|βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ| 20/20 [00:01<00:00, 11.17it/s]
In [6]: s = m["eval"]["supervisions"]
In [7]: s1 = s.filter(lambda seg: seg.duration >= 0.5)
In [8]: len(s1)
Out[8]: 5193
In [9]: s = m["eval"]["supervisions"] + m["test"]["supervisions"]
In [10]: s1 = s.filter(lambda seg: seg.duration >= 0.5)
/export/c07/draj/lhotse/lhotse/lazy.py:327: UserWarning: A lambda was passed to LazyFilter: it may prevent you from forking this process. If you experience issues with num_workers > 0 in torch.utils.data.DataLoader, try passing a regular function instead.
"A lambda was passed to LazyFilter: it may prevent you from forking this process. "
In [11]: len(s1)
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
<ipython-input-11-a700e8f68e2d> in <module>
----> 1 len(s1)
/export/c07/draj/lhotse/lhotse/supervision.py in __len__(self)
815
816 def __len__(self) -> int:
--> 817 return len(self.segments)
TypeError: object of type 'LazyFilter' has no len()
Any suggestions?
Issue Analytics
- State:
- Created a year ago
- Comments:7
Top Results From Across the Web
object of type 'filter' has no len() [duplicate] - python
This is one of the major gotchas in switching from Python2 to Python3. filter returns an iterator rather than a list. I don't...
Read more >TypeError: object of type 'filter' has no len() in Python
The Python TypeError: object of type 'filter' has no len() occurs when we pass a `filter` object to the `len()` function.
Read more >Fix 'filter' object has no len () Β· 5d6f5eb7ab - karbor - OpenDev
Karbor has a python3 compatibility issue where it will fail with: TypeError: object of type 'filter' has no len(). 'filter' is a list...
Read more >object of type 'builtin_function_or_method' has no len()
For the following code in section 4/11 of PygLatin. My program runs but once a word is typed then you pressed enter this...
Read more >TypeError: object of type 'Token' has no len() Β· Issue #2826
TypeError: object of type 'Token' has no len() #2826. Closed. Ihebzayen opened this issue on Jun 20 Β· 12 comments.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
we can either
remove_missing_recordings_and_supervisions
with a two-pass strategy that first iterates to get the sets of compatible/incompatible IDs, and in the second pass filters out the incompatible ones.or
manifest.to_eager()
(will break for people with not enough CPU RAM and large data)You can call .to_eager() on the resulting manifest to evaluate the expression. I started moving multiple operations to lazy evaluation a while ago, the only downside I can see is missing len. Itβs just an extra function call away and for that we get memory-friendly behavior by default.