<commit_before>import sys
import os

# Functions and classes for loading and using the Inception model v3.
import inception

# Load the Inception model so it is ready for classifying images.
try:
  model = inception.Inception()
except FileNotFoundError:
  print ('###### error ######')
  sys.exit('this script requires inception.maybe_download() executed from init.py at least once')

# Helper-function for classifying and plotting images
def classify(image_path):
    #display(Image(image_path))
    pred = model.classify(image_path=image_path)
    model.print_scores(pred=pred, k=10, only_first_name=True)

def main():
  if len(sys.argv) >= 2:
    image_path = sys.argv[1]
  else:
    print ('###### error ######')
    sys.exit('you need to specify a valid image')

  # We use the test image that comes with inception model v3 if arg 1 is 'test'
  if sys.argv[1] == 'test':
    image_path = os.path.join(inception.data_dir, 'cropped_panda.jpg')

  if not os.path.exists(image_path):
    print ('###### error ######')
    sys.exit('not a valid file path')

  print ("Classifying image ", image_path)
  print ('###### results ######')
  classify(image_path)

if __name__ == '__main__':
  main()<commit_msg>attempt to ignore deprecation warnings<commit_after>import sys
import os

# Functions and classes for loading and using the Inception model v3.
import inception

# Load the Inception model so it is ready for classifying images.
try:
  model = inception.Inception()
except FileNotFoundError:
  print ('###### error ######')
  sys.exit('this script requires inception.maybe_download() executed from init.py at least once')

# Helper-function for classifying and plotting images
def classify(image_path):
    #display(Image(image_path))
    pred = model.classify(image_path=image_path)
    model.print_scores(pred=pred, k=10, only_first_name=True)

def main():
  if len(sys.argv) >= 2:
    image_path = sys.argv[1]
  else:
    print ('###### error ######')
    sys.exit('you need to specify a valid image')

  # We use the test image that comes with inception model v3 if arg 1 is 'test'
  if sys.argv[1] == 'test':
    image_path = os.path.join(inception.data_dir, 'cropped_panda.jpg')

  if not os.path.exists(image_path):
    print ('###### error ######')
    sys.exit('not a valid file path')

  print ("Classifying image ", image_path)
  print ('###### results ######')
  import warnings
  with warnings.catch_warnings():
    warnings.filterwarnings("ignore",category=DeprecationWarning)
    classify(image_path)

if __name__ == '__main__':
  main()
{'fraction_non_alphanumeric': 0.1396167383652718, 'fraction_numerical': 0.006257332811888932, 'mean_word_length': 4.39662447257384, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '622110', 'n_tokens_mistral': 815, 'n_tokens_neox': 781, 'n_words': 246}