I'm developing a web application where a keras model is trained on HTTP request received by a Flask server. I deploy the server using Gevent and monkey patch it:
from gevent import monkey
monkey.patch_all()
The keras model is trained using a standard Generator and the 'flow_from_directory' method:
train_generator = ImageDataGenerator(rescale=1 / 255.0)
train_data = train_generator.flow_from_directory(directory='my_dir'),
batch_size=16,
target_size=(224, 224))
When the above code is executed, it displays the message below and then freezes.
Found 90 images belonging to 4 classes.
The following lines are not executed. When I comment the monkey patching, everything works fine.
Could someone explain me what exactly the monkey patching does and how it affects the keras Generator? Is there any better solution to triger the training by the server?