Azure-Samples / Machine-Learning-Operationalization

Deploying machine learning models to Azure
MIT License
62 stars 67 forks source link

Download Bars do not work #32

Open mhamilton723 opened 7 years ago

mhamilton723 commented 7 years ago

fancy printouts from things like keras' model downloader do not work.

from keras.applications.resnet50 import ResNet50
ResNet50(include_top=False)

Error:

  File "/var/azureml-app/driver_jabil.py", line 75, in init
    Predictor().load_model(model_path="lightgbm_classifier.model")
  File "/var/azureml-app/driver_jabil.py", line 47, in load_model
    self.model = ResNet50(include_top=False)
  File "/opt/conda/lib/python3.5/site-packages/keras/applications/resnet50.py", line 263, in ResNet50
    md5_hash='a268eb855778b3df3c7506639542a6af')
  File "/opt/conda/lib/python3.5/site-packages/keras/utils/data_utils.py", line 220, in get_file
    urlretrieve(origin, fpath, dl_progress)
  File "/opt/conda/lib/python3.5/urllib/request.py", line 224, in urlretrieve
    reporthook(blocknum, bs, size)
  File "/opt/conda/lib/python3.5/site-packages/keras/utils/data_utils.py", line 215, in dl_progress
    ProgressTracker.progbar.update(count * block_size)
  File "/opt/conda/lib/python3.5/site-packages/keras/utils/generic_utils.py", line 345, in update
    sys.stdout.flush()
  File "/var/azureml-app/print_hook.py", line 79, in __getattr__
    return self._original_fd.__getattr__(name)
AttributeError: '_io.TextIOWrapper' object has no attribute '__getattr__'

Workaround:

def blockPrint():
    sys.stdout = open(os.devnull, 'w')

def enablePrint():
    sys.stdout = sys.__stdout__

blockPrint()
ResNet50(include_top=False)
enablePrint()