{"metadata":{"kernelspec":{"display_name":"Python 3","language":"python","name":"python3"},"language_info":{"codemirror_mode":{"name":"ipython","version":3},"file_extension":".py","mimetype":"text/x-python","name":"python","nbconvert_exporter":"python","pygments_lexer":"ipython3","version":"3.11.11"},"kaggle":{"accelerator":"none","dataSources":[{"sourceId":89850,"databundleVersionId":11256103,"sourceType":"competition"}],"isInternetEnabled":true,"language":"python","sourceType":"notebook","isGpuEnabled":false},"papermill":{"default_parameters":{},"duration":305.06529,"end_time":"2025-05-01T03:47:11.858707","environment_variables":{},"exception":null,"input_path":"__notebook__.ipynb","output_path":"__notebook__.ipynb","parameters":{},"start_time":"2025-05-01T03:42:06.793417","version":"2.6.0"},"widgets":{"application/vnd.jupyter.widget-state+json":{"state":{"007ae6317a4843bd98db51a6cd35fa70":{"model_module":"@jupyter-widgets/controls","model_module_version":"2.0.0","model_name":"HTMLModel","state":{"_dom_classes":[],"_model_module":"@jupyter-widgets/controls","_model_module_version":"2.0.0","_model_name":"HTMLModel","_view_count":null,"_view_module":"@jupyter-widgets/controls","_view_module_version":"2.0.0","_view_name":"HTMLView","description":"","description_allow_html":false,"layout":"IPY_MODEL_00e22677728344fb9aba8a6b3456f40a","placeholder":"​","style":"IPY_MODEL_8da87e0f931c4f36b55322180777c428","tabbable":null,"tooltip":null,"value":" 46.8M/46.8M [00:00&lt;00:00, 152MB/s]"}},"00e22677728344fb9aba8a6b3456f40a":{"model_module":"@jupyter-widgets/base","model_module_version":"2.0.0","model_name":"LayoutModel","state":{"_model_module":"@jupyter-widgets/base","_model_module_version":"2.0.0","_model_name":"LayoutModel","_view_count":null,"_view_module":"@jupyter-widgets/base","_view_module_version":"2.0.0","_view_name":"LayoutView","align_content":null,"align_items":null,"align_self":null,"border_bottom":null,"border_left":null,"border_right":null,"border_top":null,"bottom":null,"display":null,"flex":null,"flex_flow":null,"grid_area":null,"grid_auto_columns":null,"grid_auto_flow":null,"grid_auto_rows":null,"grid_column":null,"grid_gap":null,"grid_row":null,"grid_template_areas":null,"grid_template_columns":null,"grid_template_rows":null,"height":null,"justify_content":null,"justify_items":null,"left":null,"margin":null,"max_height":null,"max_width":null,"min_height":null,"min_width":null,"object_fit":null,"object_position":null,"order":null,"overflow":null,"padding":null,"right":null,"top":null,"visibility":null,"width":null}},"01a2488a6c3442b9a1bc35fe593ad75c":{"model_module":"@jupyter-widgets/base","model_module_version":"2.0.0","model_name":"LayoutModel","state":{"_model_module":"@jupyter-widgets/base","_model_module_version":"2.0.0","_model_name":"LayoutModel","_view_count":null,"_view_module":"@jupyter-widgets/base","_view_module_version":"2.0.0","_view_name":"LayoutView","align_content":null,"align_items":null,"align_self":null,"border_bottom":null,"border_left":null,"border_right":null,"border_top":null,"bottom":null,"display":null,"flex":null,"flex_flow":null,"grid_area":null,"grid_auto_columns":null,"grid_auto_flow":null,"grid_auto_rows":null,"grid_column":null,"grid_gap":null,"grid_row":null,"grid_template_areas":null,"grid_template_columns":null,"grid_template_rows":null,"height":null,"justify_content":null,"justify_items":null,"left":null,"margin":null,"max_height":null,"max_width":null,"min_height":null,"min_width":null,"object_fit":null,"object_position":null,"order":null,"overflow":null,"padding":null,"right":null,"top":null,"visibility":null,"width":null}},"0a4650a9b5164b129374ce98df526771":{"model_module":"@jupyter-widgets/controls","model_module_version":"2.0.0","model_name":"HTMLModel","state":{"_dom_classes":[],"_model_module":"@jupyter-widgets/controls","_model_module_version":"2.0.0","_model_name":"HTMLModel","_view_count":null,"_view_module":"@jupyter-widgets/controls","_view_module_version":"2.0.0","_view_name":"HTMLView","description":"","description_allow_html":false,"layout":"IPY_MODEL_ed6b195dbe184696b75f55b3adce2536","placeholder":"​","style":"IPY_MODEL_84d867aa73a844fba10de15b006facda","tabbable":null,"tooltip":null,"value":"Validation DataLoader 0: 100%"}},"0e9ccad12dbb4d659172e914984858cb":{"model_module":"@jupyter-widgets/base","model_module_version":"2.0.0","model_name":"LayoutModel","state":{"_model_module":"@jupyter-widgets/base","_model_module_version":"2.0.0","_model_name":"LayoutModel","_view_count":null,"_view_module":"@jupyter-widgets/base","_view_module_version":"2.0.0","_view_name":"LayoutView","align_content":null,"align_items":null,"align_self":null,"border_bottom":null,"border_left":null,"border_right":null,"border_top":null,"bottom":null,"display":null,"flex":null,"flex_flow":null,"grid_area":null,"grid_auto_columns":null,"grid_auto_flow":null,"grid_auto_rows":null,"grid_column":null,"grid_gap":null,"grid_row":null,"grid_template_areas":null,"grid_template_columns":null,"grid_template_rows":null,"height":null,"justify_content":null,"justify_items":null,"left":null,"margin":null,"max_height":null,"max_width":null,"min_height":null,"min_width":null,"object_fit":null,"object_position":null,"order":null,"overflow":null,"padding":null,"right":null,"top":null,"visibility":null,"width":null}},"16d7116cf78442ff89e7ad2d0436e18f":{"model_module":"@jupyter-widgets/controls","model_module_version":"2.0.0","model_name":"HBoxModel","state":{"_dom_classes":[],"_model_module":"@jupyter-widgets/controls","_model_module_version":"2.0.0","_model_name":"HBoxModel","_view_count":null,"_view_module":"@jupyter-widgets/controls","_view_module_version":"2.0.0","_view_name":"HBoxView","box_style":"","children":["IPY_MODEL_1c2f7b96c6604c44ad9bb02f9a9b6dcd","IPY_MODEL_e7d5c0026b6141cdac35bf2dd6089695","IPY_MODEL_6619305513604e45beda5ea1cde5760c"],"layout":"IPY_MODEL_e26a41c25b1d4711b918af6e89ca49a9","tabbable":null,"tooltip":null}},"1a7924402da0466c8d51202e57bd9855":{"model_module":"@jupyter-widgets/controls","model_module_version":"2.0.0","model_name":"HTMLModel","state":{"_dom_classes":[],"_model_module":"@jupyter-widgets/controls","_model_module_version":"2.0.0","_model_name":"HTMLModel","_view_count":null,"_view_module":"@jupyter-widgets/controls","_view_module_version":"2.0.0","_view_name":"HTMLView","description":"","description_allow_html":false,"layout":"IPY_MODEL_95d6e2046d274c61a605944e1270fc82","placeholder":"​","style":"IPY_MODEL_ac013be49c5145dcaab67cf21d06c02d","tabbable":null,"tooltip":null,"value":"Testing DataLoader 0: 100%"}},"1c2f7b96c6604c44ad9bb02f9a9b6dcd":{"model_module":"@jupyter-widgets/controls","model_module_version":"2.0.0","model_name":"HTMLModel","state":{"_dom_classes":[],"_model_module":"@jupyter-widgets/controls","_model_module_version":"2.0.0","_model_name":"HTMLModel","_view_count":null,"_view_module":"@jupyter-widgets/controls","_view_module_version":"2.0.0","_view_name":"HTMLView","description":"","description_allow_html":false,"layout":"IPY_MODEL_5c9b5d5e948f4dc0955bda7aa8588d03","placeholder":"​","style":"IPY_MODEL_710aaf5ab9314090aff8865fb4dc8aa4","tabbable":null,"tooltip":null,"value":"Sanity Checking DataLoader 0: 100%"}},"217bfc96a3ca4dd7a67c983fbb33f060":{"model_module":"@jupyter-widgets/controls","model_module_version":"2.0.0","model_name":"HBoxModel","state":{"_dom_classes":[],"_model_module":"@jupyter-widgets/controls","_model_module_version":"2.0.0","_model_name":"HBoxModel","_view_count":null,"_view_module":"@jupyter-widgets/controls","_view_module_version":"2.0.0","_view_name":"HBoxView","box_style":"","children":["IPY_MODEL_0a4650a9b5164b129374ce98df526771","IPY_MODEL_ad408540b4bd4a178bb0ac5af045a390","IPY_MODEL_f1d1a0c997ee4ba8997a6e9b27309be4"],"layout":"IPY_MODEL_c6d4e564a1b646ed8a2cba6cc61c145e","tabbable":null,"tooltip":null}},"225b12f576aa4ce8932ec917dc5d0dd2":{"model_module":"@jupyter-widgets/base","model_module_version":"2.0.0","model_name":"LayoutModel","state":{"_model_module":"@jupyter-widgets/base","_model_module_version":"2.0.0","_model_name":"LayoutModel","_view_count":null,"_view_module":"@jupyter-widgets/base","_view_module_version":"2.0.0","_view_name":"LayoutView","align_content":null,"align_items":null,"align_self":null,"border_bottom":null,"border_left":null,"border_right":null,"border_top":null,"bottom":null,"display":null,"flex":"2","flex_flow":null,"grid_area":null,"grid_auto_columns":null,"grid_auto_flow":null,"grid_auto_rows":null,"grid_column":null,"grid_gap":null,"grid_row":null,"grid_template_areas":null,"grid_template_columns":null,"grid_template_rows":null,"height":null,"justify_content":null,"justify_items":null,"left":null,"margin":null,"max_height":null,"max_width":null,"min_height":null,"min_width":null,"object_fit":null,"object_position":null,"order":null,"overflow":null,"padding":null,"right":null,"top":null,"visibility":null,"width":null}},"28c5694f9b6f4734be97b6e1be795cd5":{"model_module":"@jupyter-widgets/controls","model_module_version":"2.0.0","model_name":"HBoxModel","state":{"_dom_classes":[],"_model_module":"@jupyter-widgets/controls","_model_module_version":"2.0.0","_model_name":"HBoxModel","_view_count":null,"_view_module":"@jupyter-widgets/controls","_view_module_version":"2.0.0","_view_name":"HBoxView","box_style":"","children":["IPY_MODEL_1a7924402da0466c8d51202e57bd9855","IPY_MODEL_3a69a99b6ad6402488a84bbef32d8a61","IPY_MODEL_367aef0064414d63921ff40a2d71f5db"],"layout":"IPY_MODEL_6b6e0753b3724303801a9e832d9fa193","tabbable":null,"tooltip":null}},"341b5cdc09124a6eb89ddac17555d6a0":{"model_module":"@jupyter-widgets/controls","model_module_version":"2.0.0","model_name":"HTMLModel","state":{"_dom_classes":[],"_model_module":"@jupyter-widgets/controls","_model_module_version":"2.0.0","_model_name":"HTMLModel","_view_count":null,"_view_module":"@jupyter-widgets/controls","_view_module_version":"2.0.0","_view_name":"HTMLView","description":"","description_allow_html":false,"layout":"IPY_MODEL_01a2488a6c3442b9a1bc35fe593ad75c","placeholder":"​","style":"IPY_MODEL_4944c427d22b43129868cd23b88107ff","tabbable":null,"tooltip":null,"value":"Epoch 0: 100%"}},"367aef0064414d63921ff40a2d71f5db":{"model_module":"@jupyter-widgets/controls","model_module_version":"2.0.0","model_name":"HTMLModel","state":{"_dom_classes":[],"_model_module":"@jupyter-widgets/controls","_model_module_version":"2.0.0","_model_name":"HTMLModel","_view_count":null,"_view_module":"@jupyter-widgets/controls","_view_module_version":"2.0.0","_view_name":"HTMLView","description":"","description_allow_html":false,"layout":"IPY_MODEL_9d70f342d5234794947c12d107c05498","placeholder":"​","style":"IPY_MODEL_6538a1103c4d4e7b8fdedd0278c2be36","tabbable":null,"tooltip":null,"value":" 1/1 [00:00&lt;00:00,  1.02it/s]"}},"3a69a99b6ad6402488a84bbef32d8a61":{"model_module":"@jupyter-widgets/controls","model_module_version":"2.0.0","model_name":"FloatProgressModel","state":{"_dom_classes":[],"_model_module":"@jupyter-widgets/controls","_model_module_version":"2.0.0","_model_name":"FloatProgressModel","_view_count":null,"_view_module":"@jupyter-widgets/controls","_view_module_version":"2.0.0","_view_name":"ProgressView","bar_style":"success","description":"","description_allow_html":false,"layout":"IPY_MODEL_90d3a84da1fb4069a7f49bbb1ad3902a","max":1,"min":0,"orientation":"horizontal","style":"IPY_MODEL_f97fcf651dea4b7b9f52544c7998cb59","tabbable":null,"tooltip":null,"value":1}},"3a7af6e9996f47b9a9125e17ac0214fe":{"model_module":"@jupyter-widgets/base","model_module_version":"2.0.0","model_name":"LayoutModel","state":{"_model_module":"@jupyter-widgets/base","_model_module_version":"2.0.0","_model_name":"LayoutModel","_view_count":null,"_view_module":"@jupyter-widgets/base","_view_module_version":"2.0.0","_view_name":"LayoutView","align_content":null,"align_items":null,"align_self":null,"border_bottom":null,"border_left":null,"border_right":null,"border_top":null,"bottom":null,"display":null,"flex":null,"flex_flow":null,"grid_area":null,"grid_auto_columns":null,"grid_auto_flow":null,"grid_auto_rows":null,"grid_column":null,"grid_gap":null,"grid_row":null,"grid_template_areas":null,"grid_template_columns":null,"grid_template_rows":null,"height":null,"justify_content":null,"justify_items":null,"left":null,"margin":null,"max_height":null,"max_width":null,"min_height":null,"min_width":null,"object_fit":null,"object_position":null,"order":null,"overflow":null,"padding":null,"right":null,"top":null,"visibility":null,"width":null}},"40ec909df3c54e7187857ca91e86d2df":{"model_module":"@jupyter-widgets/controls","model_module_version":"2.0.0","model_name":"HTMLStyleModel","state":{"_model_module":"@jupyter-widgets/controls","_model_module_version":"2.0.0","_model_name":"HTMLStyleModel","_view_count":null,"_view_module":"@jupyter-widgets/base","_view_module_version":"2.0.0","_view_name":"StyleView","background":null,"description_width":"","font_size":null,"text_color":null}},"4944c427d22b43129868cd23b88107ff":{"model_module":"@jupyter-widgets/controls","model_module_version":"2.0.0","model_name":"HTMLStyleModel","state":{"_model_module":"@jupyter-widgets/controls","_model_module_version":"2.0.0","_model_name":"HTMLStyleModel","_view_count":null,"_view_module":"@jupyter-widgets/base","_view_module_version":"2.0.0","_view_name":"StyleView","background":null,"description_width":"","font_size":null,"text_color":null}},"503468f87933474f93657c8470c8963a":{"model_module":"@jupyter-widgets/controls","model_module_version":"2.0.0","model_name":"ProgressStyleModel","state":{"_model_module":"@jupyter-widgets/controls","_model_module_version":"2.0.0","_model_name":"ProgressStyleModel","_view_count":null,"_view_module":"@jupyter-widgets/base","_view_module_version":"2.0.0","_view_name":"StyleView","bar_color":null,"description_width":""}},"52587fe69ebb40d9a3a45ceddaf7d28e":{"model_module":"@jupyter-widgets/controls","model_module_version":"2.0.0","model_name":"HTMLStyleModel","state":{"_model_module":"@jupyter-widgets/controls","_model_module_version":"2.0.0","_model_name":"HTMLStyleModel","_view_count":null,"_view_module":"@jupyter-widgets/base","_view_module_version":"2.0.0","_view_name":"StyleView","background":null,"description_width":"","font_size":null,"text_color":null}},"5c9b5d5e948f4dc0955bda7aa8588d03":{"model_module":"@jupyter-widgets/base","model_module_version":"2.0.0","model_name":"LayoutModel","state":{"_model_module":"@jupyter-widgets/base","_model_module_version":"2.0.0","_model_name":"LayoutModel","_view_count":null,"_view_module":"@jupyter-widgets/base","_view_module_version":"2.0.0","_view_name":"LayoutView","align_content":null,"align_items":null,"align_self":null,"border_bottom":null,"border_left":null,"border_right":null,"border_top":null,"bottom":null,"display":null,"flex":null,"flex_flow":null,"grid_area":null,"grid_auto_columns":null,"grid_auto_flow":null,"grid_auto_rows":null,"grid_column":null,"grid_gap":null,"grid_row":null,"grid_template_areas":null,"grid_template_columns":null,"grid_template_rows":null,"height":null,"justify_content":null,"justify_items":null,"left":null,"margin":null,"max_height":null,"max_width":null,"min_height":null,"min_width":null,"object_fit":null,"object_position":null,"order":null,"overflow":null,"padding":null,"right":null,"top":null,"visibility":null,"width":null}},"624af96f1a4b4f2c9cc397fa08dee779":{"model_module":"@jupyter-widgets/controls","model_module_version":"2.0.0","model_name":"ProgressStyleModel","state":{"_model_module":"@jupyter-widgets/controls","_model_module_version":"2.0.0","_model_name":"ProgressStyleModel","_view_count":null,"_view_module":"@jupyter-widgets/base","_view_module_version":"2.0.0","_view_name":"StyleView","bar_color":null,"description_width":""}},"6538a1103c4d4e7b8fdedd0278c2be36":{"model_module":"@jupyter-widgets/controls","model_module_version":"2.0.0","model_name":"HTMLStyleModel","state":{"_model_module":"@jupyter-widgets/controls","_model_module_version":"2.0.0","_model_name":"HTMLStyleModel","_view_count":null,"_view_module":"@jupyter-widgets/base","_view_module_version":"2.0.0","_view_name":"StyleView","background":null,"description_width":"","font_size":null,"text_color":null}},"6619305513604e45beda5ea1cde5760c":{"model_module":"@jupyter-widgets/controls","model_module_version":"2.0.0","model_name":"HTMLModel","state":{"_dom_classes":[],"_model_module":"@jupyter-widgets/controls","_model_module_version":"2.0.0","_model_name":"HTMLModel","_view_count":null,"_view_module":"@jupyter-widgets/controls","_view_module_version":"2.0.0","_view_name":"HTMLView","description":"","description_allow_html":false,"layout":"IPY_MODEL_3a7af6e9996f47b9a9125e17ac0214fe","placeholder":"​","style":"IPY_MODEL_bd1b197fc1ee40da9c9cd49d8dba4144","tabbable":null,"tooltip":null,"value":" 1/1 [00:01&lt;00:00,  0.97it/s]"}},"6b6e0753b3724303801a9e832d9fa193":{"model_module":"@jupyter-widgets/base","model_module_version":"2.0.0","model_name":"LayoutModel","state":{"_model_module":"@jupyter-widgets/base","_model_module_version":"2.0.0","_model_name":"LayoutModel","_view_count":null,"_view_module":"@jupyter-widgets/base","_view_module_version":"2.0.0","_view_name":"LayoutView","align_content":null,"align_items":null,"align_self":null,"border_bottom":null,"border_left":null,"border_right":null,"border_top":null,"bottom":null,"display":"inline-flex","flex":null,"flex_flow":"row wrap","grid_area":null,"grid_auto_columns":null,"grid_auto_flow":null,"grid_auto_rows":null,"grid_column":null,"grid_gap":null,"grid_row":null,"grid_template_areas":null,"grid_template_columns":null,"grid_template_rows":null,"height":null,"justify_content":null,"justify_items":null,"left":null,"margin":null,"max_height":null,"max_width":null,"min_height":null,"min_width":null,"object_fit":null,"object_position":null,"order":null,"overflow":null,"padding":null,"right":null,"top":null,"visibility":null,"width":"100%"}},"710aaf5ab9314090aff8865fb4dc8aa4":{"model_module":"@jupyter-widgets/controls","model_module_version":"2.0.0","model_name":"HTMLStyleModel","state":{"_model_module":"@jupyter-widgets/controls","_model_module_version":"2.0.0","_model_name":"HTMLStyleModel","_view_count":null,"_view_module":"@jupyter-widgets/base","_view_module_version":"2.0.0","_view_name":"StyleView","background":null,"description_width":"","font_size":null,"text_color":null}},"7394f5fc4b154a5bbf135008535933f3":{"model_module":"@jupyter-widgets/controls","model_module_version":"2.0.0","model_name":"HTMLStyleModel","state":{"_model_module":"@jupyter-widgets/controls","_model_module_version":"2.0.0","_model_name":"HTMLStyleModel","_view_count":null,"_view_module":"@jupyter-widgets/base","_view_module_version":"2.0.0","_view_name":"StyleView","background":null,"description_width":"","font_size":null,"text_color":null}},"79961449d5d0483d96d735ec1576f41f":{"model_module":"@jupyter-widgets/controls","model_module_version":"2.0.0","model_name":"FloatProgressModel","state":{"_dom_classes":[],"_model_module":"@jupyter-widgets/controls","_model_module_version":"2.0.0","_model_name":"FloatProgressModel","_view_count":null,"_view_module":"@jupyter-widgets/controls","_view_module_version":"2.0.0","_view_name":"ProgressView","bar_style":"success","description":"","description_allow_html":false,"layout":"IPY_MODEL_a6baa400765f4e3ca3bc90481d77eee5","max":46807446,"min":0,"orientation":"horizontal","style":"IPY_MODEL_8cdb6523c7d04bab894283415321fbfa","tabbable":null,"tooltip":null,"value":46807446}},"7bc4178334554cd99a167a22323ae194":{"model_module":"@jupyter-widgets/controls","model_module_version":"2.0.0","model_name":"HBoxModel","state":{"_dom_classes":[],"_model_module":"@jupyter-widgets/controls","_model_module_version":"2.0.0","_model_name":"HBoxModel","_view_count":null,"_view_module":"@jupyter-widgets/controls","_view_module_version":"2.0.0","_view_name":"HBoxView","box_style":"","children":["IPY_MODEL_341b5cdc09124a6eb89ddac17555d6a0","IPY_MODEL_906d3f8f4dbb4aa2ac1f96f4c311f2b9","IPY_MODEL_ed1832bc32e940b8921fbb05aa7693ca"],"layout":"IPY_MODEL_f8116342f19c48dfa55b3d7500705356","tabbable":null,"tooltip":null}},"7bf7f8d633a24e19935410ac22d4d357":{"model_module":"@jupyter-widgets/controls","model_module_version":"2.0.0","model_name":"HBoxModel","state":{"_dom_classes":[],"_model_module":"@jupyter-widgets/controls","_model_module_version":"2.0.0","_model_name":"HBoxModel","_view_count":null,"_view_module":"@jupyter-widgets/controls","_view_module_version":"2.0.0","_view_name":"HBoxView","box_style":"","children":["IPY_MODEL_e0e6e4c11ed64bd7a9c4a003360fa491","IPY_MODEL_79961449d5d0483d96d735ec1576f41f","IPY_MODEL_007ae6317a4843bd98db51a6cd35fa70"],"layout":"IPY_MODEL_0e9ccad12dbb4d659172e914984858cb","tabbable":null,"tooltip":null}},"84d867aa73a844fba10de15b006facda":{"model_module":"@jupyter-widgets/controls","model_module_version":"2.0.0","model_name":"HTMLStyleModel","state":{"_model_module":"@jupyter-widgets/controls","_model_module_version":"2.0.0","_model_name":"HTMLStyleModel","_view_count":null,"_view_module":"@jupyter-widgets/base","_view_module_version":"2.0.0","_view_name":"StyleView","background":null,"description_width":"","font_size":null,"text_color":null}},"8cdb6523c7d04bab894283415321fbfa":{"model_module":"@jupyter-widgets/controls","model_module_version":"2.0.0","model_name":"ProgressStyleModel","state":{"_model_module":"@jupyter-widgets/controls","_model_module_version":"2.0.0","_model_name":"ProgressStyleModel","_view_count":null,"_view_module":"@jupyter-widgets/base","_view_module_version":"2.0.0","_view_name":"StyleView","bar_color":null,"description_width":""}},"8da87e0f931c4f36b55322180777c428":{"model_module":"@jupyter-widgets/controls","model_module_version":"2.0.0","model_name":"HTMLStyleModel","state":{"_model_module":"@jupyter-widgets/controls","_model_module_version":"2.0.0","_model_name":"HTMLStyleModel","_view_count":null,"_view_module":"@jupyter-widgets/base","_view_module_version":"2.0.0","_view_name":"StyleView","background":null,"description_width":"","font_size":null,"text_color":null}},"906d3f8f4dbb4aa2ac1f96f4c311f2b9":{"model_module":"@jupyter-widgets/controls","model_module_version":"2.0.0","model_name":"FloatProgressModel","state":{"_dom_classes":[],"_model_module":"@jupyter-widgets/controls","_model_module_version":"2.0.0","_model_name":"FloatProgressModel","_view_count":null,"_view_module":"@jupyter-widgets/controls","_view_module_version":"2.0.0","_view_name":"ProgressView","bar_style":"success","description":"","description_allow_html":false,"layout":"IPY_MODEL_ba244175d7e7486fb59ae875f29802fa","max":3,"min":0,"orientation":"horizontal","style":"IPY_MODEL_624af96f1a4b4f2c9cc397fa08dee779","tabbable":null,"tooltip":null,"value":3}},"90d3a84da1fb4069a7f49bbb1ad3902a":{"model_module":"@jupyter-widgets/base","model_module_version":"2.0.0","model_name":"LayoutModel","state":{"_model_module":"@jupyter-widgets/base","_model_module_version":"2.0.0","_model_name":"LayoutModel","_view_count":null,"_view_module":"@jupyter-widgets/base","_view_module_version":"2.0.0","_view_name":"LayoutView","align_content":null,"align_items":null,"align_self":null,"border_bottom":null,"border_left":null,"border_right":null,"border_top":null,"bottom":null,"display":null,"flex":"2","flex_flow":null,"grid_area":null,"grid_auto_columns":null,"grid_auto_flow":null,"grid_auto_rows":null,"grid_column":null,"grid_gap":null,"grid_row":null,"grid_template_areas":null,"grid_template_columns":null,"grid_template_rows":null,"height":null,"justify_content":null,"justify_items":null,"left":null,"margin":null,"max_height":null,"max_width":null,"min_height":null,"min_width":null,"object_fit":null,"object_position":null,"order":null,"overflow":null,"padding":null,"right":null,"top":null,"visibility":null,"width":null}},"95d6e2046d274c61a605944e1270fc82":{"model_module":"@jupyter-widgets/base","model_module_version":"2.0.0","model_name":"LayoutModel","state":{"_model_module":"@jupyter-widgets/base","_model_module_version":"2.0.0","_model_name":"LayoutModel","_view_count":null,"_view_module":"@jupyter-widgets/base","_view_module_version":"2.0.0","_view_name":"LayoutView","align_content":null,"align_items":null,"align_self":null,"border_bottom":null,"border_left":null,"border_right":null,"border_top":null,"bottom":null,"display":null,"flex":null,"flex_flow":null,"grid_area":null,"grid_auto_columns":null,"grid_auto_flow":null,"grid_auto_rows":null,"grid_column":null,"grid_gap":null,"grid_row":null,"grid_template_areas":null,"grid_template_columns":null,"grid_template_rows":null,"height":null,"justify_content":null,"justify_items":null,"left":null,"margin":null,"max_height":null,"max_width":null,"min_height":null,"min_width":null,"object_fit":null,"object_position":null,"order":null,"overflow":null,"padding":null,"right":null,"top":null,"visibility":null,"width":null}},"9d70f342d5234794947c12d107c05498":{"model_module":"@jupyter-widgets/base","model_module_version":"2.0.0","model_name":"LayoutModel","state":{"_model_module":"@jupyter-widgets/base","_model_module_version":"2.0.0","_model_name":"LayoutModel","_view_count":null,"_view_module":"@jupyter-widgets/base","_view_module_version":"2.0.0","_view_name":"LayoutView","align_content":null,"align_items":null,"align_self":null,"border_bottom":null,"border_left":null,"border_right":null,"border_top":null,"bottom":null,"display":null,"flex":null,"flex_flow":null,"grid_area":null,"grid_auto_columns":null,"grid_auto_flow":null,"grid_auto_rows":null,"grid_column":null,"grid_gap":null,"grid_row":null,"grid_template_areas":null,"grid_template_columns":null,"grid_template_rows":null,"height":null,"justify_content":null,"justify_items":null,"left":null,"margin":null,"max_height":null,"max_width":null,"min_height":null,"min_width":null,"object_fit":null,"object_position":null,"order":null,"overflow":null,"padding":null,"right":null,"top":null,"visibility":null,"width":null}},"a6baa400765f4e3ca3bc90481d77eee5":{"model_module":"@jupyter-widgets/base","model_module_version":"2.0.0","model_name":"LayoutModel","state":{"_model_module":"@jupyter-widgets/base","_model_module_version":"2.0.0","_model_name":"LayoutModel","_view_count":null,"_view_module":"@jupyter-widgets/base","_view_module_version":"2.0.0","_view_name":"LayoutView","align_content":null,"align_items":null,"align_self":null,"border_bottom":null,"border_left":null,"border_right":null,"border_top":null,"bottom":null,"display":null,"flex":null,"flex_flow":null,"grid_area":null,"grid_auto_columns":null,"grid_auto_flow":null,"grid_auto_rows":null,"grid_column":null,"grid_gap":null,"grid_row":null,"grid_template_areas":null,"grid_template_columns":null,"grid_template_rows":null,"height":null,"justify_content":null,"justify_items":null,"left":null,"margin":null,"max_height":null,"max_width":null,"min_height":null,"min_width":null,"object_fit":null,"object_position":null,"order":null,"overflow":null,"padding":null,"right":null,"top":null,"visibility":null,"width":null}},"ac013be49c5145dcaab67cf21d06c02d":{"model_module":"@jupyter-widgets/controls","model_module_version":"2.0.0","model_name":"HTMLStyleModel","state":{"_model_module":"@jupyter-widgets/controls","_model_module_version":"2.0.0","_model_name":"HTMLStyleModel","_view_count":null,"_view_module":"@jupyter-widgets/base","_view_module_version":"2.0.0","_view_name":"StyleView","background":null,"description_width":"","font_size":null,"text_color":null}},"ad408540b4bd4a178bb0ac5af045a390":{"model_module":"@jupyter-widgets/controls","model_module_version":"2.0.0","model_name":"FloatProgressModel","state":{"_dom_classes":[],"_model_module":"@jupyter-widgets/controls","_model_module_version":"2.0.0","_model_name":"FloatProgressModel","_view_count":null,"_view_module":"@jupyter-widgets/controls","_view_module_version":"2.0.0","_view_name":"ProgressView","bar_style":"","description":"","description_allow_html":false,"layout":"IPY_MODEL_c84229f4d1ab47e6b00a461ec3dac291","max":1,"min":0,"orientation":"horizontal","style":"IPY_MODEL_503468f87933474f93657c8470c8963a","tabbable":null,"tooltip":null,"value":1}},"ba244175d7e7486fb59ae875f29802fa":{"model_module":"@jupyter-widgets/base","model_module_version":"2.0.0","model_name":"LayoutModel","state":{"_model_module":"@jupyter-widgets/base","_model_module_version":"2.0.0","_model_name":"LayoutModel","_view_count":null,"_view_module":"@jupyter-widgets/base","_view_module_version":"2.0.0","_view_name":"LayoutView","align_content":null,"align_items":null,"align_self":null,"border_bottom":null,"border_left":null,"border_right":null,"border_top":null,"bottom":null,"display":null,"flex":"2","flex_flow":null,"grid_area":null,"grid_auto_columns":null,"grid_auto_flow":null,"grid_auto_rows":null,"grid_column":null,"grid_gap":null,"grid_row":null,"grid_template_areas":null,"grid_template_columns":null,"grid_template_rows":null,"height":null,"justify_content":null,"justify_items":null,"left":null,"margin":null,"max_height":null,"max_width":null,"min_height":null,"min_width":null,"object_fit":null,"object_position":null,"order":null,"overflow":null,"padding":null,"right":null,"top":null,"visibility":null,"width":null}},"bd1b197fc1ee40da9c9cd49d8dba4144":{"model_module":"@jupyter-widgets/controls","model_module_version":"2.0.0","model_name":"HTMLStyleModel","state":{"_model_module":"@jupyter-widgets/controls","_model_module_version":"2.0.0","_model_name":"HTMLStyleModel","_view_count":null,"_view_module":"@jupyter-widgets/base","_view_module_version":"2.0.0","_view_name":"StyleView","background":null,"description_width":"","font_size":null,"text_color":null}},"c31aafb0d7434a34bcf178663d007df7":{"model_module":"@jupyter-widgets/base","model_module_version":"2.0.0","model_name":"LayoutModel","state":{"_model_module":"@jupyter-widgets/base","_model_module_version":"2.0.0","_model_name":"LayoutModel","_view_count":null,"_view_module":"@jupyter-widgets/base","_view_module_version":"2.0.0","_view_name":"LayoutView","align_content":null,"align_items":null,"align_self":null,"border_bottom":null,"border_left":null,"border_right":null,"border_top":null,"bottom":null,"display":null,"flex":null,"flex_flow":null,"grid_area":null,"grid_auto_columns":null,"grid_auto_flow":null,"grid_auto_rows":null,"grid_column":null,"grid_gap":null,"grid_row":null,"grid_template_areas":null,"grid_template_columns":null,"grid_template_rows":null,"height":null,"justify_content":null,"justify_items":null,"left":null,"margin":null,"max_height":null,"max_width":null,"min_height":null,"min_width":null,"object_fit":null,"object_position":null,"order":null,"overflow":null,"padding":null,"right":null,"top":null,"visibility":null,"width":null}},"c6d4e564a1b646ed8a2cba6cc61c145e":{"model_module":"@jupyter-widgets/base","model_module_version":"2.0.0","model_name":"LayoutModel","state":{"_model_module":"@jupyter-widgets/base","_model_module_version":"2.0.0","_model_name":"LayoutModel","_view_count":null,"_view_module":"@jupyter-widgets/base","_view_module_version":"2.0.0","_view_name":"LayoutView","align_content":null,"align_items":null,"align_self":null,"border_bottom":null,"border_left":null,"border_right":null,"border_top":null,"bottom":null,"display":"inline-flex","flex":null,"flex_flow":"row wrap","grid_area":null,"grid_auto_columns":null,"grid_auto_flow":null,"grid_auto_rows":null,"grid_column":null,"grid_gap":null,"grid_row":null,"grid_template_areas":null,"grid_template_columns":null,"grid_template_rows":null,"height":null,"justify_content":null,"justify_items":null,"left":null,"margin":null,"max_height":null,"max_width":null,"min_height":null,"min_width":null,"object_fit":null,"object_position":null,"order":null,"overflow":null,"padding":null,"right":null,"top":null,"visibility":"hidden","width":"100%"}},"c84229f4d1ab47e6b00a461ec3dac291":{"model_module":"@jupyter-widgets/base","model_module_version":"2.0.0","model_name":"LayoutModel","state":{"_model_module":"@jupyter-widgets/base","_model_module_version":"2.0.0","_model_name":"LayoutModel","_view_count":null,"_view_module":"@jupyter-widgets/base","_view_module_version":"2.0.0","_view_name":"LayoutView","align_content":null,"align_items":null,"align_self":null,"border_bottom":null,"border_left":null,"border_right":null,"border_top":null,"bottom":null,"display":null,"flex":"2","flex_flow":null,"grid_area":null,"grid_auto_columns":null,"grid_auto_flow":null,"grid_auto_rows":null,"grid_column":null,"grid_gap":null,"grid_row":null,"grid_template_areas":null,"grid_template_columns":null,"grid_template_rows":null,"height":null,"justify_content":null,"justify_items":null,"left":null,"margin":null,"max_height":null,"max_width":null,"min_height":null,"min_width":null,"object_fit":null,"object_position":null,"order":null,"overflow":null,"padding":null,"right":null,"top":null,"visibility":null,"width":null}},"caf0a14d564b4231b6c34f1209720ccc":{"model_module":"@jupyter-widgets/base","model_module_version":"2.0.0","model_name":"LayoutModel","state":{"_model_module":"@jupyter-widgets/base","_model_module_version":"2.0.0","_model_name":"LayoutModel","_view_count":null,"_view_module":"@jupyter-widgets/base","_view_module_version":"2.0.0","_view_name":"LayoutView","align_content":null,"align_items":null,"align_self":null,"border_bottom":null,"border_left":null,"border_right":null,"border_top":null,"bottom":null,"display":null,"flex":null,"flex_flow":null,"grid_area":null,"grid_auto_columns":null,"grid_auto_flow":null,"grid_auto_rows":null,"grid_column":null,"grid_gap":null,"grid_row":null,"grid_template_areas":null,"grid_template_columns":null,"grid_template_rows":null,"height":null,"justify_content":null,"justify_items":null,"left":null,"margin":null,"max_height":null,"max_width":null,"min_height":null,"min_width":null,"object_fit":null,"object_position":null,"order":null,"overflow":null,"padding":null,"right":null,"top":null,"visibility":null,"width":null}},"d4529666f7084016bd27d61007ff65c7":{"model_module":"@jupyter-widgets/base","model_module_version":"2.0.0","model_name":"LayoutModel","state":{"_model_module":"@jupyter-widgets/base","_model_module_version":"2.0.0","_model_name":"LayoutModel","_view_count":null,"_view_module":"@jupyter-widgets/base","_view_module_version":"2.0.0","_view_name":"LayoutView","align_content":null,"align_items":null,"align_self":null,"border_bottom":null,"border_left":null,"border_right":null,"border_top":null,"bottom":null,"display":null,"flex":null,"flex_flow":null,"grid_area":null,"grid_auto_columns":null,"grid_auto_flow":null,"grid_auto_rows":null,"grid_column":null,"grid_gap":null,"grid_row":null,"grid_template_areas":null,"grid_template_columns":null,"grid_template_rows":null,"height":null,"justify_content":null,"justify_items":null,"left":null,"margin":null,"max_height":null,"max_width":null,"min_height":null,"min_width":null,"object_fit":null,"object_position":null,"order":null,"overflow":null,"padding":null,"right":null,"top":null,"visibility":null,"width":null}},"e0e6e4c11ed64bd7a9c4a003360fa491":{"model_module":"@jupyter-widgets/controls","model_module_version":"2.0.0","model_name":"HTMLModel","state":{"_dom_classes":[],"_model_module":"@jupyter-widgets/controls","_model_module_version":"2.0.0","_model_name":"HTMLModel","_view_count":null,"_view_module":"@jupyter-widgets/controls","_view_module_version":"2.0.0","_view_name":"HTMLView","description":"","description_allow_html":false,"layout":"IPY_MODEL_d4529666f7084016bd27d61007ff65c7","placeholder":"​","style":"IPY_MODEL_7394f5fc4b154a5bbf135008535933f3","tabbable":null,"tooltip":null,"value":"model.safetensors: 100%"}},"e26a41c25b1d4711b918af6e89ca49a9":{"model_module":"@jupyter-widgets/base","model_module_version":"2.0.0","model_name":"LayoutModel","state":{"_model_module":"@jupyter-widgets/base","_model_module_version":"2.0.0","_model_name":"LayoutModel","_view_count":null,"_view_module":"@jupyter-widgets/base","_view_module_version":"2.0.0","_view_name":"LayoutView","align_content":null,"align_items":null,"align_self":null,"border_bottom":null,"border_left":null,"border_right":null,"border_top":null,"bottom":null,"display":"inline-flex","flex":null,"flex_flow":"row wrap","grid_area":null,"grid_auto_columns":null,"grid_auto_flow":null,"grid_auto_rows":null,"grid_column":null,"grid_gap":null,"grid_row":null,"grid_template_areas":null,"grid_template_columns":null,"grid_template_rows":null,"height":null,"justify_content":null,"justify_items":null,"left":null,"margin":null,"max_height":null,"max_width":null,"min_height":null,"min_width":null,"object_fit":null,"object_position":null,"order":null,"overflow":null,"padding":null,"right":null,"top":null,"visibility":"hidden","width":"100%"}},"e7d5c0026b6141cdac35bf2dd6089695":{"model_module":"@jupyter-widgets/controls","model_module_version":"2.0.0","model_name":"FloatProgressModel","state":{"_dom_classes":[],"_model_module":"@jupyter-widgets/controls","_model_module_version":"2.0.0","_model_name":"FloatProgressModel","_view_count":null,"_view_module":"@jupyter-widgets/controls","_view_module_version":"2.0.0","_view_name":"ProgressView","bar_style":"","description":"","description_allow_html":false,"layout":"IPY_MODEL_225b12f576aa4ce8932ec917dc5d0dd2","max":1,"min":0,"orientation":"horizontal","style":"IPY_MODEL_f6e0db0538ab43328c1d46f547ff617e","tabbable":null,"tooltip":null,"value":1}},"ed1832bc32e940b8921fbb05aa7693ca":{"model_module":"@jupyter-widgets/controls","model_module_version":"2.0.0","model_name":"HTMLModel","state":{"_dom_classes":[],"_model_module":"@jupyter-widgets/controls","_model_module_version":"2.0.0","_model_name":"HTMLModel","_view_count":null,"_view_module":"@jupyter-widgets/controls","_view_module_version":"2.0.0","_view_name":"HTMLView","description":"","description_allow_html":false,"layout":"IPY_MODEL_caf0a14d564b4231b6c34f1209720ccc","placeholder":"​","style":"IPY_MODEL_52587fe69ebb40d9a3a45ceddaf7d28e","tabbable":null,"tooltip":null,"value":" 3/3 [00:49&lt;00:00,  0.06it/s, v_num=0]"}},"ed6b195dbe184696b75f55b3adce2536":{"model_module":"@jupyter-widgets/base","model_module_version":"2.0.0","model_name":"LayoutModel","state":{"_model_module":"@jupyter-widgets/base","_model_module_version":"2.0.0","_model_name":"LayoutModel","_view_count":null,"_view_module":"@jupyter-widgets/base","_view_module_version":"2.0.0","_view_name":"LayoutView","align_content":null,"align_items":null,"align_self":null,"border_bottom":null,"border_left":null,"border_right":null,"border_top":null,"bottom":null,"display":null,"flex":null,"flex_flow":null,"grid_area":null,"grid_auto_columns":null,"grid_auto_flow":null,"grid_auto_rows":null,"grid_column":null,"grid_gap":null,"grid_row":null,"grid_template_areas":null,"grid_template_columns":null,"grid_template_rows":null,"height":null,"justify_content":null,"justify_items":null,"left":null,"margin":null,"max_height":null,"max_width":null,"min_height":null,"min_width":null,"object_fit":null,"object_position":null,"order":null,"overflow":null,"padding":null,"right":null,"top":null,"visibility":null,"width":null}},"f1d1a0c997ee4ba8997a6e9b27309be4":{"model_module":"@jupyter-widgets/controls","model_module_version":"2.0.0","model_name":"HTMLModel","state":{"_dom_classes":[],"_model_module":"@jupyter-widgets/controls","_model_module_version":"2.0.0","_model_name":"HTMLModel","_view_count":null,"_view_module":"@jupyter-widgets/controls","_view_module_version":"2.0.0","_view_name":"HTMLView","description":"","description_allow_html":false,"layout":"IPY_MODEL_c31aafb0d7434a34bcf178663d007df7","placeholder":"​","style":"IPY_MODEL_40ec909df3c54e7187857ca91e86d2df","tabbable":null,"tooltip":null,"value":" 1/1 [00:00&lt;00:00,  1.02it/s]"}},"f6e0db0538ab43328c1d46f547ff617e":{"model_module":"@jupyter-widgets/controls","model_module_version":"2.0.0","model_name":"ProgressStyleModel","state":{"_model_module":"@jupyter-widgets/controls","_model_module_version":"2.0.0","_model_name":"ProgressStyleModel","_view_count":null,"_view_module":"@jupyter-widgets/base","_view_module_version":"2.0.0","_view_name":"StyleView","bar_color":null,"description_width":""}},"f8116342f19c48dfa55b3d7500705356":{"model_module":"@jupyter-widgets/base","model_module_version":"2.0.0","model_name":"LayoutModel","state":{"_model_module":"@jupyter-widgets/base","_model_module_version":"2.0.0","_model_name":"LayoutModel","_view_count":null,"_view_module":"@jupyter-widgets/base","_view_module_version":"2.0.0","_view_name":"LayoutView","align_content":null,"align_items":null,"align_self":null,"border_bottom":null,"border_left":null,"border_right":null,"border_top":null,"bottom":null,"display":"inline-flex","flex":null,"flex_flow":"row wrap","grid_area":null,"grid_auto_columns":null,"grid_auto_flow":null,"grid_auto_rows":null,"grid_column":null,"grid_gap":null,"grid_row":null,"grid_template_areas":null,"grid_template_columns":null,"grid_template_rows":null,"height":null,"justify_content":null,"justify_items":null,"left":null,"margin":null,"max_height":null,"max_width":null,"min_height":null,"min_width":null,"object_fit":null,"object_position":null,"order":null,"overflow":null,"padding":null,"right":null,"top":null,"visibility":null,"width":"100%"}},"f97fcf651dea4b7b9f52544c7998cb59":{"model_module":"@jupyter-widgets/controls","model_module_version":"2.0.0","model_name":"ProgressStyleModel","state":{"_model_module":"@jupyter-widgets/controls","_model_module_version":"2.0.0","_model_name":"ProgressStyleModel","_view_count":null,"_view_module":"@jupyter-widgets/base","_view_module_version":"2.0.0","_view_name":"StyleView","bar_color":null,"description_width":""}}},"version_major":2,"version_minor":0}}},"nbformat_minor":4,"nbformat":4,"cells":[{"id":"0d72d80f","cell_type":"markdown","source":"# PlantCLEF ResNet18 Train\n","metadata":{"papermill":{"duration":0.004878,"end_time":"2025-05-01T03:42:11.949717","exception":false,"start_time":"2025-05-01T03:42:11.944839","status":"completed"},"tags":[]}},{"id":"2c553b58","cell_type":"markdown","source":"Train images are obtained from the internet.\n\nNo image folder by label exists, and label information is in csv file.\n\nFirst, I create a model that can identify images of single plant.","metadata":{"papermill":{"duration":0.003691,"end_time":"2025-05-01T03:42:11.957658","exception":false,"start_time":"2025-05-01T03:42:11.953967","status":"completed"},"tags":[]}},{"id":"4675aca9","cell_type":"code","source":"!pip install lightning ","metadata":{"_kg_hide-output":true,"execution":{"iopub.execute_input":"2025-05-01T03:42:11.967422Z","iopub.status.busy":"2025-05-01T03:42:11.966439Z","iopub.status.idle":"2025-05-01T03:43:53.037758Z","shell.execute_reply":"2025-05-01T03:43:53.035968Z"},"papermill":{"duration":101.078588,"end_time":"2025-05-01T03:43:53.040278","exception":false,"start_time":"2025-05-01T03:42:11.961690","status":"completed"},"tags":[]},"outputs":[],"execution_count":null},{"id":"72d6ff17","cell_type":"code","source":"import os\nimport random\nimport numpy as np\nimport pandas as pd\nfrom tqdm import tqdm\nimport torch\nimport torch.nn as nn\nimport torch.nn.functional as F\nfrom torch.utils.data import random_split\nfrom torch.utils.data import DataLoader, Dataset, Subset\nfrom torch.utils.data import random_split, SubsetRandomSampler\nfrom torchvision import datasets, transforms, models \nfrom torchvision.datasets import ImageFolder\nfrom torchvision.transforms import ToTensor\nfrom torchvision.utils import make_grid\n\n#the latest environement\nfrom lightning.pytorch import LightningModule\nfrom lightning.pytorch import Trainer\nimport lightning.pytorch as L\nfrom lightning.pytorch import LightningDataModule\n\nimport matplotlib.pyplot as plt\n%matplotlib inline\nfrom sklearn.model_selection import train_test_split\nfrom sklearn.metrics import classification_report\nfrom PIL import Image","metadata":{"execution":{"iopub.execute_input":"2025-05-01T03:43:53.108169Z","iopub.status.busy":"2025-05-01T03:43:53.107727Z","iopub.status.idle":"2025-05-01T03:44:15.425194Z","shell.execute_reply":"2025-05-01T03:44:15.424219Z"},"papermill":{"duration":22.355367,"end_time":"2025-05-01T03:44:15.427026","exception":false,"start_time":"2025-05-01T03:43:53.071659","status":"completed"},"tags":[]},"outputs":[],"execution_count":null},{"id":"0efdf634","cell_type":"code","source":"transform = transforms.Compose([\n            transforms.Resize(224),             # resize shortest side to 224 pixels\n            transforms.CenterCrop(224),         # crop longest side to 224 pixels at center            \n            transforms.ToTensor(),\n            transforms.Normalize([0.485, 0.456, 0.406],\n                                 [0.229, 0.224, 0.225])\n        ])","metadata":{"execution":{"iopub.execute_input":"2025-05-01T03:44:15.492044Z","iopub.status.busy":"2025-05-01T03:44:15.491285Z","iopub.status.idle":"2025-05-01T03:44:15.499115Z","shell.execute_reply":"2025-05-01T03:44:15.497972Z"},"papermill":{"duration":0.042302,"end_time":"2025-05-01T03:44:15.500913","exception":false,"start_time":"2025-05-01T03:44:15.458611","status":"completed"},"tags":[]},"outputs":[],"execution_count":null},{"id":"ef0a5d89","cell_type":"code","source":"df=pd.read_csv('/kaggle/input/plantclef-2025/PlantCLEF2024_single_plant_training_metadata.csv',sep=';')\nprint(len(df))\ndisplay(df[0:1].T)\nM=list(range(len(df)))\nrandom.shuffle(M)\ndata0=df.iloc[M[0:10000]]\nprint(len(data0))","metadata":{"execution":{"iopub.execute_input":"2025-05-01T03:44:15.562416Z","iopub.status.busy":"2025-05-01T03:44:15.562085Z","iopub.status.idle":"2025-05-01T03:44:45.603653Z","shell.execute_reply":"2025-05-01T03:44:45.602467Z"},"papermill":{"duration":30.104907,"end_time":"2025-05-01T03:44:45.635934","exception":false,"start_time":"2025-05-01T03:44:15.531027","status":"completed"},"tags":[]},"outputs":[],"execution_count":null},{"id":"4c7cf2b6","cell_type":"code","source":"class_counts = data0['species_id'].value_counts()\nvalid_classes = class_counts[class_counts >= 1].index\ndata2 = data0[data0['species_id'].isin(valid_classes)]\ndisplay(data2)\nclass_names=sorted(data2['species_id'].unique().tolist())\nnum_classes=len(class_names)\nprint(num_classes)\nclass_df=pd.DataFrame(data=class_names)\nclass_df.to_csv('class_names.csv',index=False)","metadata":{"execution":{"iopub.execute_input":"2025-05-01T03:44:45.699439Z","iopub.status.busy":"2025-05-01T03:44:45.698987Z","iopub.status.idle":"2025-05-01T03:44:45.747530Z","shell.execute_reply":"2025-05-01T03:44:45.746253Z"},"papermill":{"duration":0.082809,"end_time":"2025-05-01T03:44:45.749178","exception":false,"start_time":"2025-05-01T03:44:45.666369","status":"completed"},"tags":[]},"outputs":[],"execution_count":null},{"id":"422996b3","cell_type":"code","source":"N=list(range(len(class_names)))\nnormal_mapping=dict(zip(class_names,N)) \nreverse_mapping=dict(zip(N,class_names))   \ndata2['label']=data2['species_id'].map(normal_mapping)\ndisplay(data2)","metadata":{"execution":{"iopub.execute_input":"2025-05-01T03:44:45.930848Z","iopub.status.busy":"2025-05-01T03:44:45.930424Z","iopub.status.idle":"2025-05-01T03:44:46.018611Z","shell.execute_reply":"2025-05-01T03:44:46.017614Z"},"papermill":{"duration":0.123427,"end_time":"2025-05-01T03:44:46.020252","exception":false,"start_time":"2025-05-01T03:44:45.896825","status":"completed"},"tags":[]},"outputs":[],"execution_count":null},{"id":"b551a484","cell_type":"code","source":"dir0=df['image_backup_url'].tolist()\n#print(dir0[0:3])","metadata":{"execution":{"iopub.execute_input":"2025-05-01T03:44:46.086776Z","iopub.status.busy":"2025-05-01T03:44:46.086383Z","iopub.status.idle":"2025-05-01T03:44:46.144502Z","shell.execute_reply":"2025-05-01T03:44:46.143552Z"},"papermill":{"duration":0.093316,"end_time":"2025-05-01T03:44:46.146420","exception":false,"start_time":"2025-05-01T03:44:46.053104","status":"completed"},"tags":[]},"outputs":[],"execution_count":null},{"id":"6c41acb5","cell_type":"code","source":"def create_path_label_list(df):\n    path_label_list = []\n    for _, row in df.iterrows():\n        path = row['image_backup_url']\n        label = row['label']\n        path_label_list.append((path, label))\n    return path_label_list\n\npath_label = create_path_label_list(data2)\n#print(path_label[0:3])","metadata":{"execution":{"iopub.execute_input":"2025-05-01T03:44:46.221277Z","iopub.status.busy":"2025-05-01T03:44:46.220782Z","iopub.status.idle":"2025-05-01T03:44:46.233986Z","shell.execute_reply":"2025-05-01T03:44:46.232833Z"},"papermill":{"duration":0.049715,"end_time":"2025-05-01T03:44:46.236059","exception":false,"start_time":"2025-05-01T03:44:46.186344","status":"completed"},"tags":[]},"outputs":[],"execution_count":null},{"id":"58693e0b","cell_type":"code","source":"class CustomDataset(torch.utils.data.Dataset):\n    def __init__(self, path_label, transform=None):\n        self.path_label = path_label\n        self.transform = transform\n\n    def __len__(self):\n        return len(self.path_label)\n\n\n    def __getitem__(self, idx):\n        path, label = self.path_label[idx]\n        \n        try:\n            # If the path starts with 'http' or contains '://', it's a URL\n            if path.startswith('http') or '://' in path:\n                import requests\n                from io import BytesIO\n                \n                response = requests.get(path, timeout=10)  \n                if response.status_code == 200:\n                    img = Image.open(BytesIO(response.content)).convert('RGB')\n                else:\n                    print(f\"Warning: Could not fetch image from {path}, status code: {response.status_code}\")\n                    img = self._get_dummy_image()\n            else:\n                # Normal local file handling\n                img = Image.open(path).convert('RGB')\n        except Exception as e:\n            print(f\"Error loading image {path}: {str(e)}\")\n            img = self._get_dummy_image()\n        \n        if self.transform is not None:\n            img = self.transform(img)\n            \n        return img, label\n    \n    def _get_dummy_image(self):\n        \n        return Image.new('RGB', (224, 224), color=(0, 0, 0))","metadata":{"execution":{"iopub.execute_input":"2025-05-01T03:44:46.318864Z","iopub.status.busy":"2025-05-01T03:44:46.318457Z","iopub.status.idle":"2025-05-01T03:44:46.327882Z","shell.execute_reply":"2025-05-01T03:44:46.326776Z"},"papermill":{"duration":0.049608,"end_time":"2025-05-01T03:44:46.329616","exception":false,"start_time":"2025-05-01T03:44:46.280008","status":"completed"},"tags":[]},"outputs":[],"execution_count":null},{"id":"7f2a0d32","cell_type":"code","source":"class DataModule(LightningDataModule):\n    def __init__(self, path_label=None, dataset=None, batch_size=32, transform=None,\n                 val_split=0.15, test_split=0.15):\n        super().__init__()\n        self.path_label = path_label\n        self.existing_dataset = dataset\n        self.batch_size = batch_size\n        self.val_split = val_split  # Validation data ratio\n        self.test_split = test_split  # Test data ratio\n        \n        # Default image transformations\n        self.transform = transform or transforms.Compose([\n            transforms.Resize(256),\n            transforms.CenterCrop(224),\n            transforms.ToTensor(),\n            transforms.Normalize([0.485, 0.456, 0.406],\n                               [0.229, 0.224, 0.225])\n        ])\n\n    def setup(self, stage=None):\n        # Prepare dataset\n        if self.path_label is not None:\n            full_dataset = CustomDataset(self.path_label, self.transform)\n        elif self.existing_dataset is not None:\n            if isinstance(self.existing_dataset, type):\n                raise TypeError(\"Dataset class was passed. Please pass an instantiated dataset object instead\")\n            full_dataset = self.existing_dataset\n        else:\n            full_dataset = globals().get('dataset')\n            if full_dataset is None:\n                raise ValueError(\n                    \"No dataset specified. Please provide one of the following:\\n\"\n                    \"1. path_label parameter\\n\"\n                    \"2. dataset parameter\\n\"\n                    \"3. global 'dataset' variable\"\n                )\n\n        dataset_size = len(full_dataset)\n        print(f\"Total dataset size: {dataset_size}\")\n\n        # Data splitting\n        test_size = int(self.test_split * dataset_size)\n        val_size = int(self.val_split * dataset_size)\n        train_size = dataset_size - val_size - test_size\n\n        # Split dataset\n        from torch.utils.data import random_split\n        self.train_dataset, self.val_dataset, self.test_dataset = random_split(\n            full_dataset, \n            [train_size, val_size, test_size]\n        )\n\n        print(f\"Training data: {len(self.train_dataset)} samples\")\n        print(f\"Validation data: {len(self.val_dataset)} samples\")\n        print(f\"Test data: {len(self.test_dataset)} samples\")\n\n    def train_dataloader(self):\n        return DataLoader(\n            self.train_dataset,\n            batch_size=self.batch_size,\n            shuffle=True,\n            num_workers=4\n        )\n\n    def val_dataloader(self):\n        return DataLoader(\n            self.val_dataset,\n            batch_size=self.batch_size,\n            num_workers=4\n        )\n\n    def test_dataloader(self):\n        return DataLoader(\n            self.test_dataset,\n            batch_size=self.batch_size,\n            num_workers=4\n        )","metadata":{"execution":{"iopub.execute_input":"2025-05-01T03:44:46.482636Z","iopub.status.busy":"2025-05-01T03:44:46.482260Z","iopub.status.idle":"2025-05-01T03:44:46.534883Z","shell.execute_reply":"2025-05-01T03:44:46.533858Z"},"papermill":{"duration":0.088846,"end_time":"2025-05-01T03:44:46.536589","exception":false,"start_time":"2025-05-01T03:44:46.447743","status":"completed"},"tags":[]},"outputs":[],"execution_count":null},{"id":"5268bbe0","cell_type":"code","source":"import timm\n\nclass ConvolutionalNetwork(LightningModule):\n    def __init__(self, num_classes=None):\n        super().__init__()\n        if num_classes is None:\n            raise ValueError(\"num_classes must be specified.\")\n        self.base_model = timm.create_model('resnet18', \n                                            pretrained=True, \n                                            num_classes=num_classes)\n\n    def forward(self, x):\n        return self.base_model(x)\n\n    def configure_optimizers(self):\n        optimizer = torch.optim.Adam(self.parameters(), lr=0.001)\n        return optimizer\n\n    def training_step(self, train_batch, batch_idx):\n        X, y = train_batch\n        y_hat = self(X)\n        loss = F.cross_entropy(y_hat, y)\n        pred = y_hat.argmax(dim=1, keepdim=True)\n        acc = pred.eq(y.view_as(pred)).sum().item() / y.shape[0]\n        self.log(\"train_loss\", loss)\n        self.log(\"train_acc\", acc)\n        return loss\n\n    def validation_step(self, val_batch, batch_idx):\n        X, y = val_batch\n        y_hat = self(X)\n        loss = F.cross_entropy(y_hat, y)\n        pred = y_hat.argmax(dim=1, keepdim=True)\n        acc = pred.eq(y.view_as(pred)).sum().item() / y.shape[0]\n        self.log(\"val_loss\", loss)\n        self.log(\"val_acc\", acc)\n\n    def test_step(self, test_batch, batch_idx):\n        X, y = test_batch\n        y_hat = self(X)\n        loss = F.cross_entropy(y_hat, y)\n        pred = y_hat.argmax(dim=1, keepdim=True)\n        acc = pred.eq(y.view_as(pred)).sum().item() / y.shape[0]\n        self.log(\"test_loss\", loss)\n        self.log(\"test_acc\", acc)","metadata":{"execution":{"iopub.execute_input":"2025-05-01T03:44:46.606323Z","iopub.status.busy":"2025-05-01T03:44:46.605354Z","iopub.status.idle":"2025-05-01T03:44:51.171908Z","shell.execute_reply":"2025-05-01T03:44:51.170811Z"},"papermill":{"duration":4.604943,"end_time":"2025-05-01T03:44:51.173868","exception":false,"start_time":"2025-05-01T03:44:46.568925","status":"completed"},"tags":[]},"outputs":[],"execution_count":null},{"id":"d99a1e26","cell_type":"code","source":"custom_dataset = CustomDataset(path_label, transform) \ndatamodule = DataModule(dataset=custom_dataset)\ndatamodule.setup()","metadata":{"execution":{"iopub.execute_input":"2025-05-01T03:44:51.306735Z","iopub.status.busy":"2025-05-01T03:44:51.305866Z","iopub.status.idle":"2025-05-01T03:44:51.330170Z","shell.execute_reply":"2025-05-01T03:44:51.328947Z"},"papermill":{"duration":0.059829,"end_time":"2025-05-01T03:44:51.332008","exception":false,"start_time":"2025-05-01T03:44:51.272179","status":"completed"},"tags":[]},"outputs":[],"execution_count":null},{"id":"d23852dd","cell_type":"code","source":"model = ConvolutionalNetwork(num_classes)\ntrainer = L.Trainer(max_epochs=10)\ntrainer.fit(model, datamodule)","metadata":{"execution":{"iopub.execute_input":"2025-05-01T03:44:51.400359Z","iopub.status.busy":"2025-05-01T03:44:51.399986Z","iopub.status.idle":"2025-05-01T03:46:15.761213Z","shell.execute_reply":"2025-05-01T03:46:15.759992Z"},"papermill":{"duration":84.397343,"end_time":"2025-05-01T03:46:15.762979","exception":false,"start_time":"2025-05-01T03:44:51.365636","status":"completed"},"tags":[]},"outputs":[],"execution_count":null},{"id":"526da84f","cell_type":"code","source":"trainer.save_checkpoint(\"model_checkpoint.ckpt\")\n#model = ConvolutionalNetwork.load_from_checkpoint(\"model_checkpoint.ckpt\")\n#model.eval()","metadata":{"execution":{"iopub.execute_input":"2025-05-01T03:46:15.831863Z","iopub.status.busy":"2025-05-01T03:46:15.831453Z","iopub.status.idle":"2025-05-01T03:46:16.528086Z","shell.execute_reply":"2025-05-01T03:46:16.527000Z"},"papermill":{"duration":0.733552,"end_time":"2025-05-01T03:46:16.530012","exception":false,"start_time":"2025-05-01T03:46:15.796460","status":"completed"},"tags":[]},"outputs":[],"execution_count":null},{"id":"6b2a3a0c","cell_type":"code","source":"test_loader = datamodule.test_dataloader()\ntrainer.test(dataloaders=test_loader)","metadata":{"execution":{"iopub.execute_input":"2025-05-01T03:46:16.597614Z","iopub.status.busy":"2025-05-01T03:46:16.597250Z","iopub.status.idle":"2025-05-01T03:46:30.270584Z","shell.execute_reply":"2025-05-01T03:46:30.269332Z"},"papermill":{"duration":13.709509,"end_time":"2025-05-01T03:46:30.272395","exception":false,"start_time":"2025-05-01T03:46:16.562886","status":"completed"},"tags":[]},"outputs":[],"execution_count":null},{"id":"50c097e3","cell_type":"code","source":"for images, labels in datamodule.train_dataloader():\n    break\nim=make_grid(images,nrow=16)\n\nplt.figure(figsize=(12,12))\nplt.imshow(np.transpose(im.numpy(),(1,2,0)))\n\ninv_normalize=transforms.Normalize(mean=[-0.485/0.229,-0.456/0.224,-0.406/0.225],\n                                   std=[1/0.229,1/0.224,1/0.225])\nim=inv_normalize(im)\n\nplt.figure(figsize=(12,12))\nplt.imshow(np.transpose(im.numpy(),(1,2,0)))","metadata":{"execution":{"iopub.execute_input":"2025-05-01T03:46:30.341985Z","iopub.status.busy":"2025-05-01T03:46:30.341626Z","iopub.status.idle":"2025-05-01T03:46:56.169597Z","shell.execute_reply":"2025-05-01T03:46:56.168462Z"},"papermill":{"duration":25.869564,"end_time":"2025-05-01T03:46:56.176147","exception":false,"start_time":"2025-05-01T03:46:30.306583","status":"completed"},"tags":[]},"outputs":[],"execution_count":null},{"id":"e498f836","cell_type":"code","source":"from sklearn.metrics import classification_report\n\ndevice = torch.device(\"cpu\")  # \"cuda:0\"\n\nmodel.eval()\ny_true = []\ny_pred = []\n\nwith torch.no_grad():\n    for test_data in datamodule.test_dataloader():\n        test_images, test_labels = test_data[0].to(device), test_data[1].to(device)\n        pred = model(test_images).argmax(dim=1)\n        y_true.extend(test_labels.cpu().numpy())\n        y_pred.extend(pred.cpu().numpy())\n\nunique_classes = sorted(set(y_true))  \n\n# Ensure all class names are strings\nfiltered_class_names = []\nfor i in unique_classes:\n    if i < len(class_names):\n        # Convert to string explicitly\n        filtered_class_names.append(str(class_names[i]))\n    else:\n        filtered_class_names.append(f\"Class {i}\")\n\n# Now use the filtered class names\nprint(classification_report(y_true, y_pred, labels=unique_classes, target_names=filtered_class_names, digits=4))","metadata":{"execution":{"iopub.execute_input":"2025-05-01T03:46:56.275700Z","iopub.status.busy":"2025-05-01T03:46:56.275294Z","iopub.status.idle":"2025-05-01T03:47:08.601834Z","shell.execute_reply":"2025-05-01T03:47:08.600407Z"},"papermill":{"duration":12.377887,"end_time":"2025-05-01T03:47:08.603579","exception":false,"start_time":"2025-05-01T03:46:56.225692","status":"completed"},"tags":[]},"outputs":[],"execution_count":null},{"id":"564e6b36","cell_type":"code","source":"","metadata":{"papermill":{"duration":0.051615,"end_time":"2025-05-01T03:47:08.794229","exception":false,"start_time":"2025-05-01T03:47:08.742614","status":"completed"},"tags":[]},"outputs":[],"execution_count":null}]}