For ease of use, a generator is also possible: | |
thon | |
from transformers import pipeline | |
pipe = pipeline("text-classification") | |
def data(): | |
while True: | |
# This could come from a dataset, a database, a queue or HTTP request | |
# in a server | |
# Caveat: because this is iterative, you cannot use num_workers > 1 variable | |
# to use multiple threads to preprocess data. |