wko_projekt/Projekt widzenie komputerowe.ipynb

1 line
802 KiB
Plaintext
Raw Permalink Normal View History

2023-02-01 23:04:00 +01:00
{"metadata":{"colab":{"provenance":[]},"kernelspec":{"name":"python3","display_name":"Python 3","language":"python"},"language_info":{"name":"python","version":"3.7.12","mimetype":"text/x-python","codemirror_mode":{"name":"ipython","version":3},"pygments_lexer":"ipython3","nbconvert_exporter":"python","file_extension":".py"},"accelerator":"GPU","gpuClass":"standard"},"nbformat_minor":4,"nbformat":4,"cells":[{"cell_type":"code","source":"#!git clone https://github.com/spMohanty/PlantVillage-Dataset\n#!cd PlantVillage-Dataset","metadata":{"colab":{"base_uri":"https://localhost:8080/"},"id":"xw8twvywqDzo","outputId":"fcf7569b-f718-4b4a-a5a5-3fcb3b7f6796","execution":{"iopub.status.busy":"2023-02-01T19:15:14.094260Z","iopub.execute_input":"2023-02-01T19:15:14.095619Z","iopub.status.idle":"2023-02-01T19:15:14.123112Z","shell.execute_reply.started":"2023-02-01T19:15:14.095041Z","shell.execute_reply":"2023-02-01T19:15:14.122051Z"},"trusted":true},"execution_count":1,"outputs":[]},{"cell_type":"code","source":"import numpy as np\nimport pickle\nimport cv2\nimport tensorflow as tf\nimport tensorflow_addons as tfa\nfrom tensorflow import keras\nfrom tensorflow.keras import layers\nfrom os import listdir, mkdir\nfrom sklearn.preprocessing import LabelBinarizer\nfrom sklearn.preprocessing import MultiLabelBinarizer\nfrom sklearn.model_selection import train_test_split\n#from keras.utils import img_to_array\nfrom keras.preprocessing.image import img_to_array\nimport matplotlib.pyplot as plt","metadata":{"id":"pr-wBQrbNiWI","execution":{"iopub.status.busy":"2023-02-01T19:15:14.124957Z","iopub.execute_input":"2023-02-01T19:15:14.125313Z","iopub.status.idle":"2023-02-01T19:15:21.587256Z","shell.execute_reply.started":"2023-02-01T19:15:14.125279Z","shell.execute_reply":"2023-02-01T19:15:21.586211Z"},"trusted":true},"execution_count":2,"outputs":[]},{"cell_type":"code","source":"data_dir = \"/kaggle/input/plantvillage-dataset/color\"\n\nclasses = listdir(data_dir)\nclasses","metadata":{"colab":{"base_uri":"https://localhost:8080/"},"id":"TpopUQapl40P","outputId":"9e86badc-6858-4272-e72e-c616e467bc74","execution":{"iopub.status.busy":"2023-02-01T19:15:21.589441Z","iopub.execute_input":"2023-02-01T19:15:21.590085Z","iopub.status.idle":"2023-02-01T19:15:21.613307Z","shell.execute_reply.started":"2023-02-01T19:15:21.590047Z","shell.execute_reply":"2023-02-01T19:15:21.611323Z"},"trusted":true},"execution_count":3,"outputs":[{"execution_count":3,"output_type":"execute_result","data":{"text/plain":"['Tomato___Late_blight',\n 'Tomato___healthy',\n 'Grape___healthy',\n 'Orange___Haunglongbing_(Citrus_greening)',\n 'Soybean___healthy',\n 'Squash___Powdery_mildew',\n 'Potato___healthy',\n 'Corn_(maize)___Northern_Leaf_Blight',\n 'Tomato___Early_blight',\n 'Tomato___Septoria_leaf_spot',\n 'Corn_(maize)___Cercospora_leaf_spot Gray_leaf_spot',\n 'Strawberry___Leaf_scorch',\n 'Peach___healthy',\n 'Apple___Apple_scab',\n 'Tomato___Tomato_Yellow_Leaf_Curl_Virus',\n 'Tomato___Bacterial_spot',\n 'Apple___Black_rot',\n 'Blueberry___healthy',\n 'Cherry_(including_sour)___Powdery_mildew',\n 'Peach___Bacterial_spot',\n 'Apple___Cedar_apple_rust',\n 'Tomato___Target_Spot',\n 'Pepper,_bell___healthy',\n 'Grape___Leaf_blight_(Isariopsis_Leaf_Spot)',\n 'Potato___Late_blight',\n 'Tomato___Tomato_mosaic_virus',\n 'Strawberry___healthy',\n 'Apple___healthy',\n 'Grape___Black_rot',\n 'Potato___Early_blight',\n 'Cherry_(including_sour)___healthy',\n 'Corn_(maize)___Common_rust_',\n 'Grape___Esca_(Black_Measles)',\n 'Raspberry___healthy',\n 'Tomato___Leaf_Mold',\n 'Tomato___Spider_mites Two-spotted_spider_mite',\n 'Pepper,_bell___Bacterial_spot',\n 'Corn_(maize)___healthy']"},"metadata":{}}]},{"cell_type":"code","source":"#mkdir(data_dir + 'test_data')\n#mkdir(data_dir + 'train_data')","metadata":{"id":"aV_64FLUnbLg","execution":{"iopub.status.busy":"2023-02-01T19:15:21.615211Z","iopub.execute_input":"2023-02-01T19:15:21.616436Z","iopub.status.idle":"2023-02-01T19:15:21.620493Z","shell.execute_reply.started":"2023-02-01T19:15:21.616401Z","shell.execute_reply":"2023-02-0