{"metadata":{"kernelspec":{"name":"python3","display_name":"Python 3","language":"python"},"language_info":{"name":"python","version":"3.10.14","mimetype":"text/x-python","codemirror_mode":{"name":"ipython","version":3},"pygments_lexer":"ipython3","nbconvert_exporter":"python","file_extension":".py"},"accelerator":"GPU","colab":{"gpuType":"T4","provenance":[]},"widgets":{"application/vnd.jupyter.widget-state+json":{"01617dae0b7647ff991231fc7d4302ca":{"model_module":"@jupyter-widgets/base","model_module_version":"1.2.0","model_name":"LayoutModel","state":{"_model_module":"@jupyter-widgets/base","_model_module_version":"1.2.0","_model_name":"LayoutModel","_view_count":null,"_view_module":"@jupyter-widgets/base","_view_module_version":"1.2.0","_view_name":"LayoutView","align_content":null,"align_items":null,"align_self":null,"border":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,"overflow_x":null,"overflow_y":null,"padding":null,"right":null,"top":null,"visibility":null,"width":null}},"018a325d68c5472593552fe66703b616":{"model_module":"@jupyter-widgets/controls","model_module_version":"1.5.0","model_name":"ProgressStyleModel","state":{"_model_module":"@jupyter-widgets/controls","_model_module_version":"1.5.0","_model_name":"ProgressStyleModel","_view_count":null,"_view_module":"@jupyter-widgets/base","_view_module_version":"1.2.0","_view_name":"StyleView","bar_color":null,"description_width":""}},"04635cace54c4c3c9ecc733ebcc438de":{"model_module":"@jupyter-widgets/controls","model_module_version":"1.5.0","model_name":"DescriptionStyleModel","state":{"_model_module":"@jupyter-widgets/controls","_model_module_version":"1.5.0","_model_name":"DescriptionStyleModel","_view_count":null,"_view_module":"@jupyter-widgets/base","_view_module_version":"1.2.0","_view_name":"StyleView","description_width":""}},"0f44169ff3e047d9b5feed269e173dd5":{"model_module":"@jupyter-widgets/base","model_module_version":"1.2.0","model_name":"LayoutModel","state":{"_model_module":"@jupyter-widgets/base","_model_module_version":"1.2.0","_model_name":"LayoutModel","_view_count":null,"_view_module":"@jupyter-widgets/base","_view_module_version":"1.2.0","_view_name":"LayoutView","align_content":null,"align_items":null,"align_self":null,"border":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,"overflow_x":null,"overflow_y":null,"padding":null,"right":null,"top":null,"visibility":null,"width":null}},"1079402f13b2433fa87a6a9e932594c0":{"model_module":"@jupyter-widgets/base","model_module_version":"1.2.0","model_name":"LayoutModel","state":{"_model_module":"@jupyter-widgets/base","_model_module_version":"1.2.0","_model_name":"LayoutModel","_view_count":null,"_view_module":"@jupyter-widgets/base","_view_module_version":"1.2.0","_view_name":"LayoutView","align_content":null,"align_items":null,"align_self":null,"border":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,"overflow_x":null,"overflow_y":null,"padding":null,"right":null,"top":null,"visibility":null,"width":null}},"142ca26ae20a42388f5e20916cea4761":{"model_module":"@jupyter-widgets/controls","model_module_version":"1.5.0","model_name":"DescriptionStyleModel","state":{"_model_module":"@jupyter-widgets/controls","_model_module_version":"1.5.0","_model_name":"DescriptionStyleModel","_view_count":null,"_view_module":"@jupyter-widgets/base","_view_module_version":"1.2.0","_view_name":"StyleView","description_width":""}},"1480f81dcd1c4a42947319c1c07363b4":{"model_module":"@jupyter-widgets/controls","model_module_version":"1.5.0","model_name":"DescriptionStyleModel","state":{"_model_module":"@jupyter-widgets/controls","_model_module_version":"1.5.0","_model_name":"DescriptionStyleModel","_view_count":null,"_view_module":"@jupyter-widgets/base","_view_module_version":"1.2.0","_view_name":"StyleView","description_width":""}},"15646e54c2a54ac0a2d6e122bbb83fbf":{"model_module":"@jupyter-widgets/base","model_module_version":"1.2.0","model_name":"LayoutModel","state":{"_model_module":"@jupyter-widgets/base","_model_module_version":"1.2.0","_model_name":"LayoutModel","_view_count":null,"_view_module":"@jupyter-widgets/base","_view_module_version":"1.2.0","_view_name":"LayoutView","align_content":null,"align_items":null,"align_self":null,"border":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,"overflow_x":null,"overflow_y":null,"padding":null,"right":null,"top":null,"visibility":null,"width":null}},"16d7bc410cbe46b9bac373fb3c57f25f":{"model_module":"@jupyter-widgets/controls","model_module_version":"1.5.0","model_name":"HTMLModel","state":{"_dom_classes":[],"_model_module":"@jupyter-widgets/controls","_model_module_version":"1.5.0","_model_name":"HTMLModel","_view_count":null,"_view_module":"@jupyter-widgets/controls","_view_module_version":"1.5.0","_view_name":"HTMLView","description":"","description_tooltip":null,"layout":"IPY_MODEL_4820d43186e340b0bcfab188e939d9da","placeholder":"​","style":"IPY_MODEL_184fbe81f2154dceb2880deeb7719e57","value":" 380/380 [02:43&lt;00:00,  2.42it/s]"}},"1790bd950ebe451eb82c76e245d52418":{"model_module":"@jupyter-widgets/controls","model_module_version":"1.5.0","model_name":"DescriptionStyleModel","state":{"_model_module":"@jupyter-widgets/controls","_model_module_version":"1.5.0","_model_name":"DescriptionStyleModel","_view_count":null,"_view_module":"@jupyter-widgets/base","_view_module_version":"1.2.0","_view_name":"StyleView","description_width":""}},"184fbe81f2154dceb2880deeb7719e57":{"model_module":"@jupyter-widgets/controls","model_module_version":"1.5.0","model_name":"DescriptionStyleModel","state":{"_model_module":"@jupyter-widgets/controls","_model_module_version":"1.5.0","_model_name":"DescriptionStyleModel","_view_count":null,"_view_module":"@jupyter-widgets/base","_view_module_version":"1.2.0","_view_name":"StyleView","description_width":""}},"1a34009b9bcc43508a74d4ca9adee005":{"model_module":"@jupyter-widgets/base","model_module_version":"1.2.0","model_name":"LayoutModel","state":{"_model_module":"@jupyter-widgets/base","_model_module_version":"1.2.0","_model_name":"LayoutModel","_view_count":null,"_view_module":"@jupyter-widgets/base","_view_module_version":"1.2.0","_view_name":"LayoutView","align_content":null,"align_items":null,"align_self":null,"border":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,"overflow_x":null,"overflow_y":null,"padding":null,"right":null,"top":null,"visibility":null,"width":null}},"1c10933f63e5487fbd99020534897cf7":{"model_module":"@jupyter-widgets/controls","model_module_version":"1.5.0","model_name":"VBoxModel","state":{"_dom_classes":[],"_model_module":"@jupyter-widgets/controls","_model_module_version":"1.5.0","_model_name":"VBoxModel","_view_count":null,"_view_module":"@jupyter-widgets/controls","_view_module_version":"1.5.0","_view_name":"VBoxView","box_style":"","children":["IPY_MODEL_686c85d9fb3a401993daa2aff7e6afd5","IPY_MODEL_87feb57d1f4b4dc0b5894abbb87db6e6","IPY_MODEL_343c0c802076464cb1daa07141fef5f8","IPY_MODEL_4e5fae5068484896a73fc741e2b7be7f"],"layout":"IPY_MODEL_d4985e9da642420d84ad31fcf1e12de5"}},"1d1f053b134446d49439dcac4e936a69":{"model_module":"@jupyter-widgets/base","model_module_version":"1.2.0","model_name":"LayoutModel","state":{"_model_module":"@jupyter-widgets/base","_model_module_version":"1.2.0","_model_name":"LayoutModel","_view_count":null,"_view_module":"@jupyter-widgets/base","_view_module_version":"1.2.0","_view_name":"LayoutView","align_content":null,"align_items":null,"align_self":null,"border":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,"overflow_x":null,"overflow_y":null,"padding":null,"right":null,"top":null,"visibility":null,"width":null}},"1df470e36c0c4ee7bbef758875c6bc27":{"model_module":"@jupyter-widgets/controls","model_module_version":"1.5.0","model_name":"ProgressStyleModel","state":{"_model_module":"@jupyter-widgets/controls","_model_module_version":"1.5.0","_model_name":"ProgressStyleModel","_view_count":null,"_view_module":"@jupyter-widgets/base","_view_module_version":"1.2.0","_view_name":"StyleView","bar_color":null,"description_width":""}},"1f53ebf0e0a347198a3d282879744226":{"model_module":"@jupyter-widgets/controls","model_module_version":"1.5.0","model_name":"FloatProgressModel","state":{"_dom_classes":[],"_model_module":"@jupyter-widgets/controls","_model_module_version":"1.5.0","_model_name":"FloatProgressModel","_view_count":null,"_view_module":"@jupyter-widgets/controls","_view_module_version":"1.5.0","_view_name":"ProgressView","bar_style":"success","description":"","description_tooltip":null,"layout":"IPY_MODEL_6794d7fe0c1c47f5b75f1fdeed8e9dda","max":380,"min":0,"orientation":"horizontal","style":"IPY_MODEL_1df470e36c0c4ee7bbef758875c6bc27","value":380}},"25c117dc79a84e969c37f5c26c2f3013":{"model_module":"@jupyter-widgets/base","model_module_version":"1.2.0","model_name":"LayoutModel","state":{"_model_module":"@jupyter-widgets/base","_model_module_version":"1.2.0","_model_name":"LayoutModel","_view_count":null,"_view_module":"@jupyter-widgets/base","_view_module_version":"1.2.0","_view_name":"LayoutView","align_content":null,"align_items":null,"align_self":null,"border":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,"overflow_x":null,"overflow_y":null,"padding":null,"right":null,"top":null,"visibility":null,"width":null}},"270d759fe1904101bf6576c370363b96":{"model_module":"@jupyter-widgets/controls","model_module_version":"1.5.0","model_name":"FloatProgressModel","state":{"_dom_classes":[],"_model_module":"@jupyter-widgets/controls","_model_module_version":"1.5.0","_model_name":"FloatProgressModel","_view_count":null,"_view_module":"@jupyter-widgets/controls","_view_module_version":"1.5.0","_view_name":"ProgressView","bar_style":"success","description":"","description_tooltip":null,"layout":"IPY_MODEL_39c294bf06904032911dd40d8d264cc5","max":1000,"min":0,"orientation":"horizontal","style":"IPY_MODEL_9d823811d5ca4e0ca22450d872fe4467","value":1000}},"2752582348a54d978a6b411af8d7ffca":{"model_module":"@jupyter-widgets/controls","model_module_version":"1.5.0","model_name":"DescriptionStyleModel","state":{"_model_module":"@jupyter-widgets/controls","_model_module_version":"1.5.0","_model_name":"DescriptionStyleModel","_view_count":null,"_view_module":"@jupyter-widgets/base","_view_module_version":"1.2.0","_view_name":"StyleView","description_width":""}},"277b352e19de41c58fc51c15a0c18dc1":{"model_module":"@jupyter-widgets/base","model_module_version":"1.2.0","model_name":"LayoutModel","state":{"_model_module":"@jupyter-widgets/base","_model_module_version":"1.2.0","_model_name":"LayoutModel","_view_count":null,"_view_module":"@jupyter-widgets/base","_view_module_version":"1.2.0","_view_name":"LayoutView","align_content":null,"align_items":null,"align_self":null,"border":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,"overflow_x":null,"overflow_y":null,"padding":null,"right":null,"top":null,"visibility":null,"width":null}},"2abe0ecda64d48f899eee1ae56be2f7a":{"model_module":"@jupyter-widgets/controls","model_module_version":"1.5.0","model_name":"HBoxModel","state":{"_dom_classes":[],"_model_module":"@jupyter-widgets/controls","_model_module_version":"1.5.0","_model_name":"HBoxModel","_view_count":null,"_view_module":"@jupyter-widgets/controls","_view_module_version":"1.5.0","_view_name":"HBoxView","box_style":"","children":["IPY_MODEL_b21db5cee72049cba95c1211fbd0efae","IPY_MODEL_5cd86ffbc6c2407ba86c8401d38700f8","IPY_MODEL_3621eba9e42543ca80cd548f525bdee5"],"layout":"IPY_MODEL_5c799a6daca3416fb9d6a9bb5534c486"}},"2ed0fb244d0d48379f164ebcf5b9368d":{"model_module":"@jupyter-widgets/controls","model_module_version":"1.5.0","model_name":"HTMLModel","state":{"_dom_classes":[],"_model_module":"@jupyter-widgets/controls","_model_module_version":"1.5.0","_model_name":"HTMLModel","_view_count":null,"_view_module":"@jupyter-widgets/controls","_view_module_version":"1.5.0","_view_name":"HTMLView","description":"","description_tooltip":null,"layout":"IPY_MODEL_15646e54c2a54ac0a2d6e122bbb83fbf","placeholder":"​","style":"IPY_MODEL_f9744ee7542849d09eca2199042bf828","value":"id2label.json: 100%"}},"2fb6cf1d29ac4cfb87cfd29343b36025":{"model_module":"@jupyter-widgets/controls","model_module_version":"1.5.0","model_name":"ProgressStyleModel","state":{"_model_module":"@jupyter-widgets/controls","_model_module_version":"1.5.0","_model_name":"ProgressStyleModel","_view_count":null,"_view_module":"@jupyter-widgets/base","_view_module_version":"1.2.0","_view_name":"StyleView","bar_color":null,"description_width":""}},"31524db81ee240fd830c437d95e48c23":{"model_module":"@jupyter-widgets/controls","model_module_version":"1.5.0","model_name":"DescriptionStyleModel","state":{"_model_module":"@jupyter-widgets/controls","_model_module_version":"1.5.0","_model_name":"DescriptionStyleModel","_view_count":null,"_view_module":"@jupyter-widgets/base","_view_module_version":"1.2.0","_view_name":"StyleView","description_width":""}},"340329f664a547cd81cf8ba256aaf482":{"model_module":"@jupyter-widgets/base","model_module_version":"1.2.0","model_name":"LayoutModel","state":{"_model_module":"@jupyter-widgets/base","_model_module_version":"1.2.0","_model_name":"LayoutModel","_view_count":null,"_view_module":"@jupyter-widgets/base","_view_module_version":"1.2.0","_view_name":"LayoutView","align_content":null,"align_items":null,"align_self":null,"border":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,"overflow_x":null,"overflow_y":null,"padding":null,"right":null,"top":null,"visibility":null,"width":null}},"343c0c802076464cb1daa07141fef5f8":{"model_module":"@jupyter-widgets/controls","model_module_version":"1.5.0","model_name":"LabelModel","state":{"_dom_classes":[],"_model_module":"@jupyter-widgets/controls","_model_module_version":"1.5.0","_model_name":"LabelModel","_view_count":null,"_view_module":"@jupyter-widgets/controls","_view_module_version":"1.5.0","_view_name":"LabelView","description":"","description_tooltip":null,"layout":"IPY_MODEL_7d764235f788482e8ad290825ec66e53","placeholder":"​","style":"IPY_MODEL_aaff3c510f9f48fe976da60123cd337c","value":"Your token has been saved to /root/.cache/huggingface/token"}},"3621eba9e42543ca80cd548f525bdee5":{"model_module":"@jupyter-widgets/controls","model_module_version":"1.5.0","model_name":"HTMLModel","state":{"_dom_classes":[],"_model_module":"@jupyter-widgets/controls","_model_module_version":"1.5.0","_model_name":"HTMLModel","_view_count":null,"_view_module":"@jupyter-widgets/controls","_view_module_version":"1.5.0","_view_name":"HTMLView","description":"","description_tooltip":null,"layout":"IPY_MODEL_eac91c8db5a54e8cb434be22f6942dbf","placeholder":"​","style":"IPY_MODEL_e009f2ee46fc4326bc4020cafff7f941","value":" 82.5k/82.5k [00:00&lt;00:00, 2.42MB/s]"}},"38293dc2747b4ec18ff981181fb978cc":{"model_module":"@jupyter-widgets/controls","model_module_version":"1.5.0","model_name":"ProgressStyleModel","state":{"_model_module":"@jupyter-widgets/controls","_model_module_version":"1.5.0","_model_name":"ProgressStyleModel","_view_count":null,"_view_module":"@jupyter-widgets/base","_view_module_version":"1.2.0","_view_name":"StyleView","bar_color":null,"description_width":""}},"39c294bf06904032911dd40d8d264cc5":{"model_module":"@jupyter-widgets/base","model_module_version":"1.2.0","model_name":"LayoutModel","state":{"_model_module":"@jupyter-widgets/base","_model_module_version":"1.2.0","_model_name":"LayoutModel","_view_count":null,"_view_module":"@jupyter-widgets/base","_view_module_version":"1.2.0","_view_name":"LayoutView","align_content":null,"align_items":null,"align_self":null,"border":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,"overflow_x":null,"overflow_y":null,"padding":null,"right":null,"top":null,"visibility":null,"width":null}},"3eea9c2d0b624b35a7ebdc6955317fd1":{"model_module":"@jupyter-widgets/controls","model_module_version":"1.5.0","model_name":"ProgressStyleModel","state":{"_model_module":"@jupyter-widgets/controls","_model_module_version":"1.5.0","_model_name":"ProgressStyleModel","_view_count":null,"_view_module":"@jupyter-widgets/base","_view_module_version":"1.2.0","_view_name":"StyleView","bar_color":null,"description_width":""}},"3f09061fb56b416ca8ee50a9ee4c8d28":{"model_module":"@jupyter-widgets/controls","model_module_version":"1.5.0","model_name":"HTMLModel","state":{"_dom_classes":[],"_model_module":"@jupyter-widgets/controls","_model_module_version":"1.5.0","_model_name":"HTMLModel","_view_count":null,"_view_module":"@jupyter-widgets/controls","_view_module_version":"1.5.0","_view_name":"HTMLView","description":"","description_tooltip":null,"layout":"IPY_MODEL_b08c48ea491043c6b123ca02ce1d398f","placeholder":"​","style":"IPY_MODEL_d65788532d294420812f5b02fb076c1f","value":"dataset_infos.json: 100%"}},"46560630018f48baa5f21d9385d860fc":{"model_module":"@jupyter-widgets/base","model_module_version":"1.2.0","model_name":"LayoutModel","state":{"_model_module":"@jupyter-widgets/base","_model_module_version":"1.2.0","_model_name":"LayoutModel","_view_count":null,"_view_module":"@jupyter-widgets/base","_view_module_version":"1.2.0","_view_name":"LayoutView","align_content":null,"align_items":null,"align_self":null,"border":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,"overflow_x":null,"overflow_y":null,"padding":null,"right":null,"top":null,"visibility":null,"width":null}},"46ef40bd54e743038a2616fe314befce":{"model_module":"@jupyter-widgets/base","model_module_version":"1.2.0","model_name":"LayoutModel","state":{"_model_module":"@jupyter-widgets/base","_model_module_version":"1.2.0","_model_name":"LayoutModel","_view_count":null,"_view_module":"@jupyter-widgets/base","_view_module_version":"1.2.0","_view_name":"LayoutView","align_content":null,"align_items":null,"align_self":null,"border":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,"overflow_x":null,"overflow_y":null,"padding":null,"right":null,"top":null,"visibility":null,"width":null}},"47556373d2d645bba072e2cc9c01b1c6":{"model_module":"@jupyter-widgets/controls","model_module_version":"1.5.0","model_name":"DescriptionStyleModel","state":{"_model_module":"@jupyter-widgets/controls","_model_module_version":"1.5.0","_model_name":"DescriptionStyleModel","_view_count":null,"_view_module":"@jupyter-widgets/base","_view_module_version":"1.2.0","_view_name":"StyleView","description_width":""}},"4820d43186e340b0bcfab188e939d9da":{"model_module":"@jupyter-widgets/base","model_module_version":"1.2.0","model_name":"LayoutModel","state":{"_model_module":"@jupyter-widgets/base","_model_module_version":"1.2.0","_model_name":"LayoutModel","_view_count":null,"_view_module":"@jupyter-widgets/base","_view_module_version":"1.2.0","_view_name":"LayoutView","align_content":null,"align_items":null,"align_self":null,"border":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,"overflow_x":null,"overflow_y":null,"padding":null,"right":null,"top":null,"visibility":null,"width":null}},"488221d4f67c43f49a263e6bc20c6a55":{"model_module":"@jupyter-widgets/controls","model_module_version":"1.5.0","model_name":"HTMLModel","state":{"_dom_classes":[],"_model_module":"@jupyter-widgets/controls","_model_module_version":"1.5.0","_model_name":"HTMLModel","_view_count":null,"_view_module":"@jupyter-widgets/controls","_view_module_version":"1.5.0","_view_name":"HTMLView","description":"","description_tooltip":null,"layout":"IPY_MODEL_46560630018f48baa5f21d9385d860fc","placeholder":"​","style":"IPY_MODEL_a94cd2cdc3754720a1545bcc436c9b69","value":" 324M/324M [00:02&lt;00:00, 174MB/s]"}},"48bd74d6f72241c68d68307fec652db5":{"model_module":"@jupyter-widgets/base","model_module_version":"1.2.0","model_name":"LayoutModel","state":{"_model_module":"@jupyter-widgets/base","_model_module_version":"1.2.0","_model_name":"LayoutModel","_view_count":null,"_view_module":"@jupyter-widgets/base","_view_module_version":"1.2.0","_view_name":"LayoutView","align_content":null,"align_items":null,"align_self":null,"border":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,"overflow_x":null,"overflow_y":null,"padding":null,"right":null,"top":null,"visibility":null,"width":null}},"4afe454c0dd74d819d15900f4bd04231":{"model_module":"@jupyter-widgets/controls","model_module_version":"1.5.0","model_name":"HTMLModel","state":{"_dom_classes":[],"_model_module":"@jupyter-widgets/controls","_model_module_version":"1.5.0","_model_name":"HTMLModel","_view_count":null,"_view_module":"@jupyter-widgets/controls","_view_module_version":"1.5.0","_view_name":"HTMLView","description":"","description_tooltip":null,"layout":"IPY_MODEL_01617dae0b7647ff991231fc7d4302ca","placeholder":"​","style":"IPY_MODEL_51062b719e2447cbb66f417fec6ed3b9","value":"100%"}},"4bd987ea76524ba19a8c33b0ca87e3f7":{"model_module":"@jupyter-widgets/controls","model_module_version":"1.5.0","model_name":"HBoxModel","state":{"_dom_classes":[],"_model_module":"@jupyter-widgets/controls","_model_module_version":"1.5.0","_model_name":"HBoxModel","_view_count":null,"_view_module":"@jupyter-widgets/controls","_view_module_version":"1.5.0","_view_name":"HBoxView","box_style":"","children":["IPY_MODEL_e1e88192495a4f68b2c88b66b07cdd12","IPY_MODEL_79116c4298324e778a91fc9b5a2ac65b","IPY_MODEL_ba35e93b2fee41e59858fe1b09cee62a"],"layout":"IPY_MODEL_5830a4ba350f407e949cb4c3df2e8cd6"}},"4c1565ae217b4853b51979f603c427ae":{"model_module":"@jupyter-widgets/controls","model_module_version":"1.5.0","model_name":"HTMLModel","state":{"_dom_classes":[],"_model_module":"@jupyter-widgets/controls","_model_module_version":"1.5.0","_model_name":"HTMLModel","_view_count":null,"_view_module":"@jupyter-widgets/controls","_view_module_version":"1.5.0","_view_name":"HTMLView","description":"","description_tooltip":null,"layout":"IPY_MODEL_0f44169ff3e047d9b5feed269e173dd5","placeholder":"​","style":"IPY_MODEL_fd91de21f1b64f71aeb6950d1968e152","value":"100%"}},"4d9cc4d9b4af4e0889f4797f6fba05f5":{"model_module":"@jupyter-widgets/controls","model_module_version":"1.5.0","model_name":"HBoxModel","state":{"_dom_classes":[],"_model_module":"@jupyter-widgets/controls","_model_module_version":"1.5.0","_model_name":"HBoxModel","_view_count":null,"_view_module":"@jupyter-widgets/controls","_view_module_version":"1.5.0","_view_name":"HBoxView","box_style":"","children":["IPY_MODEL_4c1565ae217b4853b51979f603c427ae","IPY_MODEL_1f53ebf0e0a347198a3d282879744226","IPY_MODEL_16d7bc410cbe46b9bac373fb3c57f25f"],"layout":"IPY_MODEL_48bd74d6f72241c68d68307fec652db5"}},"4e5fae5068484896a73fc741e2b7be7f":{"model_module":"@jupyter-widgets/controls","model_module_version":"1.5.0","model_name":"LabelModel","state":{"_dom_classes":[],"_model_module":"@jupyter-widgets/controls","_model_module_version":"1.5.0","_model_name":"LabelModel","_view_count":null,"_view_module":"@jupyter-widgets/controls","_view_module_version":"1.5.0","_view_name":"LabelView","description":"","description_tooltip":null,"layout":"IPY_MODEL_f357cad809ab4bfe88fad92b97f92fd2","placeholder":"​","style":"IPY_MODEL_7391a69eff5b42839b97435d53677fe2","value":"Login successful"}},"51062b719e2447cbb66f417fec6ed3b9":{"model_module":"@jupyter-widgets/controls","model_module_version":"1.5.0","model_name":"DescriptionStyleModel","state":{"_model_module":"@jupyter-widgets/controls","_model_module_version":"1.5.0","_model_name":"DescriptionStyleModel","_view_count":null,"_view_module":"@jupyter-widgets/base","_view_module_version":"1.2.0","_view_name":"StyleView","description_width":""}},"52f51e7e8ff44a0a9e72655539ccdb4f":{"model_module":"@jupyter-widgets/controls","model_module_version":"1.5.0","model_name":"HTMLModel","state":{"_dom_classes":[],"_model_module":"@jupyter-widgets/controls","_model_module_version":"1.5.0","_model_name":"HTMLModel","_view_count":null,"_view_module":"@jupyter-widgets/controls","_view_module_version":"1.5.0","_view_name":"HTMLView","description":"","description_tooltip":null,"layout":"IPY_MODEL_a4087fc90faf48e3b2203b22d54ae372","placeholder":"​","style":"IPY_MODEL_7727703b3d08479ebc45eb78e26cca35","value":" 866M/866M [00:14&lt;00:00, 85.6MB/s]"}},"54bf5459287444c6916357602ff3f36a":{"model_module":"@jupyter-widgets/controls","model_module_version":"1.5.0","model_name":"DescriptionStyleModel","state":{"_model_module":"@jupyter-widgets/controls","_model_module_version":"1.5.0","_model_name":"DescriptionStyleModel","_view_count":null,"_view_module":"@jupyter-widgets/base","_view_module_version":"1.2.0","_view_name":"StyleView","description_width":""}},"5692d20456044bf696688fbab86a1052":{"model_module":"@jupyter-widgets/base","model_module_version":"1.2.0","model_name":"LayoutModel","state":{"_model_module":"@jupyter-widgets/base","_model_module_version":"1.2.0","_model_name":"LayoutModel","_view_count":null,"_view_module":"@jupyter-widgets/base","_view_module_version":"1.2.0","_view_name":"LayoutView","align_content":null,"align_items":null,"align_self":null,"border":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,"overflow_x":null,"overflow_y":null,"padding":null,"right":null,"top":null,"visibility":null,"width":null}},"56a413738aef4fcbbd081d21b53cfc5f":{"model_module":"@jupyter-widgets/base","model_module_version":"1.2.0","model_name":"LayoutModel","state":{"_model_module":"@jupyter-widgets/base","_model_module_version":"1.2.0","_model_name":"LayoutModel","_view_count":null,"_view_module":"@jupyter-widgets/base","_view_module_version":"1.2.0","_view_name":"LayoutView","align_content":null,"align_items":null,"align_self":null,"border":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,"overflow_x":null,"overflow_y":null,"padding":null,"right":null,"top":null,"visibility":null,"width":null}},"5830a4ba350f407e949cb4c3df2e8cd6":{"model_module":"@jupyter-widgets/base","model_module_version":"1.2.0","model_name":"LayoutModel","state":{"_model_module":"@jupyter-widgets/base","_model_module_version":"1.2.0","_model_name":"LayoutModel","_view_count":null,"_view_module":"@jupyter-widgets/base","_view_module_version":"1.2.0","_view_name":"LayoutView","align_content":null,"align_items":null,"align_self":null,"border":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,"overflow_x":null,"overflow_y":null,"padding":null,"right":null,"top":null,"visibility":null,"width":null}},"59b11982ce384595a6ff6c2d5a7eaa13":{"model_module":"@jupyter-widgets/controls","model_module_version":"1.5.0","model_name":"ProgressStyleModel","state":{"_model_module":"@jupyter-widgets/controls","_model_module_version":"1.5.0","_model_name":"ProgressStyleModel","_view_count":null,"_view_module":"@jupyter-widgets/base","_view_module_version":"1.2.0","_view_name":"StyleView","bar_color":null,"description_width":""}},"5c32db16c9394eaca2a84717e7c85222":{"model_module":"@jupyter-widgets/controls","model_module_version":"1.5.0","model_name":"FloatProgressModel","state":{"_dom_classes":[],"_model_module":"@jupyter-widgets/controls","_model_module_version":"1.5.0","_model_name":"FloatProgressModel","_view_count":null,"_view_module":"@jupyter-widgets/controls","_view_module_version":"1.5.0","_view_name":"ProgressView","bar_style":"success","description":"","description_tooltip":null,"layout":"IPY_MODEL_9f83a210bd6f402a850955d9c2ef35a0","max":635,"min":0,"orientation":"horizontal","style":"IPY_MODEL_93a1b3c7dd784dd69eebf273ba626667","value":635}},"5c799a6daca3416fb9d6a9bb5534c486":{"model_module":"@jupyter-widgets/base","model_module_version":"1.2.0","model_name":"LayoutModel","state":{"_model_module":"@jupyter-widgets/base","_model_module_version":"1.2.0","_model_name":"LayoutModel","_view_count":null,"_view_module":"@jupyter-widgets/base","_view_module_version":"1.2.0","_view_name":"LayoutView","align_content":null,"align_items":null,"align_self":null,"border":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,"overflow_x":null,"overflow_y":null,"padding":null,"right":null,"top":null,"visibility":null,"width":null}},"5cd86ffbc6c2407ba86c8401d38700f8":{"model_module":"@jupyter-widgets/controls","model_module_version":"1.5.0","model_name":"FloatProgressModel","state":{"_dom_classes":[],"_model_module":"@jupyter-widgets/controls","_model_module_version":"1.5.0","_model_name":"FloatProgressModel","_view_count":null,"_view_module":"@jupyter-widgets/controls","_view_module_version":"1.5.0","_view_name":"ProgressView","bar_style":"success","description":"","description_tooltip":null,"layout":"IPY_MODEL_82cb045136a7447ea8b2f3ee74b3b219","max":82540,"min":0,"orientation":"horizontal","style":"IPY_MODEL_38293dc2747b4ec18ff981181fb978cc","value":82540}},"5f55d724f9fa497487534761f4e808a7":{"model_module":"@jupyter-widgets/controls","model_module_version":"1.5.0","model_name":"DescriptionStyleModel","state":{"_model_module":"@jupyter-widgets/controls","_model_module_version":"1.5.0","_model_name":"DescriptionStyleModel","_view_count":null,"_view_module":"@jupyter-widgets/base","_view_module_version":"1.2.0","_view_name":"StyleView","description_width":""}},"60280ba74d8b4940a7dc4df2e9f71415":{"model_module":"@jupyter-widgets/base","model_module_version":"1.2.0","model_name":"LayoutModel","state":{"_model_module":"@jupyter-widgets/base","_model_module_version":"1.2.0","_model_name":"LayoutModel","_view_count":null,"_view_module":"@jupyter-widgets/base","_view_module_version":"1.2.0","_view_name":"LayoutView","align_content":null,"align_items":null,"align_self":null,"border":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,"overflow_x":null,"overflow_y":null,"padding":null,"right":null,"top":null,"visibility":null,"width":null}},"6099fc437b9543048bc925bc9e13f818":{"model_module":"@jupyter-widgets/controls","model_module_version":"1.5.0","model_name":"DescriptionStyleModel","state":{"_model_module":"@jupyter-widgets/controls","_model_module_version":"1.5.0","_model_name":"DescriptionStyleModel","_view_count":null,"_view_module":"@jupyter-widgets/base","_view_module_version":"1.2.0","_view_name":"StyleView","description_width":""}},"63dc488a8d0d4d3eba7afc05032f4b3c":{"model_module":"@jupyter-widgets/controls","model_module_version":"1.5.0","model_name":"FloatProgressModel","state":{"_dom_classes":[],"_model_module":"@jupyter-widgets/controls","_model_module_version":"1.5.0","_model_name":"FloatProgressModel","_view_count":null,"_view_module":"@jupyter-widgets/controls","_view_module_version":"1.5.0","_view_name":"ProgressView","bar_style":"danger","description":"","description_tooltip":null,"layout":"IPY_MODEL_7f84b103ca49415882b375ce985d35f0","max":20,"min":0,"orientation":"horizontal","style":"IPY_MODEL_59b11982ce384595a6ff6c2d5a7eaa13","value":6}},"6598da2801324d7ea5ea1c84285b66e6":{"model_module":"@jupyter-widgets/controls","model_module_version":"1.5.0","model_name":"HBoxModel","state":{"_dom_classes":[],"_model_module":"@jupyter-widgets/controls","_model_module_version":"1.5.0","_model_name":"HBoxModel","_view_count":null,"_view_module":"@jupyter-widgets/controls","_view_module_version":"1.5.0","_view_name":"HBoxView","box_style":"","children":["IPY_MODEL_2ed0fb244d0d48379f164ebcf5b9368d","IPY_MODEL_e9bbce38a51f44069e2b828239441899","IPY_MODEL_c16947ce20884931962e892046767579"],"layout":"IPY_MODEL_60280ba74d8b4940a7dc4df2e9f71415"}},"6794d7fe0c1c47f5b75f1fdeed8e9dda":{"model_module":"@jupyter-widgets/base","model_module_version":"1.2.0","model_name":"LayoutModel","state":{"_model_module":"@jupyter-widgets/base","_model_module_version":"1.2.0","_model_name":"LayoutModel","_view_count":null,"_view_module":"@jupyter-widgets/base","_view_module_version":"1.2.0","_view_name":"LayoutView","align_content":null,"align_items":null,"align_self":null,"border":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,"overflow_x":null,"overflow_y":null,"padding":null,"right":null,"top":null,"visibility":null,"width":null}},"68023198f381435a93fcad2ce078b2e2":{"model_module":"@jupyter-widgets/controls","model_module_version":"1.5.0","model_name":"HTMLModel","state":{"_dom_classes":[],"_model_module":"@jupyter-widgets/controls","_model_module_version":"1.5.0","_model_name":"HTMLModel","_view_count":null,"_view_module":"@jupyter-widgets/controls","_view_module_version":"1.5.0","_view_name":"HTMLView","description":"","description_tooltip":null,"layout":"IPY_MODEL_ac48ddd1d88e4f45a4b506690c4e0f8c","placeholder":"​","style":"IPY_MODEL_1790bd950ebe451eb82c76e245d52418","value":" 1000/1000 [00:01&lt;00:00, 708.63 examples/s]"}},"686c85d9fb3a401993daa2aff7e6afd5":{"model_module":"@jupyter-widgets/controls","model_module_version":"1.5.0","model_name":"LabelModel","state":{"_dom_classes":[],"_model_module":"@jupyter-widgets/controls","_model_module_version":"1.5.0","_model_name":"LabelModel","_view_count":null,"_view_module":"@jupyter-widgets/controls","_view_module_version":"1.5.0","_view_name":"LabelView","description":"","description_tooltip":null,"layout":"IPY_MODEL_69d0bd2157924512926b65456d4db23d","placeholder":"​","style":"IPY_MODEL_1480f81dcd1c4a42947319c1c07363b4","value":"Token is valid (permission: write)."}},"68bdd452bed845cfb88d652bb443604a":{"model_module":"@jupyter-widgets/controls","model_module_version":"1.5.0","model_name":"DescriptionStyleModel","state":{"_model_module":"@jupyter-widgets/controls","_model_module_version":"1.5.0","_model_name":"DescriptionStyleModel","_view_count":null,"_view_module":"@jupyter-widgets/base","_view_module_version":"1.2.0","_view_name":"StyleView","description_width":""}},"68d1ebd789674373b2dc2709c50254e1":{"model_module":"@jupyter-widgets/base","model_module_version":"1.2.0","model_name":"LayoutModel","state":{"_model_module":"@jupyter-widgets/base","_model_module_version":"1.2.0","_model_name":"LayoutModel","_view_count":null,"_view_module":"@jupyter-widgets/base","_view_module_version":"1.2.0","_view_name":"LayoutView","align_content":null,"align_items":null,"align_self":null,"border":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,"overflow_x":null,"overflow_y":null,"padding":null,"right":null,"top":null,"visibility":null,"width":null}},"696a6444758044a1aabd5ae25021ffd5":{"model_module":"@jupyter-widgets/controls","model_module_version":"1.5.0","model_name":"HTMLModel","state":{"_dom_classes":[],"_model_module":"@jupyter-widgets/controls","_model_module_version":"1.5.0","_model_name":"HTMLModel","_view_count":null,"_view_module":"@jupyter-widgets/controls","_view_module_version":"1.5.0","_view_name":"HTMLView","description":"","description_tooltip":null,"layout":"IPY_MODEL_56a413738aef4fcbbd081d21b53cfc5f","placeholder":"​","style":"IPY_MODEL_04635cace54c4c3c9ecc733ebcc438de","value":"Generating train split: 100%"}},"69d0bd2157924512926b65456d4db23d":{"model_module":"@jupyter-widgets/base","model_module_version":"1.2.0","model_name":"LayoutModel","state":{"_model_module":"@jupyter-widgets/base","_model_module_version":"1.2.0","_model_name":"LayoutModel","_view_count":null,"_view_module":"@jupyter-widgets/base","_view_module_version":"1.2.0","_view_name":"LayoutView","align_content":null,"align_items":null,"align_self":null,"border":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,"overflow_x":null,"overflow_y":null,"padding":null,"right":null,"top":null,"visibility":null,"width":null}},"6bab45e4b3f24a8aa69df627cbbea575":{"model_module":"@jupyter-widgets/controls","model_module_version":"1.5.0","model_name":"HTMLModel","state":{"_dom_classes":[],"_model_module":"@jupyter-widgets/controls","_model_module_version":"1.5.0","_model_name":"HTMLModel","_view_count":null,"_view_module":"@jupyter-widgets/controls","_view_module_version":"1.5.0","_view_name":"HTMLView","description":"","description_tooltip":null,"layout":"IPY_MODEL_1079402f13b2433fa87a6a9e932594c0","placeholder":"​","style":"IPY_MODEL_47556373d2d645bba072e2cc9c01b1c6","value":" 4.26k/4.26k [00:00&lt;00:00, 138kB/s]"}},"6fc70f55a8f447e2939e1ed638df80c7":{"model_module":"@jupyter-widgets/controls","model_module_version":"1.5.0","model_name":"HBoxModel","state":{"_dom_classes":[],"_model_module":"@jupyter-widgets/controls","_model_module_version":"1.5.0","_model_name":"HBoxModel","_view_count":null,"_view_module":"@jupyter-widgets/controls","_view_module_version":"1.5.0","_view_name":"HBoxView","box_style":"","children":["IPY_MODEL_740c0ab7d00a4f0ea4a33683d3713d00","IPY_MODEL_d0962cfcae454d48823b20834aa7645c","IPY_MODEL_6bab45e4b3f24a8aa69df627cbbea575"],"layout":"IPY_MODEL_5692d20456044bf696688fbab86a1052"}},"7391a69eff5b42839b97435d53677fe2":{"model_module":"@jupyter-widgets/controls","model_module_version":"1.5.0","model_name":"DescriptionStyleModel","state":{"_model_module":"@jupyter-widgets/controls","_model_module_version":"1.5.0","_model_name":"DescriptionStyleModel","_view_count":null,"_view_module":"@jupyter-widgets/base","_view_module_version":"1.2.0","_view_name":"StyleView","description_width":""}},"740c0ab7d00a4f0ea4a33683d3713d00":{"model_module":"@jupyter-widgets/controls","model_module_version":"1.5.0","model_name":"HTMLModel","state":{"_dom_classes":[],"_model_module":"@jupyter-widgets/controls","_model_module_version":"1.5.0","_model_name":"HTMLModel","_view_count":null,"_view_module":"@jupyter-widgets/controls","_view_module_version":"1.5.0","_view_name":"HTMLView","description":"","description_tooltip":null,"layout":"IPY_MODEL_ceee8d6a76e7430eaa88f3cf26652f22","placeholder":"​","style":"IPY_MODEL_8e3deea9b35b4139bb2b7d001adcee86","value":"README.md: 100%"}},"746e2e69ac464b0c87cc388e5d22ded7":{"model_module":"@jupyter-widgets/base","model_module_version":"1.2.0","model_name":"LayoutModel","state":{"_model_module":"@jupyter-widgets/base","_model_module_version":"1.2.0","_model_name":"LayoutModel","_view_count":null,"_view_module":"@jupyter-widgets/base","_view_module_version":"1.2.0","_view_name":"LayoutView","align_content":null,"align_items":null,"align_self":null,"border":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,"overflow_x":null,"overflow_y":null,"padding":null,"right":null,"top":null,"visibility":null,"width":null}},"7727703b3d08479ebc45eb78e26cca35":{"model_module":"@jupyter-widgets/controls","model_module_version":"1.5.0","model_name":"DescriptionStyleModel","state":{"_model_module":"@jupyter-widgets/controls","_model_module_version":"1.5.0","_model_name":"DescriptionStyleModel","_view_count":null,"_view_module":"@jupyter-widgets/base","_view_module_version":"1.2.0","_view_name":"StyleView","description_width":""}},"7903e283086043fb9a66a3c7b00ffb04":{"model_module":"@jupyter-widgets/controls","model_module_version":"1.5.0","model_name":"HBoxModel","state":{"_dom_classes":[],"_model_module":"@jupyter-widgets/controls","_model_module_version":"1.5.0","_model_name":"HBoxModel","_view_count":null,"_view_module":"@jupyter-widgets/controls","_view_module_version":"1.5.0","_view_name":"HBoxView","box_style":"","children":["IPY_MODEL_ee3e3bb6219a49aabb6bf5350783bb4f","IPY_MODEL_63dc488a8d0d4d3eba7afc05032f4b3c","IPY_MODEL_7b3129a6c87f46eb9ebc14c3e87d39cf"],"layout":"IPY_MODEL_b3ea2b6e22574d84a1f3f69eee2b32fa"}},"79116c4298324e778a91fc9b5a2ac65b":{"model_module":"@jupyter-widgets/controls","model_module_version":"1.5.0","model_name":"FloatProgressModel","state":{"_dom_classes":[],"_model_module":"@jupyter-widgets/controls","_model_module_version":"1.5.0","_model_name":"FloatProgressModel","_view_count":null,"_view_module":"@jupyter-widgets/controls","_view_module_version":"1.5.0","_view_name":"ProgressView","bar_style":"danger","description":"","description_tooltip":null,"layout":"IPY_MODEL_746e2e69ac464b0c87cc388e5d22ded7","max":20,"min":0,"orientation":"horizontal","style":"IPY_MODEL_ce68f1410412405c9578e4d80814228a","value":6}},"7b3129a6c87f46eb9ebc14c3e87d39cf":{"model_module":"@jupyter-widgets/controls","model_module_version":"1.5.0","model_name":"HTMLModel","state":{"_dom_classes":[],"_model_module":"@jupyter-widgets/controls","_model_module_version":"1.5.0","_model_name":"HTMLModel","_view_count":null,"_view_module":"@jupyter-widgets/controls","_view_module_version":"1.5.0","_view_name":"HTMLView","description":"","description_tooltip":null,"layout":"IPY_MODEL_abcd30b56a6d4b90a38c333d92406381","placeholder":"​","style":"IPY_MODEL_ebf48db6bf844516a8a1e335c11f3db3","value":" 6/20 [01:58&lt;04:35, 19.67s/it]"}},"7d764235f788482e8ad290825ec66e53":{"model_module":"@jupyter-widgets/base","model_module_version":"1.2.0","model_name":"LayoutModel","state":{"_model_module":"@jupyter-widgets/base","_model_module_version":"1.2.0","_model_name":"LayoutModel","_view_count":null,"_view_module":"@jupyter-widgets/base","_view_module_version":"1.2.0","_view_name":"LayoutView","align_content":null,"align_items":null,"align_self":null,"border":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,"overflow_x":null,"overflow_y":null,"padding":null,"right":null,"top":null,"visibility":null,"width":null}},"7f84b103ca49415882b375ce985d35f0":{"model_module":"@jupyter-widgets/base","model_module_version":"1.2.0","model_name":"LayoutModel","state":{"_model_module":"@jupyter-widgets/base","_model_module_version":"1.2.0","_model_name":"LayoutModel","_view_count":null,"_view_module":"@jupyter-widgets/base","_view_module_version":"1.2.0","_view_name":"LayoutView","align_content":null,"align_items":null,"align_self":null,"border":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,"overflow_x":null,"overflow_y":null,"padding":null,"right":null,"top":null,"visibility":null,"width":null}},"8095ef3b177742c2bcf438484620e04f":{"model_module":"@jupyter-widgets/controls","model_module_version":"1.5.0","model_name":"HBoxModel","state":{"_dom_classes":[],"_model_module":"@jupyter-widgets/controls","_model_module_version":"1.5.0","_model_name":"HBoxModel","_view_count":null,"_view_module":"@jupyter-widgets/controls","_view_module_version":"1.5.0","_view_name":"HBoxView","box_style":"","children":["IPY_MODEL_696a6444758044a1aabd5ae25021ffd5","IPY_MODEL_270d759fe1904101bf6576c370363b96","IPY_MODEL_68023198f381435a93fcad2ce078b2e2"],"layout":"IPY_MODEL_9d0882a2cfa94182b620ac2d0e6f1c3d"}},"80fd0eb8606c41e796419aea5f9efc1c":{"model_module":"@jupyter-widgets/controls","model_module_version":"1.5.0","model_name":"DescriptionStyleModel","state":{"_model_module":"@jupyter-widgets/controls","_model_module_version":"1.5.0","_model_name":"DescriptionStyleModel","_view_count":null,"_view_module":"@jupyter-widgets/base","_view_module_version":"1.2.0","_view_name":"StyleView","description_width":""}},"82cb045136a7447ea8b2f3ee74b3b219":{"model_module":"@jupyter-widgets/base","model_module_version":"1.2.0","model_name":"LayoutModel","state":{"_model_module":"@jupyter-widgets/base","_model_module_version":"1.2.0","_model_name":"LayoutModel","_view_count":null,"_view_module":"@jupyter-widgets/base","_view_module_version":"1.2.0","_view_name":"LayoutView","align_content":null,"align_items":null,"align_self":null,"border":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,"overflow_x":null,"overflow_y":null,"padding":null,"right":null,"top":null,"visibility":null,"width":null}},"83bfb79ef0464b9c937d18ba4dc8a40a":{"model_module":"@jupyter-widgets/base","model_module_version":"1.2.0","model_name":"LayoutModel","state":{"_model_module":"@jupyter-widgets/base","_model_module_version":"1.2.0","_model_name":"LayoutModel","_view_count":null,"_view_module":"@jupyter-widgets/base","_view_module_version":"1.2.0","_view_name":"LayoutView","align_content":null,"align_items":null,"align_self":null,"border":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,"overflow_x":null,"overflow_y":null,"padding":null,"right":null,"top":null,"visibility":null,"width":null}},"8781867aca33479faafb06889b9cae54":{"model_module":"@jupyter-widgets/controls","model_module_version":"1.5.0","model_name":"ProgressStyleModel","state":{"_model_module":"@jupyter-widgets/controls","_model_module_version":"1.5.0","_model_name":"ProgressStyleModel","_view_count":null,"_view_module":"@jupyter-widgets/base","_view_module_version":"1.2.0","_view_name":"StyleView","bar_color":null,"description_width":""}},"87b417f7a835472285fcb95c0b127b70":{"model_module":"@jupyter-widgets/base","model_module_version":"1.2.0","model_name":"LayoutModel","state":{"_model_module":"@jupyter-widgets/base","_model_module_version":"1.2.0","_model_name":"LayoutModel","_view_count":null,"_view_module":"@jupyter-widgets/base","_view_module_version":"1.2.0","_view_name":"LayoutView","align_content":null,"align_items":null,"align_self":null,"border":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,"overflow_x":null,"overflow_y":null,"padding":null,"right":null,"top":null,"visibility":null,"width":null}},"87feb57d1f4b4dc0b5894abbb87db6e6":{"model_module":"@jupyter-widgets/controls","model_module_version":"1.5.0","model_name":"LabelModel","state":{"_dom_classes":[],"_model_module":"@jupyter-widgets/controls","_model_module_version":"1.5.0","_model_name":"LabelModel","_view_count":null,"_view_module":"@jupyter-widgets/controls","_view_module_version":"1.5.0","_view_name":"LabelView","description":"","description_tooltip":null,"layout":"IPY_MODEL_932f7e39e62e4dc99cdca1875ce795c6","placeholder":"​","style":"IPY_MODEL_142ca26ae20a42388f5e20916cea4761","value":"Your token has been saved in your configured git credential helpers (store)."}},"8991f225eb754b11a1b056a55fc2da84":{"model_module":"@jupyter-widgets/base","model_module_version":"1.2.0","model_name":"LayoutModel","state":{"_model_module":"@jupyter-widgets/base","_model_module_version":"1.2.0","_model_name":"LayoutModel","_view_count":null,"_view_module":"@jupyter-widgets/base","_view_module_version":"1.2.0","_view_name":"LayoutView","align_content":null,"align_items":null,"align_self":null,"border":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,"overflow_x":null,"overflow_y":null,"padding":null,"right":null,"top":null,"visibility":null,"width":null}},"8a4848c0ce90421c86fd00dea92716e5":{"model_module":"@jupyter-widgets/controls","model_module_version":"1.5.0","model_name":"DescriptionStyleModel","state":{"_model_module":"@jupyter-widgets/controls","_model_module_version":"1.5.0","_model_name":"DescriptionStyleModel","_view_count":null,"_view_module":"@jupyter-widgets/base","_view_module_version":"1.2.0","_view_name":"StyleView","description_width":""}},"8a90194ec5044a00ab933ac788c2ce97":{"model_module":"@jupyter-widgets/controls","model_module_version":"1.5.0","model_name":"FloatProgressModel","state":{"_dom_classes":[],"_model_module":"@jupyter-widgets/controls","_model_module_version":"1.5.0","_model_name":"FloatProgressModel","_view_count":null,"_view_module":"@jupyter-widgets/controls","_view_module_version":"1.5.0","_view_name":"ProgressView","bar_style":"success","description":"","description_tooltip":null,"layout":"IPY_MODEL_68d1ebd789674373b2dc2709c50254e1","max":866052064,"min":0,"orientation":"horizontal","style":"IPY_MODEL_96d217af725c4ffa97f7846cf1576d03","value":866052064}},"8d7dbc32a0ad40ad95086fa8dbd47ed2":{"model_module":"@jupyter-widgets/controls","model_module_version":"1.5.0","model_name":"HBoxModel","state":{"_dom_classes":[],"_model_module":"@jupyter-widgets/controls","_model_module_version":"1.5.0","_model_name":"HBoxModel","_view_count":null,"_view_module":"@jupyter-widgets/controls","_view_module_version":"1.5.0","_view_name":"HBoxView","box_style":"","children":["IPY_MODEL_3f09061fb56b416ca8ee50a9ee4c8d28","IPY_MODEL_5c32db16c9394eaca2a84717e7c85222","IPY_MODEL_d3572729408f4cf283b8ea11bfa1dfaa"],"layout":"IPY_MODEL_cfc9ee58e23c469ca0436e0ddcb3957e"}},"8df418c659084100b76130ce6dde86e7":{"model_module":"@jupyter-widgets/controls","model_module_version":"1.5.0","model_name":"FloatProgressModel","state":{"_dom_classes":[],"_model_module":"@jupyter-widgets/controls","_model_module_version":"1.5.0","_model_name":"FloatProgressModel","_view_count":null,"_view_module":"@jupyter-widgets/controls","_view_module_version":"1.5.0","_view_name":"ProgressView","bar_style":"success","description":"","description_tooltip":null,"layout":"IPY_MODEL_1d1f053b134446d49439dcac4e936a69","max":324302379,"min":0,"orientation":"horizontal","style":"IPY_MODEL_8781867aca33479faafb06889b9cae54","value":324302379}},"8e3deea9b35b4139bb2b7d001adcee86":{"model_module":"@jupyter-widgets/controls","model_module_version":"1.5.0","model_name":"DescriptionStyleModel","state":{"_model_module":"@jupyter-widgets/controls","_model_module_version":"1.5.0","_model_name":"DescriptionStyleModel","_view_count":null,"_view_module":"@jupyter-widgets/base","_view_module_version":"1.2.0","_view_name":"StyleView","description_width":""}},"932f7e39e62e4dc99cdca1875ce795c6":{"model_module":"@jupyter-widgets/base","model_module_version":"1.2.0","model_name":"LayoutModel","state":{"_model_module":"@jupyter-widgets/base","_model_module_version":"1.2.0","_model_name":"LayoutModel","_view_count":null,"_view_module":"@jupyter-widgets/base","_view_module_version":"1.2.0","_view_name":"LayoutView","align_content":null,"align_items":null,"align_self":null,"border":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,"overflow_x":null,"overflow_y":null,"padding":null,"right":null,"top":null,"visibility":null,"width":null}},"93a1b3c7dd784dd69eebf273ba626667":{"model_module":"@jupyter-widgets/controls","model_module_version":"1.5.0","model_name":"ProgressStyleModel","state":{"_model_module":"@jupyter-widgets/controls","_model_module_version":"1.5.0","_model_name":"ProgressStyleModel","_view_count":null,"_view_module":"@jupyter-widgets/base","_view_module_version":"1.2.0","_view_name":"StyleView","bar_color":null,"description_width":""}},"96d217af725c4ffa97f7846cf1576d03":{"model_module":"@jupyter-widgets/controls","model_module_version":"1.5.0","model_name":"ProgressStyleModel","state":{"_model_module":"@jupyter-widgets/controls","_model_module_version":"1.5.0","_model_name":"ProgressStyleModel","_view_count":null,"_view_module":"@jupyter-widgets/base","_view_module_version":"1.2.0","_view_name":"StyleView","bar_color":null,"description_width":""}},"97867c3e4e5e47ef96fe1a2644fdf246":{"model_module":"@jupyter-widgets/controls","model_module_version":"1.5.0","model_name":"DescriptionStyleModel","state":{"_model_module":"@jupyter-widgets/controls","_model_module_version":"1.5.0","_model_name":"DescriptionStyleModel","_view_count":null,"_view_module":"@jupyter-widgets/base","_view_module_version":"1.2.0","_view_name":"StyleView","description_width":""}},"990df94ce43a499fbba4d937f9889c13":{"model_module":"@jupyter-widgets/controls","model_module_version":"1.5.0","model_name":"FloatProgressModel","state":{"_dom_classes":[],"_model_module":"@jupyter-widgets/controls","_model_module_version":"1.5.0","_model_name":"FloatProgressModel","_view_count":null,"_view_module":"@jupyter-widgets/controls","_view_module_version":"1.5.0","_view_name":"ProgressView","bar_style":"success","description":"","description_tooltip":null,"layout":"IPY_MODEL_25c117dc79a84e969c37f5c26c2f3013","max":538,"min":0,"orientation":"horizontal","style":"IPY_MODEL_3eea9c2d0b624b35a7ebdc6955317fd1","value":538}},"9d0882a2cfa94182b620ac2d0e6f1c3d":{"model_module":"@jupyter-widgets/base","model_module_version":"1.2.0","model_name":"LayoutModel","state":{"_model_module":"@jupyter-widgets/base","_model_module_version":"1.2.0","_model_name":"LayoutModel","_view_count":null,"_view_module":"@jupyter-widgets/base","_view_module_version":"1.2.0","_view_name":"LayoutView","align_content":null,"align_items":null,"align_self":null,"border":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,"overflow_x":null,"overflow_y":null,"padding":null,"right":null,"top":null,"visibility":null,"width":null}},"9d823811d5ca4e0ca22450d872fe4467":{"model_module":"@jupyter-widgets/controls","model_module_version":"1.5.0","model_name":"ProgressStyleModel","state":{"_model_module":"@jupyter-widgets/controls","_model_module_version":"1.5.0","_model_name":"ProgressStyleModel","_view_count":null,"_view_module":"@jupyter-widgets/base","_view_module_version":"1.2.0","_view_name":"StyleView","bar_color":null,"description_width":""}},"9dad9cbd81d24086bc0cef4ed42e07b3":{"model_module":"@jupyter-widgets/controls","model_module_version":"1.5.0","model_name":"HTMLModel","state":{"_dom_classes":[],"_model_module":"@jupyter-widgets/controls","_model_module_version":"1.5.0","_model_name":"HTMLModel","_view_count":null,"_view_module":"@jupyter-widgets/controls","_view_module_version":"1.5.0","_view_name":"HTMLView","description":"","description_tooltip":null,"layout":"IPY_MODEL_83bfb79ef0464b9c937d18ba4dc8a40a","placeholder":"​","style":"IPY_MODEL_5f55d724f9fa497487534761f4e808a7","value":"train-00000-of-00001.parquet: 100%"}},"9f83a210bd6f402a850955d9c2ef35a0":{"model_module":"@jupyter-widgets/base","model_module_version":"1.2.0","model_name":"LayoutModel","state":{"_model_module":"@jupyter-widgets/base","_model_module_version":"1.2.0","_model_name":"LayoutModel","_view_count":null,"_view_module":"@jupyter-widgets/base","_view_module_version":"1.2.0","_view_name":"LayoutView","align_content":null,"align_items":null,"align_self":null,"border":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,"overflow_x":null,"overflow_y":null,"padding":null,"right":null,"top":null,"visibility":null,"width":null}},"a1d299215b7c4e6a8be05a6ad6d3ebb9":{"model_module":"@jupyter-widgets/base","model_module_version":"1.2.0","model_name":"LayoutModel","state":{"_model_module":"@jupyter-widgets/base","_model_module_version":"1.2.0","_model_name":"LayoutModel","_view_count":null,"_view_module":"@jupyter-widgets/base","_view_module_version":"1.2.0","_view_name":"LayoutView","align_content":null,"align_items":null,"align_self":null,"border":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,"overflow_x":null,"overflow_y":null,"padding":null,"right":null,"top":null,"visibility":null,"width":null}},"a4087fc90faf48e3b2203b22d54ae372":{"model_module":"@jupyter-widgets/base","model_module_version":"1.2.0","model_name":"LayoutModel","state":{"_model_module":"@jupyter-widgets/base","_model_module_version":"1.2.0","_model_name":"LayoutModel","_view_count":null,"_view_module":"@jupyter-widgets/base","_view_module_version":"1.2.0","_view_name":"LayoutView","align_content":null,"align_items":null,"align_self":null,"border":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,"overflow_x":null,"overflow_y":null,"padding":null,"right":null,"top":null,"visibility":null,"width":null}},"a560d89bb5b747ea8d6d7339ebf996cd":{"model_module":"@jupyter-widgets/controls","model_module_version":"1.5.0","model_name":"HTMLModel","state":{"_dom_classes":[],"_model_module":"@jupyter-widgets/controls","_model_module_version":"1.5.0","_model_name":"HTMLModel","_view_count":null,"_view_module":"@jupyter-widgets/controls","_view_module_version":"1.5.0","_view_name":"HTMLView","description":"","description_tooltip":null,"layout":"IPY_MODEL_f197268b4a7b49a28c0150d97ae00c2c","placeholder":"​","style":"IPY_MODEL_2752582348a54d978a6b411af8d7ffca","value":"preprocessor_config.json: 100%"}},"a8cfcc83ea4d4c3e8c0eb40d345d605d":{"model_module":"@jupyter-widgets/controls","model_module_version":"1.5.0","model_name":"HBoxModel","state":{"_dom_classes":[],"_model_module":"@jupyter-widgets/controls","_model_module_version":"1.5.0","_model_name":"HBoxModel","_view_count":null,"_view_module":"@jupyter-widgets/controls","_view_module_version":"1.5.0","_view_name":"HBoxView","box_style":"","children":["IPY_MODEL_fde783dc2fcc4cf5848a8d6fd9f2060b","IPY_MODEL_8a90194ec5044a00ab933ac788c2ce97","IPY_MODEL_52f51e7e8ff44a0a9e72655539ccdb4f"],"layout":"IPY_MODEL_c2ff48c2b6ec47c89d1465b0103fddce"}},"a94cd2cdc3754720a1545bcc436c9b69":{"model_module":"@jupyter-widgets/controls","model_module_version":"1.5.0","model_name":"DescriptionStyleModel","state":{"_model_module":"@jupyter-widgets/controls","_model_module_version":"1.5.0","_model_name":"DescriptionStyleModel","_view_count":null,"_view_module":"@jupyter-widgets/base","_view_module_version":"1.2.0","_view_name":"StyleView","description_width":""}},"aaff3c510f9f48fe976da60123cd337c":{"model_module":"@jupyter-widgets/controls","model_module_version":"1.5.0","model_name":"DescriptionStyleModel","state":{"_model_module":"@jupyter-widgets/controls","_model_module_version":"1.5.0","_model_name":"DescriptionStyleModel","_view_count":null,"_view_module":"@jupyter-widgets/base","_view_module_version":"1.2.0","_view_name":"StyleView","description_width":""}},"abcd30b56a6d4b90a38c333d92406381":{"model_module":"@jupyter-widgets/base","model_module_version":"1.2.0","model_name":"LayoutModel","state":{"_model_module":"@jupyter-widgets/base","_model_module_version":"1.2.0","_model_name":"LayoutModel","_view_count":null,"_view_module":"@jupyter-widgets/base","_view_module_version":"1.2.0","_view_name":"LayoutView","align_content":null,"align_items":null,"align_self":null,"border":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,"overflow_x":null,"overflow_y":null,"padding":null,"right":null,"top":null,"visibility":null,"width":null}},"ac48ddd1d88e4f45a4b506690c4e0f8c":{"model_module":"@jupyter-widgets/base","model_module_version":"1.2.0","model_name":"LayoutModel","state":{"_model_module":"@jupyter-widgets/base","_model_module_version":"1.2.0","_model_name":"LayoutModel","_view_count":null,"_view_module":"@jupyter-widgets/base","_view_module_version":"1.2.0","_view_name":"LayoutView","align_content":null,"align_items":null,"align_self":null,"border":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,"overflow_x":null,"overflow_y":null,"padding":null,"right":null,"top":null,"visibility":null,"width":null}},"ad21c824c27e403db7f3c2f03706dc8e":{"model_module":"@jupyter-widgets/base","model_module_version":"1.2.0","model_name":"LayoutModel","state":{"_model_module":"@jupyter-widgets/base","_model_module_version":"1.2.0","_model_name":"LayoutModel","_view_count":null,"_view_module":"@jupyter-widgets/base","_view_module_version":"1.2.0","_view_name":"LayoutView","align_content":null,"align_items":null,"align_self":null,"border":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,"overflow_x":null,"overflow_y":null,"padding":null,"right":null,"top":null,"visibility":null,"width":null}},"af86b03ee63f47d99dcba2c2d5f87a43":{"model_module":"@jupyter-widgets/base","model_module_version":"1.2.0","model_name":"LayoutModel","state":{"_model_module":"@jupyter-widgets/base","_model_module_version":"1.2.0","_model_name":"LayoutModel","_view_count":null,"_view_module":"@jupyter-widgets/base","_view_module_version":"1.2.0","_view_name":"LayoutView","align_content":null,"align_items":null,"align_self":null,"border":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,"overflow_x":null,"overflow_y":null,"padding":null,"right":null,"top":null,"visibility":null,"width":null}},"b08c48ea491043c6b123ca02ce1d398f":{"model_module":"@jupyter-widgets/base","model_module_version":"1.2.0","model_name":"LayoutModel","state":{"_model_module":"@jupyter-widgets/base","_model_module_version":"1.2.0","_model_name":"LayoutModel","_view_count":null,"_view_module":"@jupyter-widgets/base","_view_module_version":"1.2.0","_view_name":"LayoutView","align_content":null,"align_items":null,"align_self":null,"border":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,"overflow_x":null,"overflow_y":null,"padding":null,"right":null,"top":null,"visibility":null,"width":null}},"b21db5cee72049cba95c1211fbd0efae":{"model_module":"@jupyter-widgets/controls","model_module_version":"1.5.0","model_name":"HTMLModel","state":{"_dom_classes":[],"_model_module":"@jupyter-widgets/controls","_model_module_version":"1.5.0","_model_name":"HTMLModel","_view_count":null,"_view_module":"@jupyter-widgets/controls","_view_module_version":"1.5.0","_view_name":"HTMLView","description":"","description_tooltip":null,"layout":"IPY_MODEL_d5219deca99c438fb9d440b1c701597c","placeholder":"​","style":"IPY_MODEL_80fd0eb8606c41e796419aea5f9efc1c","value":"config.json: 100%"}},"b3ea2b6e22574d84a1f3f69eee2b32fa":{"model_module":"@jupyter-widgets/base","model_module_version":"1.2.0","model_name":"LayoutModel","state":{"_model_module":"@jupyter-widgets/base","_model_module_version":"1.2.0","_model_name":"LayoutModel","_view_count":null,"_view_module":"@jupyter-widgets/base","_view_module_version":"1.2.0","_view_name":"LayoutView","align_content":null,"align_items":null,"align_self":null,"border":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,"overflow_x":null,"overflow_y":null,"padding":null,"right":null,"top":null,"visibility":null,"width":null}},"b5a5f21a612143a1b07322eb2883aaf8":{"model_module":"@jupyter-widgets/controls","model_module_version":"1.5.0","model_name":"HBoxModel","state":{"_dom_classes":[],"_model_module":"@jupyter-widgets/controls","_model_module_version":"1.5.0","_model_name":"HBoxModel","_view_count":null,"_view_module":"@jupyter-widgets/controls","_view_module_version":"1.5.0","_view_name":"HBoxView","box_style":"","children":["IPY_MODEL_4afe454c0dd74d819d15900f4bd04231","IPY_MODEL_e8f73e63bf8a4822af43c33ead93649b","IPY_MODEL_e1905b6d2665450b8c89f05a582b299f"],"layout":"IPY_MODEL_277b352e19de41c58fc51c15a0c18dc1"}},"b739f86a36064c3c96626f1276359ae2":{"model_module":"@jupyter-widgets/controls","model_module_version":"1.5.0","model_name":"ProgressStyleModel","state":{"_model_module":"@jupyter-widgets/controls","_model_module_version":"1.5.0","_model_name":"ProgressStyleModel","_view_count":null,"_view_module":"@jupyter-widgets/base","_view_module_version":"1.2.0","_view_name":"StyleView","bar_color":null,"description_width":""}},"ba35e93b2fee41e59858fe1b09cee62a":{"model_module":"@jupyter-widgets/controls","model_module_version":"1.5.0","model_name":"HTMLModel","state":{"_dom_classes":[],"_model_module":"@jupyter-widgets/controls","_model_module_version":"1.5.0","_model_name":"HTMLModel","_view_count":null,"_view_module":"@jupyter-widgets/controls","_view_module_version":"1.5.0","_view_name":"HTMLView","description":"","description_tooltip":null,"layout":"IPY_MODEL_ad21c824c27e403db7f3c2f03706dc8e","placeholder":"​","style":"IPY_MODEL_97867c3e4e5e47ef96fe1a2644fdf246","value":" 6/20 [01:52&lt;04:23, 18.81s/it]"}},"bce506b6be854ed5ad405ce29bbed051":{"model_module":"@jupyter-widgets/controls","model_module_version":"1.5.0","model_name":"DescriptionStyleModel","state":{"_model_module":"@jupyter-widgets/controls","_model_module_version":"1.5.0","_model_name":"DescriptionStyleModel","_view_count":null,"_view_module":"@jupyter-widgets/base","_view_module_version":"1.2.0","_view_name":"StyleView","description_width":""}},"bfc76c2fb92d4959b21a55121efc1f7a":{"model_module":"@jupyter-widgets/controls","model_module_version":"1.5.0","model_name":"DescriptionStyleModel","state":{"_model_module":"@jupyter-widgets/controls","_model_module_version":"1.5.0","_model_name":"DescriptionStyleModel","_view_count":null,"_view_module":"@jupyter-widgets/base","_view_module_version":"1.2.0","_view_name":"StyleView","description_width":""}},"c16947ce20884931962e892046767579":{"model_module":"@jupyter-widgets/controls","model_module_version":"1.5.0","model_name":"HTMLModel","state":{"_dom_classes":[],"_model_module":"@jupyter-widgets/controls","_model_module_version":"1.5.0","_model_name":"HTMLModel","_view_count":null,"_view_module":"@jupyter-widgets/controls","_view_module_version":"1.5.0","_view_name":"HTMLView","description":"","description_tooltip":null,"layout":"IPY_MODEL_c7abebb518d248fbb7e573bca72c2aba","placeholder":"​","style":"IPY_MODEL_8a4848c0ce90421c86fd00dea92716e5","value":" 852/852 [00:00&lt;00:00, 63.2kB/s]"}},"c19fca2497d24cfeb7ddf74d9d94a621":{"model_module":"@jupyter-widgets/base","model_module_version":"1.2.0","model_name":"LayoutModel","state":{"_model_module":"@jupyter-widgets/base","_model_module_version":"1.2.0","_model_name":"LayoutModel","_view_count":null,"_view_module":"@jupyter-widgets/base","_view_module_version":"1.2.0","_view_name":"LayoutView","align_content":null,"align_items":null,"align_self":null,"border":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,"overflow_x":null,"overflow_y":null,"padding":null,"right":null,"top":null,"visibility":null,"width":null}},"c2ff48c2b6ec47c89d1465b0103fddce":{"model_module":"@jupyter-widgets/base","model_module_version":"1.2.0","model_name":"LayoutModel","state":{"_model_module":"@jupyter-widgets/base","_model_module_version":"1.2.0","_model_name":"LayoutModel","_view_count":null,"_view_module":"@jupyter-widgets/base","_view_module_version":"1.2.0","_view_name":"LayoutView","align_content":null,"align_items":null,"align_self":null,"border":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,"overflow_x":null,"overflow_y":null,"padding":null,"right":null,"top":null,"visibility":null,"width":null}},"c7abebb518d248fbb7e573bca72c2aba":{"model_module":"@jupyter-widgets/base","model_module_version":"1.2.0","model_name":"LayoutModel","state":{"_model_module":"@jupyter-widgets/base","_model_module_version":"1.2.0","_model_name":"LayoutModel","_view_count":null,"_view_module":"@jupyter-widgets/base","_view_module_version":"1.2.0","_view_name":"LayoutView","align_content":null,"align_items":null,"align_self":null,"border":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,"overflow_x":null,"overflow_y":null,"padding":null,"right":null,"top":null,"visibility":null,"width":null}},"cb4d178f4c8d47bbb8d5f653c0ee6077":{"model_module":"@jupyter-widgets/base","model_module_version":"1.2.0","model_name":"LayoutModel","state":{"_model_module":"@jupyter-widgets/base","_model_module_version":"1.2.0","_model_name":"LayoutModel","_view_count":null,"_view_module":"@jupyter-widgets/base","_view_module_version":"1.2.0","_view_name":"LayoutView","align_content":null,"align_items":null,"align_self":null,"border":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,"overflow_x":null,"overflow_y":null,"padding":null,"right":null,"top":null,"visibility":null,"width":null}},"cdc0ede841c44b14a60ff8969af87740":{"model_module":"@jupyter-widgets/controls","model_module_version":"1.5.0","model_name":"HBoxModel","state":{"_dom_classes":[],"_model_module":"@jupyter-widgets/controls","_model_module_version":"1.5.0","_model_name":"HBoxModel","_view_count":null,"_view_module":"@jupyter-widgets/controls","_view_module_version":"1.5.0","_view_name":"HBoxView","box_style":"","children":["IPY_MODEL_a560d89bb5b747ea8d6d7339ebf996cd","IPY_MODEL_990df94ce43a499fbba4d937f9889c13","IPY_MODEL_d6ad45ae8306476b868cde1e49f5f42c"],"layout":"IPY_MODEL_af86b03ee63f47d99dcba2c2d5f87a43"}},"ce68f1410412405c9578e4d80814228a":{"model_module":"@jupyter-widgets/controls","model_module_version":"1.5.0","model_name":"ProgressStyleModel","state":{"_model_module":"@jupyter-widgets/controls","_model_module_version":"1.5.0","_model_name":"ProgressStyleModel","_view_count":null,"_view_module":"@jupyter-widgets/base","_view_module_version":"1.2.0","_view_name":"StyleView","bar_color":null,"description_width":""}},"ceee8d6a76e7430eaa88f3cf26652f22":{"model_module":"@jupyter-widgets/base","model_module_version":"1.2.0","model_name":"LayoutModel","state":{"_model_module":"@jupyter-widgets/base","_model_module_version":"1.2.0","_model_name":"LayoutModel","_view_count":null,"_view_module":"@jupyter-widgets/base","_view_module_version":"1.2.0","_view_name":"LayoutView","align_content":null,"align_items":null,"align_self":null,"border":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,"overflow_x":null,"overflow_y":null,"padding":null,"right":null,"top":null,"visibility":null,"width":null}},"cfc9ee58e23c469ca0436e0ddcb3957e":{"model_module":"@jupyter-widgets/base","model_module_version":"1.2.0","model_name":"LayoutModel","state":{"_model_module":"@jupyter-widgets/base","_model_module_version":"1.2.0","_model_name":"LayoutModel","_view_count":null,"_view_module":"@jupyter-widgets/base","_view_module_version":"1.2.0","_view_name":"LayoutView","align_content":null,"align_items":null,"align_self":null,"border":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,"overflow_x":null,"overflow_y":null,"padding":null,"right":null,"top":null,"visibility":null,"width":null}},"d0962cfcae454d48823b20834aa7645c":{"model_module":"@jupyter-widgets/controls","model_module_version":"1.5.0","model_name":"FloatProgressModel","state":{"_dom_classes":[],"_model_module":"@jupyter-widgets/controls","_model_module_version":"1.5.0","_model_name":"FloatProgressModel","_view_count":null,"_view_module":"@jupyter-widgets/controls","_view_module_version":"1.5.0","_view_name":"ProgressView","bar_style":"success","description":"","description_tooltip":null,"layout":"IPY_MODEL_cb4d178f4c8d47bbb8d5f653c0ee6077","max":4257,"min":0,"orientation":"horizontal","style":"IPY_MODEL_2fb6cf1d29ac4cfb87cfd29343b36025","value":4257}},"d3572729408f4cf283b8ea11bfa1dfaa":{"model_module":"@jupyter-widgets/controls","model_module_version":"1.5.0","model_name":"HTMLModel","state":{"_dom_classes":[],"_model_module":"@jupyter-widgets/controls","_model_module_version":"1.5.0","_model_name":"HTMLModel","_view_count":null,"_view_module":"@jupyter-widgets/controls","_view_module_version":"1.5.0","_view_name":"HTMLView","description":"","description_tooltip":null,"layout":"IPY_MODEL_d6345a61667d454db2f764253ccdfd7e","placeholder":"​","style":"IPY_MODEL_bfc76c2fb92d4959b21a55121efc1f7a","value":" 635/635 [00:00&lt;00:00, 43.5kB/s]"}},"d4985e9da642420d84ad31fcf1e12de5":{"model_module":"@jupyter-widgets/base","model_module_version":"1.2.0","model_name":"LayoutModel","state":{"_model_module":"@jupyter-widgets/base","_model_module_version":"1.2.0","_model_name":"LayoutModel","_view_count":null,"_view_module":"@jupyter-widgets/base","_view_module_version":"1.2.0","_view_name":"LayoutView","align_content":null,"align_items":"center","align_self":null,"border":null,"bottom":null,"display":"flex","flex":null,"flex_flow":"column","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,"overflow_x":null,"overflow_y":null,"padding":null,"right":null,"top":null,"visibility":null,"width":"50%"}},"d5219deca99c438fb9d440b1c701597c":{"model_module":"@jupyter-widgets/base","model_module_version":"1.2.0","model_name":"LayoutModel","state":{"_model_module":"@jupyter-widgets/base","_model_module_version":"1.2.0","_model_name":"LayoutModel","_view_count":null,"_view_module":"@jupyter-widgets/base","_view_module_version":"1.2.0","_view_name":"LayoutView","align_content":null,"align_items":null,"align_self":null,"border":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,"overflow_x":null,"overflow_y":null,"padding":null,"right":null,"top":null,"visibility":null,"width":null}},"d6345a61667d454db2f764253ccdfd7e":{"model_module":"@jupyter-widgets/base","model_module_version":"1.2.0","model_name":"LayoutModel","state":{"_model_module":"@jupyter-widgets/base","_model_module_version":"1.2.0","_model_name":"LayoutModel","_view_count":null,"_view_module":"@jupyter-widgets/base","_view_module_version":"1.2.0","_view_name":"LayoutView","align_content":null,"align_items":null,"align_self":null,"border":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,"overflow_x":null,"overflow_y":null,"padding":null,"right":null,"top":null,"visibility":null,"width":null}},"d65788532d294420812f5b02fb076c1f":{"model_module":"@jupyter-widgets/controls","model_module_version":"1.5.0","model_name":"DescriptionStyleModel","state":{"_model_module":"@jupyter-widgets/controls","_model_module_version":"1.5.0","_model_name":"DescriptionStyleModel","_view_count":null,"_view_module":"@jupyter-widgets/base","_view_module_version":"1.2.0","_view_name":"StyleView","description_width":""}},"d6ad45ae8306476b868cde1e49f5f42c":{"model_module":"@jupyter-widgets/controls","model_module_version":"1.5.0","model_name":"HTMLModel","state":{"_dom_classes":[],"_model_module":"@jupyter-widgets/controls","_model_module_version":"1.5.0","_model_name":"HTMLModel","_view_count":null,"_view_module":"@jupyter-widgets/controls","_view_module_version":"1.5.0","_view_name":"HTMLView","description":"","description_tooltip":null,"layout":"IPY_MODEL_a1d299215b7c4e6a8be05a6ad6d3ebb9","placeholder":"​","style":"IPY_MODEL_31524db81ee240fd830c437d95e48c23","value":" 538/538 [00:00&lt;00:00, 13.1kB/s]"}},"d9527593775745afac48a438cd11c7e0":{"model_module":"@jupyter-widgets/base","model_module_version":"1.2.0","model_name":"LayoutModel","state":{"_model_module":"@jupyter-widgets/base","_model_module_version":"1.2.0","_model_name":"LayoutModel","_view_count":null,"_view_module":"@jupyter-widgets/base","_view_module_version":"1.2.0","_view_name":"LayoutView","align_content":null,"align_items":null,"align_self":null,"border":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,"overflow_x":null,"overflow_y":null,"padding":null,"right":null,"top":null,"visibility":null,"width":null}},"e009f2ee46fc4326bc4020cafff7f941":{"model_module":"@jupyter-widgets/controls","model_module_version":"1.5.0","model_name":"DescriptionStyleModel","state":{"_model_module":"@jupyter-widgets/controls","_model_module_version":"1.5.0","_model_name":"DescriptionStyleModel","_view_count":null,"_view_module":"@jupyter-widgets/base","_view_module_version":"1.2.0","_view_name":"StyleView","description_width":""}},"e1905b6d2665450b8c89f05a582b299f":{"model_module":"@jupyter-widgets/controls","model_module_version":"1.5.0","model_name":"HTMLModel","state":{"_dom_classes":[],"_model_module":"@jupyter-widgets/controls","_model_module_version":"1.5.0","_model_name":"HTMLModel","_view_count":null,"_view_module":"@jupyter-widgets/controls","_view_module_version":"1.5.0","_view_name":"HTMLView","description":"","description_tooltip":null,"layout":"IPY_MODEL_c19fca2497d24cfeb7ddf74d9d94a621","placeholder":"​","style":"IPY_MODEL_68bdd452bed845cfb88d652bb443604a","value":" 380/380 [02:48&lt;00:00,  2.34it/s]"}},"e1e88192495a4f68b2c88b66b07cdd12":{"model_module":"@jupyter-widgets/controls","model_module_version":"1.5.0","model_name":"HTMLModel","state":{"_dom_classes":[],"_model_module":"@jupyter-widgets/controls","_model_module_version":"1.5.0","_model_name":"HTMLModel","_view_count":null,"_view_module":"@jupyter-widgets/controls","_view_module_version":"1.5.0","_view_name":"HTMLView","description":"","description_tooltip":null,"layout":"IPY_MODEL_d9527593775745afac48a438cd11c7e0","placeholder":"​","style":"IPY_MODEL_6099fc437b9543048bc925bc9e13f818","value":" 30%"}},"e8f73e63bf8a4822af43c33ead93649b":{"model_module":"@jupyter-widgets/controls","model_module_version":"1.5.0","model_name":"FloatProgressModel","state":{"_dom_classes":[],"_model_module":"@jupyter-widgets/controls","_model_module_version":"1.5.0","_model_name":"FloatProgressModel","_view_count":null,"_view_module":"@jupyter-widgets/controls","_view_module_version":"1.5.0","_view_name":"ProgressView","bar_style":"success","description":"","description_tooltip":null,"layout":"IPY_MODEL_87b417f7a835472285fcb95c0b127b70","max":380,"min":0,"orientation":"horizontal","style":"IPY_MODEL_b739f86a36064c3c96626f1276359ae2","value":380}},"e9bbce38a51f44069e2b828239441899":{"model_module":"@jupyter-widgets/controls","model_module_version":"1.5.0","model_name":"FloatProgressModel","state":{"_dom_classes":[],"_model_module":"@jupyter-widgets/controls","_model_module_version":"1.5.0","_model_name":"FloatProgressModel","_view_count":null,"_view_module":"@jupyter-widgets/controls","_view_module_version":"1.5.0","_view_name":"ProgressView","bar_style":"success","description":"","description_tooltip":null,"layout":"IPY_MODEL_340329f664a547cd81cf8ba256aaf482","max":852,"min":0,"orientation":"horizontal","style":"IPY_MODEL_018a325d68c5472593552fe66703b616","value":852}},"eac91c8db5a54e8cb434be22f6942dbf":{"model_module":"@jupyter-widgets/base","model_module_version":"1.2.0","model_name":"LayoutModel","state":{"_model_module":"@jupyter-widgets/base","_model_module_version":"1.2.0","_model_name":"LayoutModel","_view_count":null,"_view_module":"@jupyter-widgets/base","_view_module_version":"1.2.0","_view_name":"LayoutView","align_content":null,"align_items":null,"align_self":null,"border":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,"overflow_x":null,"overflow_y":null,"padding":null,"right":null,"top":null,"visibility":null,"width":null}},"ebf48db6bf844516a8a1e335c11f3db3":{"model_module":"@jupyter-widgets/controls","model_module_version":"1.5.0","model_name":"DescriptionStyleModel","state":{"_model_module":"@jupyter-widgets/controls","_model_module_version":"1.5.0","_model_name":"DescriptionStyleModel","_view_count":null,"_view_module":"@jupyter-widgets/base","_view_module_version":"1.2.0","_view_name":"StyleView","description_width":""}},"ec68acd0ebde42e4be05d8896533e153":{"model_module":"@jupyter-widgets/controls","model_module_version":"1.5.0","model_name":"HBoxModel","state":{"_dom_classes":[],"_model_module":"@jupyter-widgets/controls","_model_module_version":"1.5.0","_model_name":"HBoxModel","_view_count":null,"_view_module":"@jupyter-widgets/controls","_view_module_version":"1.5.0","_view_name":"HBoxView","box_style":"","children":["IPY_MODEL_9dad9cbd81d24086bc0cef4ed42e07b3","IPY_MODEL_8df418c659084100b76130ce6dde86e7","IPY_MODEL_488221d4f67c43f49a263e6bc20c6a55"],"layout":"IPY_MODEL_46ef40bd54e743038a2616fe314befce"}},"ee3e3bb6219a49aabb6bf5350783bb4f":{"model_module":"@jupyter-widgets/controls","model_module_version":"1.5.0","model_name":"HTMLModel","state":{"_dom_classes":[],"_model_module":"@jupyter-widgets/controls","_model_module_version":"1.5.0","_model_name":"HTMLModel","_view_count":null,"_view_module":"@jupyter-widgets/controls","_view_module_version":"1.5.0","_view_name":"HTMLView","description":"","description_tooltip":null,"layout":"IPY_MODEL_8991f225eb754b11a1b056a55fc2da84","placeholder":"​","style":"IPY_MODEL_bce506b6be854ed5ad405ce29bbed051","value":" 30%"}},"f197268b4a7b49a28c0150d97ae00c2c":{"model_module":"@jupyter-widgets/base","model_module_version":"1.2.0","model_name":"LayoutModel","state":{"_model_module":"@jupyter-widgets/base","_model_module_version":"1.2.0","_model_name":"LayoutModel","_view_count":null,"_view_module":"@jupyter-widgets/base","_view_module_version":"1.2.0","_view_name":"LayoutView","align_content":null,"align_items":null,"align_self":null,"border":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,"overflow_x":null,"overflow_y":null,"padding":null,"right":null,"top":null,"visibility":null,"width":null}},"f357cad809ab4bfe88fad92b97f92fd2":{"model_module":"@jupyter-widgets/base","model_module_version":"1.2.0","model_name":"LayoutModel","state":{"_model_module":"@jupyter-widgets/base","_model_module_version":"1.2.0","_model_name":"LayoutModel","_view_count":null,"_view_module":"@jupyter-widgets/base","_view_module_version":"1.2.0","_view_name":"LayoutView","align_content":null,"align_items":null,"align_self":null,"border":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,"overflow_x":null,"overflow_y":null,"padding":null,"right":null,"top":null,"visibility":null,"width":null}},"f9744ee7542849d09eca2199042bf828":{"model_module":"@jupyter-widgets/controls","model_module_version":"1.5.0","model_name":"DescriptionStyleModel","state":{"_model_module":"@jupyter-widgets/controls","_model_module_version":"1.5.0","_model_name":"DescriptionStyleModel","_view_count":null,"_view_module":"@jupyter-widgets/base","_view_module_version":"1.2.0","_view_name":"StyleView","description_width":""}},"fd91de21f1b64f71aeb6950d1968e152":{"model_module":"@jupyter-widgets/controls","model_module_version":"1.5.0","model_name":"DescriptionStyleModel","state":{"_model_module":"@jupyter-widgets/controls","_model_module_version":"1.5.0","_model_name":"DescriptionStyleModel","_view_count":null,"_view_module":"@jupyter-widgets/base","_view_module_version":"1.2.0","_view_name":"StyleView","description_width":""}},"fde783dc2fcc4cf5848a8d6fd9f2060b":{"model_module":"@jupyter-widgets/controls","model_module_version":"1.5.0","model_name":"HTMLModel","state":{"_dom_classes":[],"_model_module":"@jupyter-widgets/controls","_model_module_version":"1.5.0","_model_name":"HTMLModel","_view_count":null,"_view_module":"@jupyter-widgets/controls","_view_module_version":"1.5.0","_view_name":"HTMLView","description":"","description_tooltip":null,"layout":"IPY_MODEL_1a34009b9bcc43508a74d4ca9adee005","placeholder":"​","style":"IPY_MODEL_54bf5459287444c6916357602ff3f36a","value":"model.safetensors: 100%"}}}},"kaggle":{"accelerator":"nvidiaTeslaT4","dataSources":[{"sourceId":86142,"databundleVersionId":9786425,"sourceType":"competition"},{"sourceId":9587671,"sourceType":"datasetVersion","datasetId":5847105}],"dockerImageVersionId":30787,"isInternetEnabled":true,"language":"python","sourceType":"notebook","isGpuEnabled":true}},"nbformat_minor":4,"nbformat":4,"cells":[{"cell_type":"markdown","source":"# **Getting strted**\ngetting labels and thier data","metadata":{}},{"cell_type":"code","source":"import cv2\nimport numpy as np\nimport pandas as pd\nimport json\nimport os\n\n\nclass Label:\n    def __init__(self, name, id, csId, csTrainId, level4id, level3Id, category, level2Id, level1Id, hasInstances, ignoreInEval, color):\n        self.name = name\n        self.id = id\n        self.csId = csId\n        self.csTrainId = csTrainId\n        self.level4id = level4id\n        self.level3Id = level3Id\n        self.category = category\n        self.level2Id = level2Id\n        self.level1Id = level1Id\n        self.hasInstances = hasInstances\n        self.ignoreInEval = ignoreInEval\n        self.color = color\n\n# Your label definitions here (from your provided list)\n\nlabels_details = [\n    #       name                     id    csId     csTrainId level4id        level3Id  category           level2Id      level1Id  hasInstances   ignoreInEval   color\n    Label(  'road'                 ,  0   ,  7 ,     0 ,       0   ,     0  ,   'drivable'            , 0           , 0      , False        , False        , (128, 64,128)  ),\n    Label(  'parking'              ,  1   ,  9 ,   255 ,       1   ,     1  ,   'drivable'            , 1           , 0      , False        , False         , (250,170,160)  ),\n    Label(  'drivable fallback'    ,  2   ,  255 ,   255 ,     2   ,       1  ,   'drivable'            , 1           , 0      , False        , False         , ( 81,  0, 81)  ),\n    Label(  'sidewalk'             ,  3   ,  8 ,     1 ,       3   ,     2  ,   'non-drivable'        , 2           , 1      , False        , False        , (244, 35,232)  ),\n    Label(  'rail track'           ,  4   , 10 ,   255 ,       3   ,     3  ,   'non-drivable'        , 3           , 1      , False        , False         , (230,150,140)  ),\n    Label(  'non-drivable fallback',  5   , 255 ,     9 ,      4   ,      3  ,   'non-drivable'        , 3           , 1      , False        , False        , (152,251,152)  ),\n    Label(  'person'               ,  6   , 24 ,    11 ,       5   ,     4  ,   'living-thing'        , 4           , 2      , True         , False        , (220, 20, 60)  ),\n    Label(  'animal'               ,  7   , 255 ,   255 ,      6   ,      4  ,   'living-thing'        , 4           , 2      , True         , True        , (246, 198, 145)),\n    Label(  'rider'                ,  8   , 25 ,    12 ,       7   ,     5  ,   'living-thing'        , 5           , 2      , True         , False        , (255,  0,  0)  ),\n    Label(  'motorcycle'           ,  9   , 32 ,    17 ,       8   ,     6  ,   '2-wheeler'           , 6           , 3      , True         , False        , (  0,  0,230)  ),\n    Label(  'bicycle'              , 10   , 33 ,    18 ,       9   ,     7  ,   '2-wheeler'           , 6           , 3      , True         , False        , (119, 11, 32)  ),\n    Label(  'autorickshaw'         , 11   , 255 ,   255 ,     10   ,      8  ,   'autorickshaw'        , 7           , 3      , True         , False        , (255, 204, 54) ),\n    Label(  'car'                  , 12   , 26 ,    13 ,      11   ,     9  ,   'car'                 , 7           , 3      , True         , False        , (  0,  0,142)  ),\n    Label(  'truck'                , 13   , 27 ,    14 ,      12   ,     10 ,   'large-vehicle'       , 8           , 3      , True         , False        , (  0,  0, 70)  ),\n    Label(  'bus'                  , 14   , 28 ,    15 ,      13   ,     11 ,   'large-vehicle'       , 8           , 3      , True         , False        , (  0, 60,100)  ),\n    Label(  'caravan'              , 15   , 29 ,   255 ,      14   ,     12 ,   'large-vehicle'       , 8           , 3      , True         , True         , (  0,  0, 90)  ),\n    Label(  'trailer'              , 16   , 30 ,   255 ,      15   ,     12 ,   'large-vehicle'       , 8           , 3      , True         , True         , (  0,  0,110)  ),\n    Label(  'train'                , 17   , 31 ,    16 ,      15   ,     12 ,   'large-vehicle'       , 8           , 3      , True         , True        , (  0, 80,100)  ),\n    Label(  'vehicle fallback'     , 18   , 355 ,   255 ,     15   ,      12 ,   'large-vehicle'       , 8           , 3      , True         , False        , (136, 143, 153)),\n    Label(  'curb'                 , 19   ,255 ,   255 ,      16   ,     13 ,   'barrier'             , 9           , 4      , False        , False        , (220, 190, 40)),\n    Label(  'wall'                 , 20   , 12 ,     3 ,      17   ,     14 ,   'barrier'             , 9           , 4      , False        , False        , (102,102,156)  ),\n    Label(  'fence'                , 21   , 13 ,     4 ,      18   ,     15 ,   'barrier'             , 10           , 4      , False        , False        , (190,153,153)  ),\n    Label(  'guard rail'           , 22   , 14 ,   255 ,      19   ,     16 ,   'barrier'             , 10          , 4      , False        , False         , (180,165,180)  ),\n    Label(  'billboard'            , 23   , 255 ,   255 ,     20   ,      17 ,   'structures'          , 11           , 4      , False        , False        , (174, 64, 67) ),\n    Label(  'traffic sign'         , 24   , 20 ,     7 ,      21   ,     18 ,   'structures'          , 11          , 4      , False        , False        , (220,220,  0)  ),\n    Label(  'traffic light'        , 25   , 19 ,     6 ,      22   ,     19 ,   'structures'          , 11          , 4      , False        , False        , (250,170, 30)  ),\n    Label(  'pole'                 , 26   , 17 ,     5 ,      23   ,     20 ,   'structures'          , 12          , 4      , False        , False        , (153,153,153)  ),\n    Label(  'polegroup'            , 27   , 18 ,   255 ,      23   ,     20 ,   'structures'          , 12          , 4      , False        , False         , (153,153,153)  ),\n    Label(  'obs-str-bar-fallback' , 28   , 255 ,   255 ,     24   ,      21 ,   'structures'          , 12          , 4      , False        , False        , (169, 187, 214) ),\n    Label(  'building'             , 29   , 11 ,     2 ,      25   ,     22 ,   'construction'        , 13          , 5      , False        , False        , ( 70, 70, 70)  ),\n    Label(  'bridge'               , 30   , 15 ,   255 ,      26   ,     23 ,   'construction'        , 13          , 5      , False        , False         , (150,100,100)  ),\n    Label(  'tunnel'               , 31   , 16 ,   255 ,      26   ,     23 ,   'construction'        , 13          , 5      , False        , False         , (150,120, 90)  ),\n    Label(  'vegetation'           , 32   , 21 ,     8 ,      27   ,     24 ,   'vegetation'          , 14          , 5      , False        , False        , (107,142, 35)  ),\n    Label(  'sky'                  , 33   , 23 ,    10 ,      28   ,     25 ,   'sky'                 , 15          , 6      , False        , False        , ( 70,130,180)  ),\n    Label(  'fallback background'  , 34   , 255 ,   255 ,     29   ,      25 ,   'object fallback'     , 15          , 6      , False        , False        , (169, 187, 214)),\n    Label(  'unlabeled'            , 35   ,  0  ,     255 ,   255   ,      255 ,   'void'                , 255         , 255    , False        , True         , (  0,  0,  0)  ),\n    Label(  'ego vehicle'          , 36   ,  1  ,     255 ,   255   ,      255 ,   'void'                , 255         , 255    , False        , True         , (  0,  0,  0)  ),\n    Label(  'rectification border' , 37   ,  2  ,     255 ,   255   ,      255 ,   'void'                , 255         , 255    , False        , True         , (  0,  0,  0)  ),\n    Label(  'out of roi'           , 38   ,  3  ,     255 ,   255   ,      255 ,   'void'                , 255         , 255    , False        , True         , (  0,  0,  0)  ),\n    Label(  'license plate'        , 39   , 255 ,     255 ,   255   ,      255 ,   'vehicle'             , 255         , 255    , False        , True         , (  0,  0,142)  ),\n\n]\n\n\n\n# Function to get label information from pixel color\ndef get_label_by_color(color):\n    for label in labels_details:\n        if label.color == tuple(color):  # Compare the pixel color to the label color\n            return label\n    return None\n\nimport torch\nimport numpy as np\n\n# Step 1: Build a dictionary to map color tuples to label IDs\ncolor_to_id_map = {tuple(label.color): label.id for label in labels_details}\nid_to_label_map = {int(label.id): label.name for label in labels_details}\ndef id_to_label_map():\n    new_dict = {}\n    for label in labels_details:\n        new_dict[int(label.id)] = label.name\n    return new_dict","metadata":{"id":"mxRgRfimOYQ1","execution":{"iopub.status.busy":"2024-10-12T15:04:34.257509Z","iopub.execute_input":"2024-10-12T15:04:34.258059Z","iopub.status.idle":"2024-10-12T15:04:39.737867Z","shell.execute_reply.started":"2024-10-12T15:04:34.258007Z","shell.execute_reply":"2024-10-12T15:04:39.737105Z"},"trusted":true},"outputs":[],"execution_count":null},{"cell_type":"code","source":"import os\nimport json\n\nlabels = [label.name for label in labels_details]\nlabel_dict = {}\nlabel_dict = label_dict.fromkeys(labels, 0)\nlabel_dict['ground'] = 0\nbase_dir = '/kaggle/input/iitg-ai-overnight-hackathon-2024/dataset/dataset/labels' \nfor sub_dir in os.listdir(base_dir):\n    sub_dir_path = os.path.join(base_dir, sub_dir)\n\n    for json_file in os.listdir(sub_dir_path):\n        if json_file.endswith('_polygons.json'):\n            json_path = os.path.join(sub_dir_path, json_file)\n            with open(json_path, 'r') as f:\n                data = json.load(f)\n                unique_label = set()\n                for obj in data.get('objects', []):\n                    unique_label.add(obj.get('label'))\n                for s in unique_label:\n                    label_dict[s] += 1","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-10-12T11:50:01.00641Z","iopub.execute_input":"2024-10-12T11:50:01.007366Z","iopub.status.idle":"2024-10-12T11:51:01.581813Z","shell.execute_reply.started":"2024-10-12T11:50:01.007318Z","shell.execute_reply":"2024-10-12T11:51:01.580771Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"import operator\nsorted_label_dict = dict(sorted(label_dict.items(),key = operator.itemgetter(1)))\nsorted_label_dict","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-10-12T11:51:01.583491Z","iopub.execute_input":"2024-10-12T11:51:01.583837Z","iopub.status.idle":"2024-10-12T11:51:01.59237Z","shell.execute_reply.started":"2024-10-12T11:51:01.583803Z","shell.execute_reply":"2024-10-12T11:51:01.591127Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"lfreq_label_dict = []\nfor i in sorted_label_dict.items():\n    if i[1] < 100 and i[1] > 4:\n        lfreq_label_dict.append(i[0])","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-10-12T11:51:01.594061Z","iopub.execute_input":"2024-10-12T11:51:01.594551Z","iopub.status.idle":"2024-10-12T11:51:01.603022Z","shell.execute_reply.started":"2024-10-12T11:51:01.594505Z","shell.execute_reply":"2024-10-12T11:51:01.601922Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"for k, v in enumerate(lfreq_label_dict):\n    print(k, \" \", v)","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-10-12T11:51:01.604853Z","iopub.execute_input":"2024-10-12T11:51:01.605253Z","iopub.status.idle":"2024-10-12T11:51:01.615527Z","shell.execute_reply.started":"2024-10-12T11:51:01.605192Z","shell.execute_reply":"2024-10-12T11:51:01.614295Z"}},"outputs":[],"execution_count":null},{"cell_type":"markdown","source":"## Selecting Key Images for Fine-Tuning:\n\nThe selection process begins by analyzing each directory to extract key features like the total number of unique images, the occurrence of rare classes, and the overall image count. For each directory:\n\n**Unique Image Count:** We first compute the total number of distinct images, ensuring no duplicates are considered.\n**Rare Class Representation:** We identify the rare classes present in the images. A rare class is defined based on its infrequent occurrence across the dataset. For each image, we parse the corresponding JSON files to extract class labels and flag those that belong to the underrepresented categories.\n**Total Image Count:** We then calculate the total number of images in each directory.\nNext, we assign weights to each of these metrics to capture their importance in the final selection:\n\n***α (Weight for unique images):*** This factor gives importance to directories containing a higher diversity of images.\n***β (Weight for rare class representation):*** This factor emphasizes directories that contribute rare class instances.\n***γ (Weight for image count):*** This accounts for the overall size of the directory in terms of the number of images.\nAfter normalizing these weighted values (so each metric contributes comparably), a composite score is calculated for each directory. The formula used to compute the final score for each directory \n𝐷\nD is:\n\n***Score\n𝐷\n=\n𝛼\n⋅\nnorm\n(\nunique images\n)\n+\n𝛽\n⋅\nnorm\n(\nrare classes\n)\n+\n𝛾\n⋅\nnorm\n(\ntotal images\n)***\nFinally, directories are ranked based on their scores, and the top \n𝑁\nN directories with the highest scores are selected for fine-tuning the model. This ensures the sampled subset has a richer class representation and a balanced distribution of rare and frequent classes. ","metadata":{}},{"cell_type":"code","source":"import os\nimport json\n\n# Define rare classes\nrare_classes = ['tunnel','trailer', 'train', 'rectification border', 'rail track', 'parking']\n\n# Store the scores for each subdirectory\nsubdir_scores = {}\nbase_path = '/kaggle/input/iitg-ai-overnight-hackathon-2024/dataset/dataset/labels'\n# Iterate over all subdirectories (e.g., 201, 202...)\nfor subdir in os.listdir(base_path):\n    class_count = {}\n    rare_class_count = 0\n    image_count = 0\n\n    # Get all JSON files (assuming the format is like frame{id}_polygons.json)\n    json_files = [f for f in os.listdir(os.path.join(base_path, subdir)) if f.endswith('_polygons.json')]\n\n    for json_file in json_files:\n        image_count += 1  # Increment image count\n        with open(os.path.join(os.path.join(base_path, subdir), json_file), 'r') as file:\n            data = json.load(file)\n            for obj in data['objects']:\n                label = obj['label']\n                # Count class occurrences\n                if label in class_count:\n                    class_count[label] += 1\n                else:\n                    class_count[label] = 1\n\n                # Count rare class occurrences\n                if label in rare_classes:\n                    rare_class_count += 1\n\n    # Calculate the class diversity score\n    class_diversity_score = len(class_count)  # Number of unique classes\n\n    # Store the subdirectory scores\n    subdir_scores[subdir] = {\n        'class_diversity_score': class_diversity_score,\n        'rare_class_score': rare_class_count,\n        'image_count': image_count\n    }\n\n# Normalize the scores and calculate the weighted score\nmax_class_diversity = max([v['class_diversity_score'] for v in subdir_scores.values()])\nmax_rare_class = max([v['rare_class_score'] for v in subdir_scores.values()])\nmax_image_count = max([v['image_count'] for v in subdir_scores.values()])\n\nα, β, γ = 0.4, 0.45, 0.15  # Example weights\n\nfor subdir, scores in subdir_scores.items():\n    weighted_score = (\n        α * (scores['class_diversity_score'] / max_class_diversity) +\n        β * (scores['rare_class_score'] / max_rare_class) +\n        γ * (scores['image_count'] / max_image_count)\n    )\n    subdir_scores[subdir]['weighted_score'] = weighted_score\n\n# Sort the subdirectories based on weighted score\nranked_subdirs = sorted(subdir_scores.items(), key=lambda x: x[1]['weighted_score'], reverse=True)\n\n# Select top N subdirectories for dataset creation\n# top_subdirs = [subdir for subdir, scores in ranked_subdirs[:N]]  # N is the number of subdirs to sample","metadata":{"execution":{"iopub.status.busy":"2024-10-09T14:09:01.175032Z","iopub.execute_input":"2024-10-09T14:09:01.175428Z","iopub.status.idle":"2024-10-09T14:10:40.439264Z","shell.execute_reply.started":"2024-10-09T14:09:01.175392Z","shell.execute_reply":"2024-10-09T14:10:40.43848Z"},"trusted":true},"outputs":[],"execution_count":null},{"cell_type":"code","source":"needed_count = 0\nfor i, (k, v) in enumerate(ranked_subdirs):\n    print(k, v['weighted_score'], v['image_count'])\n    needed_count += v['image_count']\n    print(i+1, \" \", needed_count)","metadata":{"id":"1_38lyAyOfJa","trusted":true},"outputs":[],"execution_count":null},{"cell_type":"code","source":"N = 9\ntop_subdirs = [subdir for subdir, scores in ranked_subdirs[:N]]\ntop_subdirs","metadata":{"execution":{"iopub.status.busy":"2024-10-09T14:14:05.745225Z","iopub.execute_input":"2024-10-09T14:14:05.745604Z","iopub.status.idle":"2024-10-09T14:14:05.752257Z","shell.execute_reply.started":"2024-10-09T14:14:05.745562Z","shell.execute_reply":"2024-10-09T14:14:05.751338Z"},"trusted":true},"outputs":[],"execution_count":null},{"cell_type":"code","source":"color_to_id = {tuple(label.color) : label.id for label in labels_details}\ndef convert(seg_map):\n    # Convert the segmentation map image to a numpy array of shape (H, W, 3) where each pixel has RGB values\n    seg_map_array = np.array(seg_map.convert('RGB').resize((512,512)))\n\n    # Create an empty H * W array to store the pixel-wise label values (id values)\n    id_array = np.zeros((seg_map_array.shape[0], seg_map_array.shape[1]), dtype=np.int32)\n\n    # Iterate over each pixel in the segmentation map\n    for i in range(seg_map_array.shape[0]):\n        for j in range(seg_map_array.shape[1]):\n            pixel_color = tuple(seg_map_array[i, j])\n            # Lookup the corresponding id for the pixel's color\n            id_array[i, j] = color_to_id.get(pixel_color, -1)  # Default to -1 if the color is not found\n\n    return id_array\n\ndef get_identifier(filename):\n    parts = filename.split('_')\n    if 'frame' in parts[0]:\n        return parts[0].replace('frame', '')  # Get ID after 'frame'\n    else:\n        return parts[0]  # Get numeric part in filename","metadata":{"execution":{"iopub.status.busy":"2024-10-09T14:11:22.735146Z","iopub.execute_input":"2024-10-09T14:11:22.735503Z","iopub.status.idle":"2024-10-09T14:11:22.743794Z","shell.execute_reply.started":"2024-10-09T14:11:22.735472Z","shell.execute_reply":"2024-10-09T14:11:22.742845Z"},"trusted":true},"outputs":[],"execution_count":null},{"cell_type":"code","source":"import PIL.Image as Image\nimg = Image.open('/kaggle/input/iitg-ai-overnight-hackathon-2024/dataset/dataset/labels/201/frame0029_gtFine_labelColors.png')\n(np.array(img).shape)","metadata":{"execution":{"iopub.status.busy":"2024-10-10T16:45:41.979999Z","iopub.execute_input":"2024-10-10T16:45:41.980773Z","iopub.status.idle":"2024-10-10T16:45:42.040769Z","shell.execute_reply.started":"2024-10-10T16:45:41.980728Z","shell.execute_reply":"2024-10-10T16:45:42.039712Z"},"trusted":true},"outputs":[],"execution_count":null},{"cell_type":"code","source":"import matplotlib.pyplot as plt\nplt.imshow(np.array(img))","metadata":{"execution":{"iopub.status.busy":"2024-10-09T14:12:36.756319Z","iopub.execute_input":"2024-10-09T14:12:36.757002Z","iopub.status.idle":"2024-10-09T14:12:37.065546Z","shell.execute_reply.started":"2024-10-09T14:12:36.756948Z","shell.execute_reply":"2024-10-09T14:12:37.064696Z"},"trusted":true},"outputs":[],"execution_count":null},{"cell_type":"code","source":"import os\nimport torch\nfrom PIL import Image\nimport numpy as np\nfrom tqdm import tqdm\nfrom multiprocessing import Process, Queue\n# Base directory path\nbase_dir = '/kaggle/input/iitg-ai-overnight-hackathon-2024/dataset/dataset'\ntrain_dir = os.path.join(base_dir, 'train')\nlabels_dir = os.path.join(base_dir, 'labels')\n# Array to store the dataset\ndata_set = []\n\ntop_subdirs.insert(0, \"296\")\n# Get the list of subdirectories\nsubdirs = [dirname for dirname in top_subdirs]\n\n# Process images sequentially\nfor dirname in tqdm(subdirs, desc=\"Processing directories\"):\n    train_subdir = os.path.join(train_dir, dirname)\n    labels_subdir = os.path.join(labels_dir, dirname)\n\n    if os.path.isdir(train_subdir) and os.path.isdir(labels_subdir):\n        # Get the list of train images and label images\n        train_images = [f for f in os.listdir(train_subdir) if f.endswith('.jpg')]\n        label_images = [f for f in os.listdir(labels_subdir) if f.endswith('labelColors.png')]\n\n        # Match train and label images based on the {ID}\n        for label_image in label_images:\n            identifier = get_identifier(label_image)  # Extract {ID} from label filename\n\n            # Find the matching train image\n            matched_train_image = next((img for img in train_images if identifier in img), None)\n\n            if matched_train_image:\n                # Process the image pair sequentially\n                pixel_image_path = os.path.join(train_subdir, matched_train_image)\n                label_image_path = os.path.join(labels_subdir, label_image)\n\n                pixel_image = Image.open(pixel_image_path).resize((512,512))  # Train image\n                label_image_tensor = convert(Image.open(label_image_path))   # Label image transformed to label IDs\n\n                data_set.append({\n                    'pixel_values': pixel_image,  # Train image as PIL Image\n                    'label': label_image_tensor  # Label image as torch tensor on GPU (if available)\n                })\n\n# Example to show the contents of data_set\nfor idx, data in enumerate(data_set[:3]):  # Show first 3 entries\n    print(f\"Index {idx}:\")\n    print(f\"Pixels Image: {data['pixel_values']}\")\n    # print(f\"Labels Image (Tensor on {device}): {data['label']}\")  # Labels are stored as tensors on GPU if available\n\n\nimport pickle\n# Save the data_set using pickle\nsave_path = '/kaggle/working/data_s.pkl'\n\nwith open(save_path, 'wb') as file:\n    pickle.dump(data_set, file)\n\nprint(f'data_set saved to {save_path}')","metadata":{"execution":{"iopub.status.busy":"2024-10-09T14:14:11.977286Z","iopub.execute_input":"2024-10-09T14:14:11.978008Z","iopub.status.idle":"2024-10-09T15:10:29.227579Z","shell.execute_reply.started":"2024-10-09T14:14:11.977948Z","shell.execute_reply":"2024-10-09T15:10:29.226516Z"},"trusted":true},"outputs":[],"execution_count":null},{"cell_type":"code","source":"import pickle\n\n# Path to your .pkl file\npkl_file_path = '/kaggle/input/iitg-ai-sample-dataset/data_s.pkl'\n\n# Open and load the .pkl file\nwith open(pkl_file_path, 'rb') as f:\n    data_set = pickle.load(f)\n\n","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-10-12T15:04:41.438726Z","iopub.execute_input":"2024-10-12T15:04:41.439477Z","iopub.status.idle":"2024-10-12T15:05:00.461045Z","shell.execute_reply.started":"2024-10-12T15:04:41.439434Z","shell.execute_reply":"2024-10-12T15:05:00.4602Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"type(data_set[0]['label'])","metadata":{"execution":{"iopub.status.busy":"2024-10-12T15:05:00.462732Z","iopub.execute_input":"2024-10-12T15:05:00.463052Z","iopub.status.idle":"2024-10-12T15:05:00.470146Z","shell.execute_reply.started":"2024-10-12T15:05:00.463016Z","shell.execute_reply":"2024-10-12T15:05:00.469209Z"},"trusted":true},"outputs":[],"execution_count":null},{"cell_type":"code","source":"import numpy as np\nfor idx, _ in enumerate(data_set):\n    data_set[idx]['label'] = torch.tensor(data_set[idx]['label'])\n    data_set[idx]['label'] = [torch.where(label == -1, torch.tensor(35), label) for label in data_set[idx]['label']]\n    data_set[idx]['label'] = np.array(data_set[idx]['label'])","metadata":{"execution":{"iopub.status.busy":"2024-10-12T15:05:00.471304Z","iopub.execute_input":"2024-10-12T15:05:00.471585Z","iopub.status.idle":"2024-10-12T15:05:20.299816Z","shell.execute_reply.started":"2024-10-12T15:05:00.471553Z","shell.execute_reply":"2024-10-12T15:05:20.298899Z"},"trusted":true},"outputs":[],"execution_count":null},{"cell_type":"code","source":"type(data_set[0]['label'])","metadata":{"execution":{"iopub.status.busy":"2024-10-12T15:05:20.301942Z","iopub.execute_input":"2024-10-12T15:05:20.302376Z","iopub.status.idle":"2024-10-12T15:05:20.308597Z","shell.execute_reply.started":"2024-10-12T15:05:20.30233Z","shell.execute_reply":"2024-10-12T15:05:20.307764Z"},"trusted":true},"outputs":[],"execution_count":null},{"cell_type":"markdown","source":"# Vision Transformers : Semantic Segmentation Transfer Learning\n","metadata":{"id":"CFo_LXiD6AgK"}},{"cell_type":"markdown","source":"In this tutorial, we'll explore how to apply transfer learning to a [transformer-based model](https://huggingface.co/facebook/maskformer-swin-base-ade) for semantic segmentation, using the [sidewalk](https://huggingface.co/datasets/segments/sidewalk-semantic) dataset.\n\nit's recommended to run the training on a GPU machine.\n","metadata":{"id":"_Lkk0fpJhWXy"}},{"cell_type":"markdown","source":"_Let's first import the necessary libraries and modules_\n","metadata":{"id":"ZRoDgYr-spFu"}},{"cell_type":"code","source":"!pip install evaluate","metadata":{"id":"6T3Qm3WwRGmJ","outputId":"48b4149a-0045-4a0c-baf6-a9a9fec54618","execution":{"iopub.status.busy":"2024-10-12T15:05:31.78396Z","iopub.execute_input":"2024-10-12T15:05:31.784704Z","iopub.status.idle":"2024-10-12T15:05:45.360055Z","shell.execute_reply.started":"2024-10-12T15:05:31.784662Z","shell.execute_reply":"2024-10-12T15:05:45.35878Z"},"trusted":true},"outputs":[],"execution_count":null},{"cell_type":"code","source":"!pip install datasets","metadata":{"id":"XrLXao0F_WG2","outputId":"b94b50b3-6bae-44e2-87b5-e159ff2e05f8","execution":{"iopub.status.busy":"2024-10-12T15:07:06.664546Z","iopub.execute_input":"2024-10-12T15:07:06.665427Z","iopub.status.idle":"2024-10-12T15:07:18.539314Z","shell.execute_reply.started":"2024-10-12T15:07:06.665385Z","shell.execute_reply":"2024-10-12T15:07:18.538308Z"},"trusted":true},"outputs":[],"execution_count":null},{"cell_type":"code","source":"import json\nimport torch\nimport datasets\nimport requests\nimport evaluate\nimport numpy as np\nimport huggingface_hub\nfrom PIL import Image\nimport albumentations as A\nfrom tqdm.auto import tqdm\nimport matplotlib.pyplot as plt\nfrom typing import Tuple, Any\nfrom dataclasses import dataclass\nfrom datasets import load_dataset\nimport matplotlib.patches as mpatches\nfrom huggingface_hub import hf_hub_download\nfrom torch.utils.data import Dataset, DataLoader\nfrom transformers import (\n    Mask2FormerImageProcessor,\n    AutoImageProcessor,\n    Mask2FormerForUniversalSegmentation,\n)\n\ntorch.manual_seed(29)","metadata":{"id":"x_8ZhjffOwgY","outputId":"2e4944c5-8518-4a83-876f-f8dba9ecb1ab","execution":{"iopub.status.busy":"2024-10-12T15:07:18.541446Z","iopub.execute_input":"2024-10-12T15:07:18.542199Z","iopub.status.idle":"2024-10-12T15:07:18.553942Z","shell.execute_reply.started":"2024-10-12T15:07:18.542148Z","shell.execute_reply":"2024-10-12T15:07:18.553215Z"},"trusted":true},"outputs":[],"execution_count":null},{"cell_type":"code","source":"# it seems that we need to login to huggingface to have access to the dataset segments/sidewalk-semantic\nhuggingface_hub.notebook_login() #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","metadata":{"id":"_IZxlP0rxM4f","outputId":"736367aa-d04e-446b-eb45-a91a4acfd215","execution":{"iopub.status.busy":"2024-10-12T15:07:21.880773Z","iopub.execute_input":"2024-10-12T15:07:21.881156Z","iopub.status.idle":"2024-10-12T15:07:21.904853Z","shell.execute_reply.started":"2024-10-12T15:07:21.881119Z","shell.execute_reply":"2024-10-12T15:07:21.904013Z"},"trusted":true},"outputs":[],"execution_count":null},{"cell_type":"markdown","source":"# Loading and explore the dataset\n\nWe will use a dataset of sidewalk images containing **1000** images with **34** categories of vehicles, sidewalks construction etc..\n\n_Let's load the dataset and split the dataset in a train and test set._\n","metadata":{"id":"uOYqYZ6ws14A"}},{"cell_type":"code","source":"from datasets import Dataset\ndataset = Dataset.from_dict({\"pixel_values\": [item[\"pixel_values\"] for item in data_set],\n                             \"label\": [item[\"label\"] for item in data_set]})","metadata":{"execution":{"iopub.status.busy":"2024-10-12T15:07:30.615157Z","iopub.execute_input":"2024-10-12T15:07:30.615566Z","iopub.status.idle":"2024-10-12T15:10:20.7505Z","shell.execute_reply.started":"2024-10-12T15:07:30.615527Z","shell.execute_reply":"2024-10-12T15:10:20.749599Z"},"trusted":true},"outputs":[],"execution_count":null},{"cell_type":"code","source":"type(dataset)","metadata":{"execution":{"iopub.status.busy":"2024-10-12T15:10:25.396104Z","iopub.execute_input":"2024-10-12T15:10:25.396917Z","iopub.status.idle":"2024-10-12T15:10:25.40324Z","shell.execute_reply.started":"2024-10-12T15:10:25.396873Z","shell.execute_reply":"2024-10-12T15:10:25.402233Z"},"trusted":true},"outputs":[],"execution_count":null},{"cell_type":"code","source":"dataset = dataset.shuffle(seed=1)\ndataset = dataset.train_test_split(test_size=0.1)\ntrain_ds, test_ds = dataset[\"train\"], dataset[\"test\"]\n\ndataset = train_ds.train_test_split(test_size=0.05)\ntrain_ds, val_ds = dataset[\"train\"], dataset[\"test\"]","metadata":{"id":"u2GYIblNQKvs","outputId":"2596d448-be1c-416d-ed8e-878cab9a89a8","execution":{"iopub.status.busy":"2024-10-12T15:10:27.000919Z","iopub.execute_input":"2024-10-12T15:10:27.001318Z","iopub.status.idle":"2024-10-12T15:10:27.039861Z","shell.execute_reply.started":"2024-10-12T15:10:27.001261Z","shell.execute_reply":"2024-10-12T15:10:27.039115Z"},"trusted":true},"outputs":[],"execution_count":null},{"cell_type":"code","source":"train_ds","metadata":{"id":"G_mcEd1-RjA9","outputId":"db4888e9-d0f8-4072-a0b0-4b63e6073999","execution":{"iopub.status.busy":"2024-10-12T15:10:27.386252Z","iopub.execute_input":"2024-10-12T15:10:27.387112Z","iopub.status.idle":"2024-10-12T15:10:27.393118Z","shell.execute_reply.started":"2024-10-12T15:10:27.387073Z","shell.execute_reply":"2024-10-12T15:10:27.392219Z"},"trusted":true},"outputs":[],"execution_count":null},{"cell_type":"code","source":"id2label = id_to_label_map()\nprint(id2label)","metadata":{"id":"20yOq90_QmF9","outputId":"0e414ac6-b97c-47ba-8daa-1f71ab225843","execution":{"iopub.status.busy":"2024-10-12T15:10:27.821118Z","iopub.execute_input":"2024-10-12T15:10:27.821527Z","iopub.status.idle":"2024-10-12T15:10:27.827005Z","shell.execute_reply.started":"2024-10-12T15:10:27.821482Z","shell.execute_reply":"2024-10-12T15:10:27.825948Z"},"trusted":true},"outputs":[],"execution_count":null},{"cell_type":"markdown","source":"As you can see below, the dataset contains two fields: `pixel_values` and `label`.\n\n- `pixel_values` is an RGB image of shape (height, width, 3)\n- `label` is a segmentation map of shape (height, width) that contains the label of each pixel in the image.\n","metadata":{"id":"8bn3zKE64Plv"}},{"cell_type":"code","source":"example = train_ds[0]\nprint(example)\nsegmentation_map = np.array(example[\"label\"])\nimage_array = np.array(example[\"pixel_values\"])\nprint(\n    f\"Shape : Image: {image_array.shape} - Segmentation map: {segmentation_map.shape}\"\n)\n\nprint(segmentation_map)","metadata":{"id":"FtbOb-tr5Nrn","outputId":"60d5306e-cbfb-4b68-e427-5ac8ca0675f6","trusted":true},"outputs":[],"execution_count":null},{"cell_type":"markdown","source":"_Let's now visualize some samples_\n","metadata":{"id":"kPpPl-BB9Ia9"}},{"cell_type":"code","source":"def show_samples(dataset: datasets.Dataset, n: int = 5):\n    \"\"\"\n    Displays 'n' samples from the dataset.\n    ----\n    Args:\n      - dataset: The dataset which should contain 'pixel_values' and 'label' in its items.\n      - n (int): Number of samples to display.\n\n    \"\"\"\n    if n > len(dataset):\n        raise ValueError(\"n is larger than the dataset size\")\n\n    fig, axs = plt.subplots(n, 2, figsize=(10, 5 * n))\n\n    for i in range(n):\n        sample = dataset[i]\n        image, label = np.array(sample[\"pixel_values\"]), sample[\"label\"]\n\n        axs[i, 0].imshow(image)\n        axs[i, 0].set_title(\"Image\")\n        axs[i, 0].axis(\"off\")\n\n        axs[i, 1].imshow(image)\n        axs[i, 1].imshow(label, cmap=\"nipy_spectral\", alpha=1.0)\n        axs[i, 1].set_title(\"Segmentation Map\")\n        axs[i, 1].axis(\"off\")\n\n    plt.tight_layout()\n    plt.show()","metadata":{"id":"qHqdou_i15UE","execution":{"iopub.status.busy":"2024-10-12T15:10:31.111737Z","iopub.execute_input":"2024-10-12T15:10:31.112128Z","iopub.status.idle":"2024-10-12T15:10:31.120772Z","shell.execute_reply.started":"2024-10-12T15:10:31.11209Z","shell.execute_reply":"2024-10-12T15:10:31.119731Z"},"trusted":true},"outputs":[],"execution_count":null},{"cell_type":"code","source":"show_samples(train_ds, n=4)","metadata":{"id":"LXL7X3dD0YRh","outputId":"681f66f5-ed50-419f-d728-d31869758374","execution":{"iopub.status.busy":"2024-10-12T15:10:31.622762Z","iopub.execute_input":"2024-10-12T15:10:31.623138Z","iopub.status.idle":"2024-10-12T15:10:34.187033Z","shell.execute_reply.started":"2024-10-12T15:10:31.623098Z","shell.execute_reply":"2024-10-12T15:10:34.186077Z"},"trusted":true},"outputs":[],"execution_count":null},{"cell_type":"markdown","source":"# Prepare the Dataset for training & Sanity checks\n\nThe model that we will use later in the tutorial expects the input to be in a certain shape and format. To transform our training data, we will use the corresponding Preprocessor available in the `transformers` library.\n\nTo improve the robustness of the model under different rotations, scaling, or lighting conditions, we will apply data augmentations (namely **random croping**, **flipping** and **normalizing**) to the training dataset. we will use the `albumentations` library for that.\n\nFor normalization, It's common to use the mean and standard deviation (std) of the pretrained dataset, it ensures that the input data is on a similar scale and distribution as the data the model was originally trained on. it improves the performance and the convergence of the model.\n","metadata":{"id":"_8jPobCe4H3L"}},{"cell_type":"code","source":"import torch\nfrom torch.utils.data import Dataset, DataLoader\nfrom torchvision import transforms\nfrom dataclasses import dataclass\nimport numpy as np\nfrom typing import Any, Tuple, List, Union\n\nfrom transformers import Mask2FormerImageProcessor\n\npreprocessor = Mask2FormerImageProcessor(\n    ignore_index=0,\n    do_reduce_labels=False,\n    do_resize=False,\n    do_rescale=False,\n    do_normalize=False,\n)\n\nade_mean = [123.675 / 255, 116.280 / 255, 103.530 / 255]\nade_std = [58.395 / 255, 57.120 / 255, 57.375 / 255]\n\nclass SegmentationTransform:\n    def __init__(self, is_train=True):\n        self.is_train = is_train\n        self.img_transform = transforms.Compose([\n            transforms.ToTensor(),\n            transforms.Normalize(mean=ade_mean, std=ade_std)\n        ])\n        if self.is_train:\n            self.img_transform = transforms.Compose([\n                transforms.RandomHorizontalFlip(p=0.5),\n                self.img_transform\n            ])\n\n    def __call__(self, image, mask):\n        image = self.img_transform(image)\n        mask = torch.from_numpy(np.array(mask)).long()\n        if self.is_train and torch.rand(1) < 0.5:\n            image = torch.flip(image, dims=[2])\n            mask = torch.flip(mask, dims=[1])\n        return image, mask\n\n@dataclass\nclass SegmentationDataInput:\n    original_image: np.ndarray\n    transformed_image: torch.Tensor\n    original_segmentation_map: np.ndarray\n    transformed_segmentation_map: torch.Tensor\n\nclass SemanticSegmentationDataset(Dataset):\n    def __init__(self, dataset: Any, is_train: bool = True) -> None:\n        \"\"\"\n        Dataset for Semantic Segmentation.\n        ----\n        Args:\n          - dataset: A dataset containing images and segmentation maps.\n          - is_train: Whether this is a training dataset (for augmentations).\n        \"\"\"\n        self.dataset = dataset\n        self.transform = SegmentationTransform(is_train)\n\n    def __len__(self) -> int:\n        return len(self.dataset)\n\n    def __getitem__(self, idx: int) -> SegmentationDataInput:\n        sample = self.dataset[idx]\n        original_image = sample[\"pixel_values\"]\n        original_segmentation_map = sample[\"label\"]\n        \n        transformed_image, transformed_segmentation_map = self.transform(original_image, original_segmentation_map)\n        \n        return SegmentationDataInput(\n            original_image=np.array(original_image),\n            transformed_image=transformed_image,\n            original_segmentation_map=np.array(original_segmentation_map),\n            transformed_segmentation_map=transformed_segmentation_map,\n        )\n\ndef collate_fn(batch: List[SegmentationDataInput]) -> dict:\n    original_images = [sample.original_image for sample in batch]\n    transformed_images = [sample.transformed_image for sample in batch]\n    original_segmentation_maps = [sample.original_segmentation_map for sample in batch]\n    transformed_segmentation_maps = [sample.transformed_segmentation_map for sample in batch]\n\n    preprocessed_batch = preprocessor(\n        transformed_images,\n        segmentation_maps=transformed_segmentation_maps,\n        return_tensors=\"pt\",\n    )\n    preprocessed_batch[\"original_images\"] = original_images\n    preprocessed_batch[\"original_segmentation_maps\"] = original_segmentation_maps\n    return preprocessed_batch\n\n# Prepare Datasets\ntrain_dataset = SemanticSegmentationDataset(train_ds, is_train=True)\nval_dataset = SemanticSegmentationDataset(val_ds, is_train=False)\ntest_dataset = SemanticSegmentationDataset(test_ds, is_train=False)\n\n# Prepare Dataloaders\ntrain_dataloader = DataLoader(\n    train_dataset, batch_size=8, shuffle=True, collate_fn=collate_fn\n)\nval_dataloader = DataLoader(\n    val_dataset, batch_size=8, shuffle=False, collate_fn=collate_fn\n)\ntest_dataloader = DataLoader(\n    test_dataset, batch_size=8, shuffle=False, collate_fn=collate_fn\n)","metadata":{"execution":{"iopub.status.busy":"2024-10-12T15:13:07.165983Z","iopub.execute_input":"2024-10-12T15:13:07.16636Z","iopub.status.idle":"2024-10-12T15:13:07.188114Z","shell.execute_reply.started":"2024-10-12T15:13:07.166321Z","shell.execute_reply":"2024-10-12T15:13:07.187204Z"},"trusted":true},"outputs":[],"execution_count":null},{"cell_type":"code","source":"for i in train_dataloader:\n    print(i.keys())\n    break","metadata":{"execution":{"iopub.status.busy":"2024-10-12T15:13:07.544523Z","iopub.execute_input":"2024-10-12T15:13:07.5451Z","iopub.status.idle":"2024-10-12T15:13:09.425208Z","shell.execute_reply.started":"2024-10-12T15:13:07.545063Z","shell.execute_reply":"2024-10-12T15:13:09.424157Z"},"trusted":true},"outputs":[],"execution_count":null},{"cell_type":"code","source":"i['pixel_values'].shape","metadata":{"execution":{"iopub.status.busy":"2024-10-12T15:13:09.427089Z","iopub.execute_input":"2024-10-12T15:13:09.427459Z","iopub.status.idle":"2024-10-12T15:13:09.43383Z","shell.execute_reply.started":"2024-10-12T15:13:09.427422Z","shell.execute_reply":"2024-10-12T15:13:09.432899Z"},"trusted":true},"outputs":[],"execution_count":null},{"cell_type":"markdown","source":"_Let's do some quick sanity checks :_\n\n- **Spatial dimension consistency**: The last two dimensions of `pixel_values`,\n  `pixel_mask`, and `mask_labels` should match and correspond to the height and width of the image (after data augmentation).\n- **Channel dimensions for `mask_labels`**: The number of channels (first dimension) of `mask_labels` (representing the categories in the image) should match the number of values in `class_labels`.\n","metadata":{"id":"6uFWfji4QOsJ"}},{"cell_type":"code","source":"sample = next(iter(train_dataloader))\nprint(\n    {\n        key: value[0].shape if isinstance(value, list) else value.shape\n        for key, value in sample.items()\n    }\n)","metadata":{"id":"AERhcfIc4Gv5","outputId":"dfa1fe00-2853-43b7-e277-fb091d6a7013","execution":{"iopub.status.busy":"2024-10-12T15:13:09.434946Z","iopub.execute_input":"2024-10-12T15:13:09.435352Z","iopub.status.idle":"2024-10-12T15:13:11.373713Z","shell.execute_reply.started":"2024-10-12T15:13:09.435317Z","shell.execute_reply":"2024-10-12T15:13:11.372646Z"},"trusted":true},"outputs":[],"execution_count":null},{"cell_type":"markdown","source":"_Let's verify now that the normalization is done correctly by doing the opposite operation (denormalization)_\n","metadata":{"id":"FJeBtCQMUDpo"}},{"cell_type":"code","source":"def denormalize_image(image, mean, std):\n    \"\"\"\n    Denormalizes a normalized image.\n    ----\n    Args:\n     - image (numpy.ndarray): The normalized image.\n     - mean (list or numpy.ndarray): The mean used for normalization.\n     - std (list or numpy.ndarray): The standard deviation used for normalization.\n\n    \"\"\"\n    unnormalized_image = (image * std[:, None, None]) + mean[:, None, None]\n    unnormalized_image = (unnormalized_image * 255).numpy().astype(np.uint8)\n    unnormalized_image = np.moveaxis(unnormalized_image, 0, -1)\n    return unnormalized_image\n\nade_mean = np.array(ade_mean)\nade_std = np.array(ade_std)\ndenormalized_image = denormalize_image(sample[\"pixel_values\"][0], ade_mean, ade_std)\npil_image = Image.fromarray(denormalized_image)\npil_image","metadata":{"id":"45ijY5rV4GVA","outputId":"494f05b1-564e-45df-f3b0-78bbaeb25271","execution":{"iopub.status.busy":"2024-10-12T15:13:11.375819Z","iopub.execute_input":"2024-10-12T15:13:11.37619Z","iopub.status.idle":"2024-10-12T15:13:11.437632Z","shell.execute_reply.started":"2024-10-12T15:13:11.376151Z","shell.execute_reply":"2024-10-12T15:13:11.436716Z"},"trusted":true},"outputs":[],"execution_count":null},{"cell_type":"markdown","source":"_Finally, we will verify the consistency between `mask_labels` and `class_labels` :_\n","metadata":{"id":"8CcWbxRfUcm2"}},{"cell_type":"code","source":"labels = [id2label[label] for label in sample[\"class_labels\"][0].tolist()]\nprint(labels)","metadata":{"id":"FvT4uxZn4FyK","outputId":"442a6f79-9cba-4d45-fcf5-76d267f9e97f","execution":{"iopub.status.busy":"2024-10-12T15:13:11.439111Z","iopub.execute_input":"2024-10-12T15:13:11.439639Z","iopub.status.idle":"2024-10-12T15:13:11.444344Z","shell.execute_reply.started":"2024-10-12T15:13:11.439604Z","shell.execute_reply":"2024-10-12T15:13:11.443329Z"},"trusted":true},"outputs":[],"execution_count":null},{"cell_type":"code","source":"def visualize_mask(sample, labels, label_name):\n    print(f\"Category: {label_name}\")\n    idx = labels.index(label_name)\n\n    visual_mask = (sample[\"mask_labels\"][0][idx].bool().numpy() * 255).astype(np.uint8)\n    return Image.fromarray(visual_mask)","metadata":{"id":"AA7Av8ErPuAM","execution":{"iopub.status.busy":"2024-10-12T15:13:11.445686Z","iopub.execute_input":"2024-10-12T15:13:11.446044Z","iopub.status.idle":"2024-10-12T15:13:11.454749Z","shell.execute_reply.started":"2024-10-12T15:13:11.445981Z","shell.execute_reply":"2024-10-12T15:13:11.453861Z"},"trusted":true},"outputs":[],"execution_count":null},{"cell_type":"code","source":"visualize_mask(sample, labels, labels[0])","metadata":{"id":"vaPDV0KWPt14","outputId":"29972e5f-ac0a-4a97-e0fe-9dad4987b118","execution":{"iopub.status.busy":"2024-10-12T15:13:11.874708Z","iopub.execute_input":"2024-10-12T15:13:11.875046Z","iopub.status.idle":"2024-10-12T15:13:11.889376Z","shell.execute_reply.started":"2024-10-12T15:13:11.875011Z","shell.execute_reply":"2024-10-12T15:13:11.888603Z"},"trusted":true},"outputs":[],"execution_count":null},{"cell_type":"markdown","source":"# Loading model for semantic segmentation\n","metadata":{"id":"goNWFexZUuAt"}},{"cell_type":"markdown","source":"### Model choice\n\n[MaskFormer (Cheng et al., 2021)](https://arxiv.org/abs/2107.06278) is a model capable to solve both semantic segmentation (classifying areas of an image into different categories) and instance segmentation (identifying each distinct object of interest in an image).\n\nMaskFormer unifies these two tasks by _predicting per-pixel masks_, where each pixel is assigned a binary mask and a class label. This approach allows the model to perform both semantic segmentation (by considering the class labels) and instance segmentation (by distinguishing individual objects through unique masks). Panoptic segmentation is naturally incorporated as it combines these two aspects, assigning a semantic label and a unique identifier to every pixel.\n\nAs shown in figure below, the model is composes of :\n\n- **Backbone** : A pre-trained CNN or a ViT that processes the input image to extract a set of feature maps $F$.\n- **Pixel Decoder** : Takes the feature maps from the backbone and produces per-pixel embeddings.\n- **Transformer Decoder**: Processes a fixed number of queries $N$ that along with the image features $F$ to produce per-segment embeddings $Q$. these queries $Q$ represent the features of each potential object segment in the image.\n- **Class and Mask prediction**: The MLP predicts the likelihood of each segment belonging to each of the $K$ classes plus one additional class for the background. binary masks are also predicted for each of these segments.\n\n![MaskFormer Architecture Overview](https://huggingface.co/datasets/hf-vision/course-assets/resolve/main/unit3-chapter-3-segmentation-maskformer.png)\n","metadata":{"id":"W-zeQKwvGl9T"}},{"cell_type":"markdown","source":"### Semantic Segmentation Inference\n\nSemantic segmentation is the task of classifying each pixel in an image into a category effectively grouping parts of the image into distinct objects.\n","metadata":{"id":"pWu7p-36vJHl"}},{"cell_type":"code","source":"processor = AutoImageProcessor.from_pretrained(\"facebook/mask2former-swin-large-ade-semantic\")\nmodel = Mask2FormerForUniversalSegmentation.from_pretrained(\n    \"facebook/mask2former-swin-large-ade-semantic\"\n)","metadata":{"id":"lcXg7gR-sRo6","outputId":"7d1c395d-7b51-46ec-e5dc-aebad77645d1","execution":{"iopub.status.busy":"2024-10-12T15:13:13.626943Z","iopub.execute_input":"2024-10-12T15:13:13.627842Z","iopub.status.idle":"2024-10-12T15:13:14.356778Z","shell.execute_reply.started":"2024-10-12T15:13:13.6278Z","shell.execute_reply":"2024-10-12T15:13:14.355896Z"},"trusted":true},"outputs":[],"execution_count":null},{"cell_type":"code","source":"image = Image.fromarray(denormalized_image)\nimage","metadata":{"id":"rtE0V8i6yPHq","outputId":"6f3d19d5-5a90-4265-c7c0-bbe476c565c5","execution":{"iopub.status.busy":"2024-10-12T15:13:14.940514Z","iopub.execute_input":"2024-10-12T15:13:14.940916Z","iopub.status.idle":"2024-10-12T15:13:14.988377Z","shell.execute_reply.started":"2024-10-12T15:13:14.940878Z","shell.execute_reply":"2024-10-12T15:13:14.987546Z"},"trusted":true},"outputs":[],"execution_count":null},{"cell_type":"code","source":"inputs = processor(images=image, return_tensors=\"pt\")\nwith torch.no_grad():\n    outputs = model(**inputs)\n\npredicted_semantic_map = processor.post_process_semantic_segmentation(\n    outputs, target_sizes=[image.size[::-1]]\n)[0]\npredicted_semantic_map","metadata":{"id":"N8oH8vW3vDEm","outputId":"37b17427-8876-4585-9625-76fb60d5027e","execution":{"iopub.status.busy":"2024-10-12T15:13:16.105728Z","iopub.execute_input":"2024-10-12T15:13:16.106103Z","iopub.status.idle":"2024-10-12T15:13:19.026314Z","shell.execute_reply.started":"2024-10-12T15:13:16.106065Z","shell.execute_reply":"2024-10-12T15:13:19.025177Z"},"trusted":true},"outputs":[],"execution_count":null},{"cell_type":"code","source":"num_classes = len(np.unique(predicted_semantic_map))\ncmap = plt.cm.get_cmap(\"hsv\", num_classes)\n\noverlay = np.zeros(\n    (predicted_semantic_map.shape[0], predicted_semantic_map.shape[1], 4)\n)\n\nfor i, unique_value in enumerate(np.unique(predicted_semantic_map)):\n    overlay[predicted_semantic_map == unique_value, :3] = cmap(i)[:3]\n    overlay[predicted_semantic_map == unique_value, 3] = 0.9  # 50% transparency\n\nfig, ax = plt.subplots(figsize=(8, 6))\nax.imshow(image)\nax.imshow(overlay, interpolation=\"nearest\", alpha=0.9)\nplt.axis(\"off\")\n\nplt.show()","metadata":{"id":"3rQKOykr0APc","outputId":"364aaa9d-68dd-4403-9cf7-626caccf26be","execution":{"iopub.status.busy":"2024-10-12T15:13:19.028175Z","iopub.execute_input":"2024-10-12T15:13:19.028574Z","iopub.status.idle":"2024-10-12T15:13:19.356228Z","shell.execute_reply.started":"2024-10-12T15:13:19.028532Z","shell.execute_reply":"2024-10-12T15:13:19.355329Z"},"trusted":true},"outputs":[],"execution_count":null},{"cell_type":"markdown","source":"### Sanity Check\n","metadata":{"id":"qp3k1SDTGyR3"}},{"cell_type":"markdown","source":"_A good sanity check before launching the training is to compute the loss on one sample_\n","metadata":{"id":"CDjCeX39C_NQ"}},{"cell_type":"code","source":"model = Mask2FormerForUniversalSegmentation.from_pretrained(\n    \"facebook/mask2former-swin-large-ade-semantic\", id2label=id2label, ignore_mismatched_sizes=True\n)","metadata":{"id":"-qsAoU7kHYPB","outputId":"531198df-e920-4b77-beaa-de171dd8bac3","execution":{"iopub.status.busy":"2024-10-12T15:13:19.524814Z","iopub.execute_input":"2024-10-12T15:13:19.525148Z","iopub.status.idle":"2024-10-12T15:13:23.713368Z","shell.execute_reply.started":"2024-10-12T15:13:19.525103Z","shell.execute_reply":"2024-10-12T15:13:23.712581Z"},"trusted":true},"outputs":[],"execution_count":null},{"cell_type":"code","source":"sample = next(iter(train_dataloader))\noutputs = model(\n    pixel_values=sample[\"pixel_values\"],\n    pixel_mask=sample[\"pixel_mask\"],\n    class_labels=sample[\"class_labels\"],\n    mask_labels=sample[\"mask_labels\"],\n)\nprint(outputs.loss)","metadata":{"id":"r9Sfnk7ChKh3","outputId":"70c8a2b3-7017-4aad-d1e1-a219d3a95627","execution":{"iopub.status.busy":"2024-10-10T15:29:14.027623Z","iopub.execute_input":"2024-10-10T15:29:14.028395Z"},"trusted":true},"outputs":[],"execution_count":null},{"cell_type":"markdown","source":"# Training\n","metadata":{"id":"tbeiNy9bG17v"}},{"cell_type":"markdown","source":"### Transfer Learning\n\nTransfer learning involves **freezing** certain layers of the model that have already been trained on a large dataset and fine-tuning other layers on a new (smaller) dataset. To do transfer learning with MaskFormer, we propose the following approach:\n\n**Freezing Components**: The Backbone and the Pixel Decoder will be frozen. Their pre-trained weights capture universal features applicable across different datasets and domains.\n\n**Training Components**: The _Transformer Decoder_ and _MLP_ will be fine-tuned. This process customizes the segment embeddings and classification layers.\n","metadata":{"id":"ABV5klcWs7dt"}},{"cell_type":"markdown","source":"Let's freeze the backbone and the pixel decoder\n","metadata":{"id":"EXScfUhjcehS"}},{"cell_type":"code","source":"# pixel level module contains both the backbone and the pixel decoder\nfor param in model.model.pixel_level_module.parameters():\n    param.requires_grad = False\n\n# Confirm that the parameters are correctly frozen\nfor name, param in model.model.pixel_level_module.named_parameters():\n    assert not param.requires_grad","metadata":{"id":"xy3Jo6u5a8wz","execution":{"iopub.status.busy":"2024-10-12T15:13:28.788769Z","iopub.execute_input":"2024-10-12T15:13:28.789181Z","iopub.status.idle":"2024-10-12T15:13:28.799972Z","shell.execute_reply.started":"2024-10-12T15:13:28.789141Z","shell.execute_reply":"2024-10-12T15:13:28.799011Z"},"trusted":true},"outputs":[],"execution_count":null},{"cell_type":"code","source":"import torch\nfrom tqdm import tqdm\nfrom sklearn.metrics import fbeta_score\n\ndevice = torch.device(\"cuda\" if torch.cuda.is_available() else \"cpu\")\n\ndef compute_dice_f1_for_classes(pred_map, gt_map, beta=0.5, num_classes=None):\n    \"\"\"\n    Computes the Dice Coefficient and F1 score for each class between the predicted segmentation map and the ground truth.\n\n    Args:\n    - pred_map (torch.Tensor): Predicted segmentation map of shape (H, W).\n    - gt_map (torch.Tensor): Ground truth segmentation map of shape (H, W).\n    - beta (float): The beta value to weigh precision more or less than recall in F1 score.\n    - num_classes (int, optional): The number of classes to calculate metrics for. If None, it is inferred from the maps.\n\n    Returns:\n    - dice_coeff (float): Mean Dice coefficient across classes.\n    - f1_score (float): Mean F1 score across classes with the given beta.\n    \"\"\"\n    \n    # Infer number of classes if not provided\n    if num_classes is None:\n        num_classes = max(pred_map.max().item(), gt_map.max().item()) + 1\n\n    dice_scores = []\n    f1_scores = []\n\n    for cls in range(num_classes):\n        # Create binary masks for the current class in both pred_map and gt_map\n        pred_cls_mask = (pred_map == cls).float()\n        gt_cls_mask = (gt_map == cls).float()\n\n        # Dice coefficient: 2 * intersection / (size of prediction + size of ground truth)\n        intersection = (pred_cls_mask * gt_cls_mask).sum()\n        dice_coeff = (2 * intersection) / (pred_cls_mask.sum() + gt_cls_mask.sum() + 1e-8)\n        # dice_scores.append(dice_coeff.item())\n\n        # F1 score: (1 + beta^2) * precision * recall / (beta^2 * precision + recall)\n        precision = intersection / (pred_cls_mask.sum() + 1e-8)\n        recall = intersection / (gt_cls_mask.sum() + 1e-8)\n        f1_score = (1 + beta**2) * (precision * recall) / (beta**2 * precision + recall + 1e-8)\n        # f1_scores.append(f1_score.item())\n        if dice_coeff.item() > 0:\n            dice_scores.append(dice_coeff.item())\n        if f1_score.item() > 0:\n            f1_scores.append(f1_score.item())\n\n\n    # Mean of Dice and F1 across classes\n    mean_dice = sum(dice_scores) / len(dice_scores) if dice_scores else 0.0\n    mean_f1 = sum(f1_scores) / len(f1_scores) if f1_scores else 0.0\n\n    return mean_dice, mean_f1\n\n\ndef evaluate_model(\n    model: Mask2FormerForUniversalSegmentation,\n    dataloader: DataLoader,\n    preprocessor: AutoImageProcessor,\n    id2label: dict,\n    max_batches=None,\n):\n    \"\"\"\n    Evaluates the given model using the specified dataloader and computes a custom metric:\n    - Mean of Dice coefficient\n    - Mean of F1 score with beta=0.5\n    ----\n    Args:\n      - model (MaskFormerForInstanceSegmentation): The trained model to be evaluated.\n      - dataloader (DataLoader): DataLoader containing the dataset for evaluation.\n      - preprocessor (AutoImageProcessor): The preprocessor used for post-processing the model outputs.\n      - id2label (dict): Dictionary mapping class ids to their corresponding labels.\n      - max_batches (int, optional): Maximum number of batches to evaluate. If None, evaluates on the entire validation dataset.\n\n    Returns:\n    dict: The mean Dice coefficient and F1 score calculated over the specified number of batches.\n    \"\"\"\n    model.eval()\n    running_dice = 0.0\n    running_f1 = 0.0\n    num_batches = 0\n    with torch.no_grad():\n        for idx, batch in enumerate(tqdm(dataloader)):\n            if max_batches and idx >= max_batches:\n                break\n            \n            pixel_values = batch[\"pixel_values\"].to(device)\n            outputs = model(pixel_values=pixel_values)\n\n            original_images = batch[\"original_images\"]\n            target_sizes = [\n                (image.shape[0], image.shape[1]) for image in original_images\n            ]\n\n            predicted_segmentation_maps = (\n                preprocessor.post_process_semantic_segmentation(\n                    outputs, target_sizes=target_sizes\n                )\n            )\n\n            ground_truth_segmentation_maps = batch[\"original_segmentation_maps\"]\n\n            # Iterate over the batch\n            for pred_map, gt_map in zip(predicted_segmentation_maps, ground_truth_segmentation_maps):\n                # Convert numpy arrays to torch tensors\n                pred_map = torch.tensor(pred_map).to(device)\n                gt_map = torch.tensor(gt_map).to(device)\n\n                # Compute mean dice and F1 score across all classes in the batch\n                dice_coeff, f1_score = compute_dice_f1_for_classes(pred_map, gt_map, beta=0.5)\n\n                running_dice += dice_coeff\n                running_f1 += f1_score\n                num_batches += 1\n\n    mean_dice = running_dice / num_batches\n    mean_f1 = running_f1 / num_batches\n\n    return {\"mean_dice\": mean_dice, \"mean_f1\": mean_f1}\n\n\ndef train_model(\n    model: Mask2FormerForUniversalSegmentation,\n    train_dataloader: DataLoader,\n    val_dataloader: DataLoader,\n    preprocessor: AutoImageProcessor,\n    id2label: dict,\n    num_epochs=100,\n    learning_rate=5e-5,\n    log_interval=100,\n):\n    \"\"\"\n    Trains the Mask2Former model for semantic segmentation over a specified number of epochs and evaluates it on a validation set using custom metrics.\n    ----\n    Args:\n      - model (MaskFormerForInstanceSegmentation): The model to be trained.\n      - train_dataloader (DataLoader): DataLoader for the training data.\n      - val_dataloader (DataLoader): DataLoader for the validation data.\n      - preprocessor (AutoImageProcessor): The preprocessor used for preparing the data.\n      - id2label (dict): Dictionary mapping class IDs to their corresponding labels.\n      - num_epochs (int): Number of epochs to train the model.\n      - learning_rate (float): Learning rate for the optimizer.\n      - log_interval (int): Interval (in number of batches) at which to log training progress.\n\n    \"\"\"\n    model.to(device)\n\n    optimizer = torch.optim.Adam(model.parameters(), lr=learning_rate)\n\n    for epoch in range(num_epochs):\n        print(f\"Current epoch: {epoch+1}/{num_epochs}\")\n        model.train()\n\n        running_loss = 0.0\n        num_samples = 0\n\n        for idx, batch in enumerate(tqdm(train_dataloader)):\n            optimizer.zero_grad()\n            batch['class_labels'] = [torch.where(label == -1, torch.tensor(35), label) for label in batch['class_labels']]\n            outputs = model(\n                pixel_values=batch[\"pixel_values\"].to(device),\n                mask_labels=[labels.to(device) for labels in batch[\"mask_labels\"]],\n                class_labels=[labels.to(device) for labels in batch[\"class_labels\"]],\n            )\n\n            loss = outputs.loss\n            loss.backward()\n\n            batch_size = batch[\"pixel_values\"].size(0)\n            running_loss += loss.item()\n            num_samples += batch_size\n\n            if idx % log_interval == 0 and idx > 0:\n                print(f\"Iteration {idx} - loss: {running_loss/num_samples}\")\n\n            optimizer.step()\n        \n        # Evaluate using the custom metric\n        val_metrics = evaluate_model(\n            model, val_dataloader, preprocessor, id2label, max_batches=6\n        )\n        print(f\"Validation Metrics - Mean Dice: {val_metrics['mean_dice']}, Mean F1 (β=0.5): {val_metrics['mean_f1']}\")\n","metadata":{"id":"Y0t2NjRsfSeb","execution":{"iopub.status.busy":"2024-10-12T15:13:29.268179Z","iopub.execute_input":"2024-10-12T15:13:29.26856Z","iopub.status.idle":"2024-10-12T15:13:29.29526Z","shell.execute_reply.started":"2024-10-12T15:13:29.268524Z","shell.execute_reply":"2024-10-12T15:13:29.293956Z"},"trusted":true},"outputs":[],"execution_count":null},{"cell_type":"code","source":"model.to(device)\nval_metrics = evaluate_model(model, test_dataloader, preprocessor, id2label)\nprint(f\"Validation Metrics - Mean Dice: {val_metrics['mean_dice']}, Mean F1 (β=0.5): {val_metrics['mean_f1']}\")","metadata":{"execution":{"iopub.status.busy":"2024-10-12T15:13:41.944828Z","iopub.execute_input":"2024-10-12T15:13:41.945843Z","iopub.status.idle":"2024-10-12T15:14:46.792351Z","shell.execute_reply.started":"2024-10-12T15:13:41.945798Z","shell.execute_reply":"2024-10-12T15:14:46.791209Z"},"trusted":true},"outputs":[],"execution_count":null},{"cell_type":"code","source":"train_model(\n    model,\n    train_dataloader,\n    val_dataloader,\n    preprocessor,\n    #metric,\n    id2label,\n    num_epochs=3,\n    log_interval=100,\n)","metadata":{"id":"kWgT1tuDsF7h","outputId":"196708d3-f5c4-4629-f58e-a0967cf722be","execution":{"iopub.status.busy":"2024-10-12T15:14:46.794397Z","iopub.execute_input":"2024-10-12T15:14:46.794751Z","iopub.status.idle":"2024-10-12T15:45:55.998387Z","shell.execute_reply.started":"2024-10-12T15:14:46.794712Z","shell.execute_reply":"2024-10-12T15:45:55.997475Z"},"trusted":true},"outputs":[],"execution_count":null},{"cell_type":"markdown","source":"# Inference and Test Evaluation\n\nAs a metric, we are using Mean Intersection over Union (mean IoU) which is a common metric used for segmentation tasks. it measures the **overlap** between **the predicted segmentation area** and **the ground truth (actual) area** for each class.\n\n$$\\text{IoU} = \\frac{\\text{Area of Overlap}}{\\text{Area of Union}}$$\n","metadata":{"id":"2c-Lqk3lG4w1"}},{"cell_type":"code","source":"test_metric = evaluate_model(model, test_dataloader, preprocessor, id2label)\nprint(f\"Validation Metrics - Mean Dice: {test_metric['mean_dice']}, Mean F1 (β=0.5): {test_metric['mean_f1']}\")","metadata":{"id":"AG4jhtsRV8qq","outputId":"a39b6bca-8928-4dcd-e4a4-db463b3b0833","execution":{"iopub.status.busy":"2024-10-12T15:50:51.021656Z","iopub.execute_input":"2024-10-12T15:50:51.02212Z","iopub.status.idle":"2024-10-12T15:51:56.090642Z","shell.execute_reply.started":"2024-10-12T15:50:51.022081Z","shell.execute_reply":"2024-10-12T15:51:56.089627Z"},"trusted":true},"outputs":[],"execution_count":null},{"cell_type":"code","source":"def show_inference_samples(\n    model: Mask2FormerForUniversalSegmentation,\n    dataloader: DataLoader,\n    preprocessor: AutoImageProcessor,\n    n: int = 5,\n):\n    \"\"\"\n    Displays 'n' samples from the dataloader with model inference results.\n    ----\n    Args:\n     - model: The trained model.\n     - dataloader: DataLoader containing the dataset for inference.\n     - preprocessor: The preprocessor used for post-processing the outputs.\n     - n (int): Number of samples to display.\n\n    \"\"\"\n    model.to(device)\n    model.eval()\n\n    if n > len(dataloader.dataset):\n        raise ValueError(\"n is larger than the dataset size\")\n\n    fig, axs = plt.subplots(n, 2, figsize=(10, 5 * n))\n\n    with torch.no_grad():\n        for i, batch in enumerate(dataloader):\n            if i >= n:\n                break\n\n            pixel_values = batch[\"pixel_values\"].to(device)\n            outputs = model(pixel_values=pixel_values)\n\n            original_images = batch[\"original_images\"]\n            target_sizes = [\n                (image.shape[0], image.shape[1]) for image in original_images\n            ]\n            predicted_segmentation_maps = (\n                preprocessor.post_process_semantic_segmentation(\n                    outputs, target_sizes=target_sizes\n                )\n            )\n\n            ground_truth_segmentation_maps = batch[\"original_segmentation_maps\"]\n\n            # Assuming original_images are numpy arrays and already in the right format\n            image = original_images[i]\n            ground_truth_map = ground_truth_segmentation_maps[i]\n            predicted_map = predicted_segmentation_maps[i]\n\n            axs[i, 0].imshow(image)\n            axs[i, 0].imshow(ground_truth_map, cmap=\"nipy_spectral\", alpha=0.5)\n            axs[i, 0].set_title(\"Ground Truth\")\n            axs[i, 0].axis(\"off\")\n\n            axs[i, 1].imshow(image)\n            axs[i, 1].imshow(\n                predicted_map.cpu().numpy(), cmap=\"nipy_spectral\", alpha=0.5\n            )\n            axs[i, 1].set_title(\"Prediction\")\n            axs[i, 1].axis(\"off\")\n\n    plt.tight_layout()\n    plt.show()","metadata":{"id":"7_E6409tPtDv","execution":{"iopub.status.busy":"2024-10-12T15:52:18.839359Z","iopub.execute_input":"2024-10-12T15:52:18.840209Z","iopub.status.idle":"2024-10-12T15:52:18.851986Z","shell.execute_reply.started":"2024-10-12T15:52:18.840166Z","shell.execute_reply":"2024-10-12T15:52:18.851011Z"},"trusted":true},"outputs":[],"execution_count":null},{"cell_type":"code","source":"show_inference_samples(model, test_dataloader, preprocessor, n=2)","metadata":{"id":"E-oIk4MX-99p","outputId":"3aacd388-3ca6-4878-ca84-2ebb0421fbf4","execution":{"iopub.status.busy":"2024-10-12T15:52:22.192494Z","iopub.execute_input":"2024-10-12T15:52:22.193431Z","iopub.status.idle":"2024-10-12T15:52:32.422652Z","shell.execute_reply.started":"2024-10-12T15:52:22.193385Z","shell.execute_reply":"2024-10-12T15:52:32.421614Z"},"trusted":true},"outputs":[],"execution_count":null},{"cell_type":"code","source":"import os\nos.mkdir('finetuned')\nmodel.save_pretrained(\"finetuned\")","metadata":{"execution":{"iopub.status.busy":"2024-10-12T15:52:32.424481Z","iopub.execute_input":"2024-10-12T15:52:32.424849Z","iopub.status.idle":"2024-10-12T15:52:34.095328Z","shell.execute_reply.started":"2024-10-12T15:52:32.424809Z","shell.execute_reply":"2024-10-12T15:52:34.094505Z"},"trusted":true},"outputs":[],"execution_count":null},{"cell_type":"code","source":"!zip -r finetuned.zip finetuned/","metadata":{"execution":{"iopub.status.busy":"2024-10-12T15:52:44.53811Z","iopub.execute_input":"2024-10-12T15:52:44.538517Z","iopub.status.idle":"2024-10-12T15:53:30.967381Z","shell.execute_reply.started":"2024-10-12T15:52:44.538479Z","shell.execute_reply":"2024-10-12T15:53:30.966347Z"},"trusted":true},"outputs":[],"execution_count":null},{"cell_type":"code","source":"test_dir = '/kaggle/input/iitg-ai-overnight-hackathon-2024/dataset/dataset/test'\n# Array to store the dataset\ntest_dataset = []\n\ntest_images = [f for f in os.listdir(test_dir) if f.endswith('.jpg')]\nfor test_image in test_images:\n    filename = test_image.split('_')[0]\n    image_path = os.path.join(test_dir, test_image)\n    pixel_image = Image.open(image_path).resize((512,512))\n    test_dataset.append({'pixel_values': pixel_image,\n                         'id' : filename})\n\n# Example to show the contents of data_set\nfor idx, data in enumerate(test_dataset[:3]):  # Show first 3 entries\n    print(f\"Index {idx}:\")\n    print(f\"Pixels Image: {data['pixel_values']}\")\n    print(f\"ID: {data['id']}\")\n    # print(f\"Labels Image (Tensor on {device}): {data['label']}\")  # Labels are stored as tensors on GPU if available\n\n\nimport pickle\n# Save the data_set using pickle\nsave_path = '/kaggle/working/data_s.pkl'\n\nwith open(save_path, 'wb') as file:\n    pickle.dump(data_set, file)\n\nprint(f'data_set saved to {save_path}')","metadata":{"execution":{"iopub.status.busy":"2024-10-12T15:53:57.888921Z","iopub.execute_input":"2024-10-12T15:53:57.889357Z","iopub.status.idle":"2024-10-12T15:54:07.280844Z","shell.execute_reply.started":"2024-10-12T15:53:57.889315Z","shell.execute_reply":"2024-10-12T15:54:07.27978Z"},"trusted":true},"outputs":[],"execution_count":null},{"cell_type":"code","source":"test_images[0].split('_')[0]","metadata":{"execution":{"iopub.status.busy":"2024-10-12T15:54:14.88812Z","iopub.execute_input":"2024-10-12T15:54:14.888548Z","iopub.status.idle":"2024-10-12T15:54:14.895602Z","shell.execute_reply.started":"2024-10-12T15:54:14.888507Z","shell.execute_reply":"2024-10-12T15:54:14.894659Z"},"trusted":true},"outputs":[],"execution_count":null},{"cell_type":"code","source":"test_images","metadata":{"execution":{"iopub.status.busy":"2024-10-12T15:54:15.383245Z","iopub.execute_input":"2024-10-12T15:54:15.383632Z","iopub.status.idle":"2024-10-12T15:54:19.1287Z","shell.execute_reply.started":"2024-10-12T15:54:15.383598Z","shell.execute_reply":"2024-10-12T15:54:19.12774Z"},"trusted":true},"outputs":[],"execution_count":null},{"cell_type":"code","source":"from datasets import Dataset\ntest_ds = Dataset.from_dict({\"pixel_values\": [item[\"pixel_values\"] for item in test_dataset],\n                            \"id\": [item[\"id\"] for item in test_dataset]})","metadata":{"execution":{"iopub.status.busy":"2024-10-12T15:54:19.130736Z","iopub.execute_input":"2024-10-12T15:54:19.131751Z","iopub.status.idle":"2024-10-12T15:54:33.427876Z","shell.execute_reply.started":"2024-10-12T15:54:19.131711Z","shell.execute_reply":"2024-10-12T15:54:33.42683Z"},"trusted":true},"outputs":[],"execution_count":null},{"cell_type":"code","source":"test_ds","metadata":{"execution":{"iopub.status.busy":"2024-10-12T15:54:37.491224Z","iopub.execute_input":"2024-10-12T15:54:37.491601Z","iopub.status.idle":"2024-10-12T15:54:37.497756Z","shell.execute_reply.started":"2024-10-12T15:54:37.491568Z","shell.execute_reply":"2024-10-12T15:54:37.496864Z"},"trusted":true},"outputs":[],"execution_count":null},{"cell_type":"code","source":"sample = test_ds[0]['pixel_values']\nplt.imshow(sample)\nplt.axis('off')","metadata":{"execution":{"iopub.status.busy":"2024-10-12T15:54:39.332212Z","iopub.execute_input":"2024-10-12T15:54:39.333083Z","iopub.status.idle":"2024-10-12T15:54:39.597698Z","shell.execute_reply.started":"2024-10-12T15:54:39.333039Z","shell.execute_reply":"2024-10-12T15:54:39.596671Z"},"trusted":true},"outputs":[],"execution_count":null},{"cell_type":"code","source":"\nimport torch\nfrom torch.utils.data import Dataset, DataLoader\nfrom torchvision import transforms\nfrom dataclasses import dataclass\nimport numpy as np\nfrom typing import Any, List\nfrom transformers import Mask2FormerImageProcessor\n\npreprocessor = Mask2FormerImageProcessor(\n    ignore_index=0,\n    do_reduce_labels=False,\n    do_resize=False,\n    do_rescale=False,\n    do_normalize=False,\n)\n\nade_mean = [123.675 / 255, 116.280 / 255, 103.530 / 255]\nade_std = [58.395 / 255, 57.120 / 255, 57.375 / 255]\n\nclass TestSegmentationTransform:\n    def __init__(self):\n        self.img_transform = transforms.Compose([\n            transforms.ToTensor(),\n            transforms.Normalize(mean=ade_mean, std=ade_std)\n        ])\n\n    def __call__(self, image):\n        return self.img_transform(image)\n\n@dataclass\nclass TestSegmentationDataInput:\n    image_id: str\n    original_image: np.ndarray\n    transformed_image: torch.Tensor\n\nclass TestSemanticSegmentationDataset(Dataset):\n    def __init__(self, dataset: Any) -> None:\n        \"\"\"\n        Dataset for Semantic Segmentation Testing.\n        ----\n        Args:\n          - dataset: A dataset containing images for prediction.\n        \"\"\"\n        self.dataset = dataset\n        self.transform = TestSegmentationTransform()\n\n    def __len__(self) -> int:\n        return len(self.dataset)\n\n    def __getitem__(self, idx: int) -> TestSegmentationDataInput:\n        sample = self.dataset[idx]\n        original_image = sample[\"pixel_values\"]\n        image_id = sample[\"id\"]  # Assuming the ID is stored under the key \"id\"\n        \n        transformed_image = self.transform(original_image)\n        \n        return TestSegmentationDataInput(\n            image_id=image_id,\n            original_image=np.array(original_image),\n            transformed_image=transformed_image,\n        )\n\ndef test_collate_fn(batch: List[TestSegmentationDataInput]) -> dict:\n    image_ids = [sample.image_id for sample in batch]\n    original_images = [sample.original_image for sample in batch]\n    transformed_images = [sample.transformed_image for sample in batch]\n\n    preprocessed_batch = preprocessor(\n        transformed_images,\n        return_tensors=\"pt\",\n    )\n    preprocessed_batch[\"image_id\"] = image_ids\n    preprocessed_batch[\"original_images\"] = original_images\n    return preprocessed_batch\n\n# Prepare Test Dataset\ntest_dataset = TestSemanticSegmentationDataset(test_ds)\n\n# Prepare Test Dataloader\ntest_dataloader = DataLoader(\n    test_dataset, batch_size=8, shuffle=False, collate_fn=test_collate_fn\n)","metadata":{"execution":{"iopub.status.busy":"2024-10-12T15:56:45.363878Z","iopub.execute_input":"2024-10-12T15:56:45.364281Z","iopub.status.idle":"2024-10-12T15:56:45.381426Z","shell.execute_reply.started":"2024-10-12T15:56:45.364234Z","shell.execute_reply":"2024-10-12T15:56:45.380447Z"},"trusted":true},"outputs":[],"execution_count":null},{"cell_type":"code","source":"test_ds","metadata":{"execution":{"iopub.status.busy":"2024-10-12T15:56:49.507151Z","iopub.execute_input":"2024-10-12T15:56:49.508066Z","iopub.status.idle":"2024-10-12T15:56:49.513767Z","shell.execute_reply.started":"2024-10-12T15:56:49.508022Z","shell.execute_reply":"2024-10-12T15:56:49.512899Z"},"trusted":true},"outputs":[],"execution_count":null},{"cell_type":"code","source":"for i in test_dataloader:\n    print(i.keys())\n    break","metadata":{"execution":{"iopub.status.busy":"2024-10-12T15:56:52.244187Z","iopub.execute_input":"2024-10-12T15:56:52.245059Z","iopub.status.idle":"2024-10-12T15:56:52.378282Z","shell.execute_reply.started":"2024-10-12T15:56:52.245018Z","shell.execute_reply":"2024-10-12T15:56:52.377305Z"},"trusted":true},"outputs":[],"execution_count":null},{"cell_type":"code","source":"\nlabel_to_color = {label.id: label.color for label in labels_details}\n\ndef run_inference_and_store(\n    model: Mask2FormerForUniversalSegmentation,\n    dataloader: DataLoader,\n    preprocessor: AutoImageProcessor,\n    output_dir: str,\n    device: str = \"cuda\" if torch.cuda.is_available() else \"cpu\"\n):\n    \"\"\"\n    Runs inference on the test dataset and stores the predicted segmentation maps as color-coded images.\n    Returns a dictionary mapping image IDs to their file paths.\n    \"\"\"\n    model.to(device)\n    model.eval()\n    os.makedirs(output_dir, exist_ok=True)\n    \n    id_to_filepath = {}\n\n    with torch.no_grad():\n        for batch in tqdm(dataloader, desc=\"Running inference\"):\n            pixel_values = batch[\"pixel_values\"].to(device)\n            image_ids = batch[\"image_id\"]\n            outputs = model(pixel_values=pixel_values)\n            original_images = batch[\"original_images\"]\n            target_sizes = [(image.shape[0], image.shape[1]) for image in original_images]\n            predicted_segmentation_maps = preprocessor.post_process_semantic_segmentation(\n                outputs, target_sizes=target_sizes\n            )\n\n            for predicted_map, original_image, image_id in zip(predicted_segmentation_maps, original_images, image_ids):\n                predicted_map_np = predicted_map.cpu().numpy()\n                \n                # Create a color-coded image\n                color_map = np.zeros((predicted_map_np.shape[0], predicted_map_np.shape[1], 3), dtype=np.uint8)\n                for label_id, color in label_to_color.items():\n                    color_map[predicted_map_np == label_id] = color\n\n                # Save the color-coded image using image_id as the filename\n                filename = f\"{image_id}.png\"\n                filepath = os.path.join(output_dir, filename)\n                cv2.imwrite(filepath, cv2.cvtColor(color_map, cv2.COLOR_RGB2BGR))\n                \n                # Store the mapping of image ID to file path\n                id_to_filepath[image_id] = filepath\n\n    print(f\"Predicted segmentation maps saved as color-coded images in {output_dir}\")\n    return id_to_filepath\n# Usage example:\n# model = MaskFormerForInstanceSegmentation.from_pretrained(\"your_model_path\")\n# preprocessor = AutoImageProcessor.from_pretrained(\"your_model_path\")\noutput_dir = \"newer_inference\"\nrun_inference_and_store(model=model, dataloader=test_dataloader, preprocessor=preprocessor, output_dir=output_dir)","metadata":{"execution":{"iopub.status.busy":"2024-10-12T15:56:54.169864Z","iopub.execute_input":"2024-10-12T15:56:54.170669Z","iopub.status.idle":"2024-10-12T15:57:26.899501Z","shell.execute_reply.started":"2024-10-12T15:56:54.170624Z","shell.execute_reply":"2024-10-12T15:57:26.898581Z"},"trusted":true},"outputs":[],"execution_count":null},{"cell_type":"code","source":"import cv2\nimport numpy as np\nimport pandas as pd\nimport json\nimport os\n\n\nclass Label:\n    def __init__(self, name, id, csId, csTrainId, level4id, level3Id, category, level2Id, level1Id, hasInstances, ignoreInEval, color):\n        self.name = name\n        self.id = id\n        self.csId = csId\n        self.csTrainId = csTrainId\n        self.level4id = level4id\n        self.level3Id = level3Id\n        self.category = category\n        self.level2Id = level2Id\n        self.level1Id = level1Id\n        self.hasInstances = hasInstances\n        self.ignoreInEval = ignoreInEval\n        self.color = color\n\n# Your label definitions here (from your provided list)\n\nlabels = [\n    #       name                     id    csId     csTrainId level4id        level3Id  category           level2Id      level1Id  hasInstances   ignoreInEval   color\n    Label(  'road'                 ,  0   ,  7 ,     0 ,       0   ,     0  ,   'drivable'            , 0           , 0      , False        , False        , (128, 64,128)  ),\n    Label(  'parking'              ,  1   ,  9 ,   255 ,       1   ,     1  ,   'drivable'            , 1           , 0      , False        , False         , (250,170,160)  ),\n    Label(  'drivable fallback'    ,  2   ,  255 ,   255 ,     2   ,       1  ,   'drivable'            , 1           , 0      , False        , False         , ( 81,  0, 81)  ),\n    Label(  'sidewalk'             ,  3   ,  8 ,     1 ,       3   ,     2  ,   'non-drivable'        , 2           , 1      , False        , False        , (244, 35,232)  ),\n    Label(  'rail track'           ,  4   , 10 ,   255 ,       3   ,     3  ,   'non-drivable'        , 3           , 1      , False        , False         , (230,150,140)  ),\n    Label(  'non-drivable fallback',  5   , 255 ,     9 ,      4   ,      3  ,   'non-drivable'        , 3           , 1      , False        , False        , (152,251,152)  ),\n    Label(  'person'               ,  6   , 24 ,    11 ,       5   ,     4  ,   'living-thing'        , 4           , 2      , True         , False        , (220, 20, 60)  ),\n    Label(  'animal'               ,  7   , 255 ,   255 ,      6   ,      4  ,   'living-thing'        , 4           , 2      , True         , True        , (246, 198, 145)),\n    Label(  'rider'                ,  8   , 25 ,    12 ,       7   ,     5  ,   'living-thing'        , 5           , 2      , True         , False        , (255,  0,  0)  ),\n    Label(  'motorcycle'           ,  9   , 32 ,    17 ,       8   ,     6  ,   '2-wheeler'           , 6           , 3      , True         , False        , (  0,  0,230)  ),\n    Label(  'bicycle'              , 10   , 33 ,    18 ,       9   ,     7  ,   '2-wheeler'           , 6           , 3      , True         , False        , (119, 11, 32)  ),\n    Label(  'autorickshaw'         , 11   , 255 ,   255 ,     10   ,      8  ,   'autorickshaw'        , 7           , 3      , True         , False        , (255, 204, 54) ),\n    Label(  'car'                  , 12   , 26 ,    13 ,      11   ,     9  ,   'car'                 , 7           , 3      , True         , False        , (  0,  0,142)  ),\n    Label(  'truck'                , 13   , 27 ,    14 ,      12   ,     10 ,   'large-vehicle'       , 8           , 3      , True         , False        , (  0,  0, 70)  ),\n    Label(  'bus'                  , 14   , 28 ,    15 ,      13   ,     11 ,   'large-vehicle'       , 8           , 3      , True         , False        , (  0, 60,100)  ),\n    Label(  'caravan'              , 15   , 29 ,   255 ,      14   ,     12 ,   'large-vehicle'       , 8           , 3      , True         , True         , (  0,  0, 90)  ),\n    Label(  'trailer'              , 16   , 30 ,   255 ,      15   ,     12 ,   'large-vehicle'       , 8           , 3      , True         , True         , (  0,  0,110)  ),\n    Label(  'train'                , 17   , 31 ,    16 ,      15   ,     12 ,   'large-vehicle'       , 8           , 3      , True         , True        , (  0, 80,100)  ),\n    Label(  'vehicle fallback'     , 18   , 355 ,   255 ,     15   ,      12 ,   'large-vehicle'       , 8           , 3      , True         , False        , (136, 143, 153)),  \n    Label(  'curb'                 , 19   ,255 ,   255 ,      16   ,     13 ,   'barrier'             , 9           , 4      , False        , False        , (220, 190, 40)),\n    Label(  'wall'                 , 20   , 12 ,     3 ,      17   ,     14 ,   'barrier'             , 9           , 4      , False        , False        , (102,102,156)  ),\n    Label(  'fence'                , 21   , 13 ,     4 ,      18   ,     15 ,   'barrier'             , 10           , 4      , False        , False        , (190,153,153)  ),\n    Label(  'guard rail'           , 22   , 14 ,   255 ,      19   ,     16 ,   'barrier'             , 10          , 4      , False        , False         , (180,165,180)  ),\n    Label(  'billboard'            , 23   , 255 ,   255 ,     20   ,      17 ,   'structures'          , 11           , 4      , False        , False        , (174, 64, 67) ),\n    Label(  'traffic sign'         , 24   , 20 ,     7 ,      21   ,     18 ,   'structures'          , 11          , 4      , False        , False        , (220,220,  0)  ),\n    Label(  'traffic light'        , 25   , 19 ,     6 ,      22   ,     19 ,   'structures'          , 11          , 4      , False        , False        , (250,170, 30)  ),\n    Label(  'pole'                 , 26   , 17 ,     5 ,      23   ,     20 ,   'structures'          , 12          , 4      , False        , False        , (153,153,153)  ),\n    Label(  'polegroup'            , 27   , 18 ,   255 ,      23   ,     20 ,   'structures'          , 12          , 4      , False        , False         , (153,153,153)  ),\n    Label(  'obs-str-bar-fallback' , 28   , 255 ,   255 ,     24   ,      21 ,   'structures'          , 12          , 4      , False        , False        , (169, 187, 214) ),  \n    Label(  'building'             , 29   , 11 ,     2 ,      25   ,     22 ,   'construction'        , 13          , 5      , False        , False        , ( 70, 70, 70)  ),\n    Label(  'bridge'               , 30   , 15 ,   255 ,      26   ,     23 ,   'construction'        , 13          , 5      , False        , False         , (150,100,100)  ),\n    Label(  'tunnel'               , 31   , 16 ,   255 ,      26   ,     23 ,   'construction'        , 13          , 5      , False        , False         , (150,120, 90)  ),\n    Label(  'vegetation'           , 32   , 21 ,     8 ,      27   ,     24 ,   'vegetation'          , 14          , 5      , False        , False        , (107,142, 35)  ),\n    Label(  'sky'                  , 33   , 23 ,    10 ,      28   ,     25 ,   'sky'                 , 15          , 6      , False        , False        , ( 70,130,180)  ),\n    Label(  'fallback background'  , 34   , 255 ,   255 ,     29   ,      25 ,   'object fallback'     , 15          , 6      , False        , False        , (169, 187, 214)),\n    Label(  'unlabeled'            , 35   ,  0  ,     255 ,   255   ,      255 ,   'void'                , 255         , 255    , False        , True         , (  0,  0,  0)  ),\n    Label(  'ego vehicle'          , 36   ,  1  ,     255 ,   255   ,      255 ,   'void'                , 255         , 255    , False        , True         , (  0,  0,  0)  ),\n    Label(  'rectification border' , 37   ,  2  ,     255 ,   255   ,      255 ,   'void'                , 255         , 255    , False        , True         , (  0,  0,  0)  ),\n    Label(  'out of roi'           , 38   ,  3  ,     255 ,   255   ,      255 ,   'void'                , 255         , 255    , False        , True         , (  0,  0,  0)  ),\n    Label(  'license plate'        , 39   , 255 ,     255 ,   255   ,      255 ,   'vehicle'             , 255         , 255    , False        , True         , (  0,  0,142)  ),\n    \n]           \n\n      \n\n# Function to get label information from pixel color\ndef get_label_by_color(color):\n    for label in labels:\n        if label.color == tuple(color):  # Compare the pixel color to the label color\n            return label\n    return None\n\n# Function to convert the segmented image into polygon-based format and prepare for CSV\ndef image_to_polygon_format(image_path):\n    if not os.path.exists(image_path):\n        raise FileNotFoundError(f\"Image path '{image_path}' not found.\")\n    \n    segmented_image = cv2.imread(image_path)\n    segmented_image = cv2.resize(segmented_image, (1920, 1080))# Load the segmented image\n    if segmented_image is None:\n        raise ValueError(f\"Failed to load image at '{image_path}'. Make sure the file is a valid image.\")\n\n    height, width, _ = segmented_image.shape\n\n    objects = []  # To hold the polygon data for each object\n\n    # Loop through all the labels\n    for label in labels:\n        if label.ignoreInEval:\n            continue  # Skip labels that should be ignored\n\n        # Convert the label color to a binary mask\n        mask = cv2.inRange(segmented_image, np.array(label.color), np.array(label.color))\n\n        # Find contours (polygons) in the binary mask\n        contours, _ = cv2.findContours(mask, cv2.RETR_EXTERNAL, cv2.CHAIN_APPROX_SIMPLE)\n\n        for contour in contours:\n            if len(contour) < 3:  # Skip small or invalid polygons\n                continue\n\n            # Simplify the contour to polygon format\n            polygon = contour.reshape(-1, 2).tolist()  # Flatten the contour to a list of points\n\n            # Create the object data for the current label and polygon\n            object_data = {\n                \"label\": label.name,\n                \"polygon\": polygon\n            }\n\n            # Append the object to the result\n            objects.append(object_data)\n\n    return objects\n\n# Function to save to the CSV format as requested\ndef save_to_csv(objects_dict, output_csv_path):\n    # Create a DataFrame with id and objects\n    data = [{\"id\": filename, \"objects\": json.dumps(objects)} for filename, objects in objects_dict.items()]\n    df = pd.DataFrame(data)\n    \n    # Save to CSV\n    df.to_csv(output_csv_path, index=False)\n\n# Main function to process multiple images and save the output CSV\ndef process_images(image_folder, output_csv_path):\n    if not os.path.exists(image_folder):\n        raise FileNotFoundError(f\"Image folder '{image_folder}' not found.\")\n    \n    objects_dict = {}\n\n    # Process each image and store the objects for each row ID\n    segmented_image_paths = [os.path.join(image_folder, f) for f in os.listdir(image_folder) if os.path.isfile(os.path.join(image_folder, f))]\n\n    for image_path in segmented_image_paths:\n        # Get the filename without the extension\n        filename = os.path.splitext(os.path.basename(image_path))[0].replace('_gtFine_labelColors', '')\n        polygon_data = image_to_polygon_format(image_path)\n        objects_dict[filename] = polygon_data\n\n    # Save the results to CSV\n    save_to_csv(objects_dict, output_csv_path)","metadata":{"execution":{"iopub.status.busy":"2024-10-12T16:01:28.274028Z","iopub.execute_input":"2024-10-12T16:01:28.274464Z","iopub.status.idle":"2024-10-12T16:01:28.318679Z","shell.execute_reply.started":"2024-10-12T16:01:28.274424Z","shell.execute_reply":"2024-10-12T16:01:28.317749Z"},"trusted":true},"outputs":[],"execution_count":null},{"cell_type":"code","source":"image_folder = \"newer_inference\"  # Same as output_dir in run_inference_and_store\noutput_csv_path = \"submission.csv\"\nprocess_images(image_folder, output_csv_path)","metadata":{"execution":{"iopub.status.busy":"2024-10-12T16:01:30.323087Z","iopub.execute_input":"2024-10-12T16:01:30.323726Z","iopub.status.idle":"2024-10-12T16:01:43.605545Z","shell.execute_reply.started":"2024-10-12T16:01:30.323684Z","shell.execute_reply":"2024-10-12T16:01:43.604523Z"},"trusted":true},"outputs":[],"execution_count":null},{"cell_type":"markdown","source":"# **LOW FREQUENCY CLASS**","metadata":{}},{"cell_type":"code","source":"import operator\nsorted_label_dict = dict(sorted(label_dict.items(),key = operator.itemgetter(1)))\nsorted_label_dict","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-10-12T11:43:34.450062Z","iopub.execute_input":"2024-10-12T11:43:34.4505Z","iopub.status.idle":"2024-10-12T11:43:34.460928Z","shell.execute_reply.started":"2024-10-12T11:43:34.45046Z","shell.execute_reply":"2024-10-12T11:43:34.459695Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"lfreq_label_dict = []\nfor i in sorted_label_dict.items():\n    if i[1] < 100 and i[1] > 4:\n        lfreq_label_dict.append(i[0])","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-10-12T11:46:36.290817Z","iopub.execute_input":"2024-10-12T11:46:36.291246Z","iopub.status.idle":"2024-10-12T11:46:36.29695Z","shell.execute_reply.started":"2024-10-12T11:46:36.291182Z","shell.execute_reply":"2024-10-12T11:46:36.295845Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"for k, v in enumerate(lfreq_label_dict):\n    print(k, \" \", v)","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-10-12T11:46:37.764489Z","iopub.execute_input":"2024-10-12T11:46:37.764876Z","iopub.status.idle":"2024-10-12T11:46:37.770469Z","shell.execute_reply.started":"2024-10-12T11:46:37.76484Z","shell.execute_reply":"2024-10-12T11:46:37.76942Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"import os\nimport json\n\ndef extract_label_images(base_dir, class_name):\n    label_ids = []\n    \n    # Go through each sub-directory in the 'labels' folder\n    for sub_dir in os.listdir(base_dir):\n        sub_dir_path = os.path.join(base_dir, sub_dir)\n            \n        # Iterate through each file in the sub-directory\n        for json_file in os.listdir(sub_dir_path):\n            if json_file.endswith('_polygons.json'):\n                json_path = os.path.join(sub_dir_path, json_file)\n\n                # Load the JSON file\n                with open(json_path, 'r') as f:\n                    data = json.load(f)\n                    for obj in data.get('objects', []):\n                        if obj.get('label') == class_name:\n                            # Extract the unique image ID from the file name (e.g., 'frame0029')\n                            image_id = json_file.split('_')[0].replace('frame', '')\n                            image_id = sub_dir + \"_\" + image_id\n                            label_ids.append(image_id)\n                            break\n    \n    return label_ids\n\n\n# Example usage\nbase_dir = '/kaggle/input/iitg-ai-overnight-hackathon-2024/dataset/dataset/labels'  # Update with the actual path to the 'labels' directory\n# tunnel_images = extract_tunnel_images(base_dir)\n# print(tunnel_images)\n","metadata":{},"outputs":[],"execution_count":null},{"cell_type":"code","source":"lfreq_label_dict = lfreq_label_dict.fromkeys(lower_freq_labels, [])\nfor label in lfreq_label_dict:\n    ls = extract_label_images(base_dir, label)\n    lfreq_label_dict[label] = ls","metadata":{},"outputs":[],"execution_count":null},{"cell_type":"code","source":"import os\nimport shutil\n\ndef organize_images_by_class(class_labels, image_dir, output_dir):\n    \"\"\"Organizes images into subdirectories based on class labels and image IDs.\n\n    Args:\n        class_labels (dict): A dictionary where keys are class labels and values are lists of image IDs.\n        image_dir (str): The directory containing the original images.\n        output_dir (str): The root directory where class subdirectories will be created.\n    \"\"\"\n\n\n    for class_label, image_ids in class_labels.items():\n        class_subdir = os.path.join(output_dir, str(class_label))  # Creating subdir name\n\n        # Create subdirectory if it doesn't exist\n        os.makedirs(class_subdir, exist_ok=True)\n\n        for image_id_string in image_ids:\n            subdir, image_id = image_id_string.split(\"_\")\n\n            try:\n                image_name = f\"frame{image_id}_leftImg8bit.jpg\"\n                source_image_path = os.path.join(image_dir, subdir, image_name)\n                shutil.copy(source_image_path, os.path.join(class_subdir, image_name))\n                print(f\"Copied '{image_name}' to '{class_label}' subdirectory.\")\n\n\n            except FileNotFoundError:\n                try:\n                    image_name = f\"{image_id}_leftImg8bit.jpg\"\n                    source_image_path = os.path.join(image_dir, subdir, image_name)\n                    shutil.copy(source_image_path, os.path.join(class_subdir, image_name))\n                    print(f\"Copied '{image_name}' to '{class_label}' subdirectory.\")\n\n                except FileNotFoundError:\n                    print(f\"WARNING: Neither file pattern found for {image_id_string}\")\n\n\n# Example usage (replace with your actual data)\nclass_labels = lfreq_label_dict\n\nimage_dir = r\"/kaggle/input/iitg-ai-overnight-hackathon-2024/dataset/dataset/train\"\noutput_dir = r\"/kaggle/working/images\"\n\n\norganize_images_by_class(class_labels, image_dir, output_dir)","metadata":{},"outputs":[],"execution_count":null},{"cell_type":"code","source":"import os\nimport json\n\n# Define rare classes\nrare_classes = ['tunnel','trailer', 'train', 'rectification border', 'rail track', 'parking']\n\n# Store the scores for each subdirectory\nsubdir_scores = {}\nbase_path = '/kaggle/input/iitg-ai-overnight-hackathon-2024/dataset/dataset/labels'\n# Iterate over all subdirectories (e.g., 201, 202...)\nfor subdir in os.listdir(base_path):\n    class_count = {}\n    rare_class_count = 0\n    image_count = 0\n\n    # Get all JSON files (assuming the format is like frame{id}_polygons.json)\n    json_files = [f for f in os.listdir(os.path.join(base_path, subdir)) if f.endswith('_polygons.json')]\n\n    for json_file in json_files:\n        image_count += 1  # Increment image count\n        with open(os.path.join(os.path.join(base_path, subdir), json_file), 'r') as file:\n            data = json.load(file)\n            for obj in data['objects']:\n                label = obj['label']\n                # Count class occurrences\n                if label in class_count:\n                    class_count[label] += 1\n                else:\n                    class_count[label] = 1\n\n                # Count rare class occurrences\n                if label in rare_classes:\n                    rare_class_count += 1\n\n    # Calculate the class diversity score\n    class_diversity_score = len(class_count)  # Number of unique classes\n\n    # Store the subdirectory scores\n    subdir_scores[subdir] = {\n        'class_diversity_score': class_diversity_score,\n        'rare_class_score': rare_class_count,\n        'image_count': image_count\n    }\n\n# Normalize the scores and calculate the weighted score\nmax_class_diversity = max([v['class_diversity_score'] for v in subdir_scores.values()])\nmax_rare_class = max([v['rare_class_score'] for v in subdir_scores.values()])\nmax_image_count = max([v['image_count'] for v in subdir_scores.values()])\n\nα, β, γ = 0.0, 1, 0.0  # Example weights\n\nfor subdir, scores in subdir_scores.items():\n    weighted_score = (\n        α * (scores['class_diversity_score'] / max_class_diversity) +\n        β * (scores['rare_class_score'] / max_rare_class) +\n        γ * (scores['image_count'] / max_image_count)\n    )\n    subdir_scores[subdir]['weighted_score'] = weighted_score\n\n# Sort the subdirectories based on weighted score\nranked_subdirs = sorted(subdir_scores.items(), key=lambda x: x[1]['weighted_score'], reverse=True)\n\n# Select top N subdirectories for dataset creation\n# top_subdirs = [subdir for subdir, scores in ranked_subdirs[:N]]  # N is the number of subdirs to sample","metadata":{},"outputs":[],"execution_count":null}]}