<jupyter_start><jupyter_text>Testing Model<jupyter_code>import glob
from fastai.vision import load_learner, open_image, torch, defaults

data_directory = './image_data/'

def model_predict(file_path = './test_data/'):
    '''productionize the trained model'''
    
    defaults.device = torch.device('cpu')
    learn = load_learner(data_directory)
    test_image_directory = glob.glob(file_path + '*.jpg')
                  
    pred_class_list = []
                  
    for image in test_image_directory:
        img = open_image(fn = image)
        pred_class,pred_idx,outputs = learn.predict(img)
        img.show()
        print(pred_class)
                  
  

model_predict()<jupyter_output>trump
obama
trump
obama
hillary
obama
obama
obama
hillary
hillary
obama
trump
trump
{'fraction_non_alphanumeric': 0.09311224489795919, 'fraction_numerical': 0.0, 'mean_word_length': 2.9447236180904524, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 4, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '509987', 'license': 'MIT', 'n_tokens_mistral': 258, 'n_tokens_neox': 254, 'n_words': 51, 'path': 'model_test.ipynb', 'repo_name': 'reflexiveprophecy/fastai_any_image_classifier', 'size': '784'}