get_predict.py 961 B

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. import text_processing
  2. import model_helpers
  3. import azure_storage_helpers
  4. ###############
  5. # GETTING MODEL
  6. ###############
  7. # GETTING MODEL FROM BLOB STORAGE
  8. # Blob Storage config
  9. # TODO: replace the values with your own
  10. blobConfig = {
  11. 'ACCOUNTNAME': 'YOUR_STORAGE_NAME',
  12. 'KEY': 'YOUR_KEY',
  13. 'CONTAINER': 'main'
  14. }
  15. # Initializing Blob Storage service
  16. blob_service = azure_storage_helpers.InitializeBlobService(blobConfig)
  17. # Model local path
  18. modelPath = 'model.pkl'
  19. # Getting file from Blob Storage and storing it locally
  20. # Comment out this line if you want to use a local one
  21. azure_storage_helpers.getFile(blobConfig,blob_service,'model.pkl',modelPath)
  22. # Loading model
  23. model = azure_storage_helpers.getModel(modelPath)
  24. #############
  25. # PREDICTIONS
  26. #############
  27. # Sample text to predict a label for
  28. # TODO: Replace it with your own
  29. txt = "Text to get a prediction for"
  30. # Getting a prediction
  31. prediction = model_helpers.getPrediction(txt,model)