{"metadata":{"kernelspec":{"language":"python","display_name":"Python 3","name":"python3"},"language_info":{"name":"python","version":"3.10.12","mimetype":"text/x-python","codemirror_mode":{"name":"ipython","version":3},"pygments_lexer":"ipython3","nbconvert_exporter":"python","file_extension":".py"},"kaggle":{"accelerator":"none","dataSources":[{"sourceId":5048,"databundleVersionId":868335,"sourceType":"competition"},{"sourceId":7095532,"sourceType":"datasetVersion","datasetId":4089322}],"dockerImageVersionId":30587,"isInternetEnabled":true,"language":"python","sourceType":"notebook","isGpuEnabled":false}},"nbformat_minor":4,"nbformat":4,"cells":[{"cell_type":"code","source":"import numpy as np # linear algebra\nimport pandas as pd # data processing, CSV file I/O (e.g. pd.read_csv)\n\nimport os\n\n# import fast ai vision library\nfrom fastai.vision.all import *\n\n\nlearn = load_learner('/kaggle/input/ml-model/cnn_model.pth')\n\n# Load and preprocess the single image you want to predict\nimg_path = '/kaggle/input/state-farm-distracted-driver-detection/imgs/test/img_10.jpg'  # Replace with the path to your image\nimg = PILImage.create(img_path)\n\n# Make the prediction\npred, _, prob = learn.predict(img)\n\nlabel = {\n    'c0': 'safe driving',\n    'c1': 'texting - right',\n    'c2': 'talking on the phone - right',\n    'c3': 'texting - left',\n    'c4': 'talking on the phone - left',\n    'c5': 'operating the radio',\n    'c6': 'drinking',\n    'c7': 'reaching behind',\n    'c8': 'hair and makeup',\n    'c9': 'talking to passenger'\n}\nprint(label[pred])\nimg.show()","metadata":{"_uuid":"8f2839f25d086af736a60e9eeb907d3b93b6e0e5","_cell_guid":"b1076dfc-b9ad-4769-8c92-a6c4dae69d19","execution":{"iopub.status.busy":"2023-12-01T04:25:18.491821Z","iopub.execute_input":"2023-12-01T04:25:18.492718Z","iopub.status.idle":"2023-12-01T04:25:19.620202Z","shell.execute_reply.started":"2023-12-01T04:25:18.492678Z","shell.execute_reply":"2023-12-01T04:25:19.618974Z"},"trusted":true},"execution_count":null,"outputs":[]}]}