<jupyter_start><jupyter_text>Image Dataset Details<jupyter_code>location = 'data4'
top_model_weights_path = location+'/top_model_weights.h5'
fine_tuned_model_path = location+'/ft_model.h5'

train_data_dir = location+'/training'
validation_data_dir = location+'/validation'
train_samples = [len(os.listdir(train_data_dir+'/'+i)) for i in sorted(os.listdir(train_data_dir))]
nb_train_samples = 976
validation_samples = [len(os.listdir(validation_data_dir+'/'+i)) for i in sorted(os.listdir(validation_data_dir))]
nb_validation_samples = 176

img_width, img_height = 256,256
epochs = 50
batch_size = 16
save_bottleneck_features()
d4_model, d4_history = train_categorical_model()
plot_metrics(d4_history)
ft_model, ft_history = finetune_categorical_model()
ft_model = load_model('data4/ft_model.h5')
validation_labels = np.array([0] * validation_samples[0] + 
                             [1] * validation_samples[1] +
                             [2] * validation_samples[2])
def pipe32(image_path, model):
    urllib.request.urlretrieve(image_path, 'save.jpg')
    img = load_img('save.jpg', target_size=(256,256))
    x = img_to_array(img)
    x = x.reshape((1,)+x.shape)/255
    pred = model.predict(x)
    pred_labels = np.argmax(pred, axis=1)
    d = {0:'minor', 1:'moderate', 2:'severe'}
    for key in d.keys():
        if pred_labels[0] == key:
            print("Validating severity of damage....Result:",d[key])
    print("Severity assessment complete.")
Image('https://www.copartdirect.com/content/2007-kia-rio-front-end-damage.jpg')
pipe32('https://www.copartdirect.com/content/2007-kia-rio-front-end-damage.jpg', ft_model)
Image('http://repairablecars-forsale.com/photos/Exotic_Wrecked_Cars_F430_Spider_Red_Ferrari.jpg')
pipe32('http://repairablecars-forsale.com/photos/Exotic_Wrecked_Cars_F430_Spider_Red_Ferrari.jpg', ft_model)
Image('https://di-uploads-pod1.dealerinspire.com/depaulachevy/uploads/2015/07/Scratch-2.jpg')
pipe32('https://di-uploads-pod1.dealerinspire.com/depaulachevy/uploads/2015/07/Scratch-2.jpg', ft_model)<jupyter_output>Validating severity of damage....Result: minor
Severity assessment complete.
{'fraction_non_alphanumeric': 0.1431924882629108, 'fraction_numerical': 0.03896713615023474, 'mean_word_length': 5.141210374639769, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 4, 'https://': 4, 'lorem ipsum': 0, 'www.': 2, '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}}
{'chain_length': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '459305', 'license': 'MIT', 'n_tokens_mistral': 840, 'n_tokens_neox': 773, 'n_words': 103, 'path': 'car-damage-assessment-master/04-pipe_3.2-damage_severity_assessment.ipynb', 'repo_name': 'jrderek/Car-Damage-Tracking-and-Assessment-', 'size': '2130'}