{"metadata":{"kernelspec":{"language":"python","display_name":"Python 3","name":"python3"},"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"},"kaggle":{"accelerator":"none","dataSources":[{"sourceId":71549,"databundleVersionId":8561470,"sourceType":"competition"},{"sourceId":8828221,"sourceType":"datasetVersion","datasetId":5311520},{"sourceId":8828438,"sourceType":"datasetVersion","datasetId":5311657},{"sourceId":8830300,"sourceType":"datasetVersion","datasetId":5312851},{"sourceId":9144019,"sourceType":"datasetVersion","datasetId":5522040},{"sourceId":9177976,"sourceType":"datasetVersion","datasetId":5546970},{"sourceId":9394772,"sourceType":"datasetVersion","datasetId":5550734},{"sourceId":195442359,"sourceType":"kernelVersion"}],"dockerImageVersionId":30761,"isInternetEnabled":false,"language":"python","sourceType":"notebook","isGpuEnabled":false}},"nbformat_minor":4,"nbformat":4,"cells":[{"cell_type":"code","source":"#!mkdir -p /kaggle/working/julia-1.10.4\n#!cp -r /kaggle/input/notebookf3972f5a93/julia-1.10.4/* /kaggle/working/julia-1.10.4/\n#!cp -r /kaggle/input/env4julia/julia-1.10.4/* /kaggle/working/julia-1.10.4/\n#看來不可行","metadata":{"_uuid":"8f2839f25d086af736a60e9eeb907d3b93b6e0e5","_cell_guid":"b1076dfc-b9ad-4769-8c92-a6c4dae69d19","execution":{"iopub.status.busy":"2024-09-06T06:05:18.145092Z","iopub.execute_input":"2024-09-06T06:05:18.146026Z","iopub.status.idle":"2024-09-06T06:05:18.150791Z","shell.execute_reply.started":"2024-09-06T06:05:18.145980Z","shell.execute_reply":"2024-09-06T06:05:18.149538Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"#換一個方法\n!ls /kaggle/input/rsnajuliaenv/\n\n#解壓縮\n!tar -xzf /kaggle/input/rsnajuliaenv/julia_envfinal.tar.gz\n\n#創建環境資料夾\n!mkdir -p /kaggle/working/juliaenvRoot/\n\n#!tar -xzf /kaggle/input/rsnajuliaenv/julia_environment.tar.gz  /kaggle/working/juliaEnv\n","metadata":{"execution":{"iopub.status.busy":"2024-09-10T12:47:06.596435Z","iopub.execute_input":"2024-09-10T12:47:06.597278Z","iopub.status.idle":"2024-09-10T12:47:18.869581Z","shell.execute_reply.started":"2024-09-10T12:47:06.597229Z","shell.execute_reply":"2024-09-10T12:47:18.868010Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"!tar -xzf /kaggle/input/rsnajuliaenv/julia_environment.tar.gz -C /kaggle/working/juliaenvRoot/\n#!tar -tzf /kaggle/input/rsnajuliaenv/julia_environment.tar.gz\n#!ls  /kaggle/working/juliaEnv","metadata":{"execution":{"iopub.status.busy":"2024-09-10T12:47:45.750752Z","iopub.execute_input":"2024-09-10T12:47:45.751236Z","iopub.status.idle":"2024-09-10T12:49:26.938176Z","shell.execute_reply.started":"2024-09-10T12:47:45.751191Z","shell.execute_reply":"2024-09-10T12:49:26.936062Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"#檢查環境檔案\n!ls -a /kaggle/working/juliaenvRoot/root\n#傳遞資料夾\n!cp -r /kaggle/working/juliaenvRoot/root/.julia /root/\n\n","metadata":{"execution":{"iopub.status.busy":"2024-09-10T12:50:20.589082Z","iopub.execute_input":"2024-09-10T12:50:20.589632Z","iopub.status.idle":"2024-09-10T12:50:52.535063Z","shell.execute_reply.started":"2024-09-10T12:50:20.589575Z","shell.execute_reply":"2024-09-10T12:50:52.533357Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"#確認複製成功\n!ls -a /root","metadata":{"execution":{"iopub.status.busy":"2024-09-06T06:07:36.331797Z","iopub.execute_input":"2024-09-06T06:07:36.332460Z","iopub.status.idle":"2024-09-06T06:07:37.523707Z","shell.execute_reply.started":"2024-09-06T06:07:36.332393Z","shell.execute_reply":"2024-09-06T06:07:37.522231Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"#JULIA_HOME：指定 Julia 安装目录，主要供内部使用，帮助一些程序找到 Julia 相关资源。\n#PATH：系统搜索可执行文件的路径，设置后可以直接运行 Julia 命令。\n#LD_LIBRARY_PATH：动态链接库的搜索路径，确保 Julia 及其依赖库可以被正确加载。\nimport os\nos.environ['JULIA_HOME'] = '/kaggle/working/kaggle/working/julia-1.10.4/bin'\nos.environ['PATH'] = '/kaggle/working/kaggle/working/julia-1.10.4/bin:' + os.environ['PATH']\nos.environ['LD_LIBRARY_PATH'] = '/kaggle/working/kaggle/working/julia-1.10.4/lib:' + os.environ.get('LD_LIBRARY_PATH', '')\n\n#!/kaggle/working/julia-1.10.4/usr/bin/julia -e 'println(\"Hello from Julia!\")'","metadata":{"execution":{"iopub.status.busy":"2024-09-10T12:51:02.812425Z","iopub.execute_input":"2024-09-10T12:51:02.812940Z","iopub.status.idle":"2024-09-10T12:51:03.834559Z","shell.execute_reply.started":"2024-09-10T12:51:02.812897Z","shell.execute_reply":"2024-09-10T12:51:03.833231Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"!/kaggle/working/kaggle/working/julia-1.10.4/bin/julia -e 'println(\"Hello from Julia!\")'\n!/kaggle/working/kaggle/working/julia-1.10.4/bin/julia --version\n","metadata":{"execution":{"iopub.status.busy":"2024-09-10T12:51:07.525329Z","iopub.execute_input":"2024-09-10T12:51:07.525980Z","iopub.status.idle":"2024-09-10T12:51:12.224580Z","shell.execute_reply.started":"2024-09-10T12:51:07.525907Z","shell.execute_reply":"2024-09-10T12:51:12.222953Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"#確認環境是否OK\n#激活项目环境：Pkg.activate(\".\")\n#查看包状态：Pkg.status()\n#根据依赖安装包：Pkg.instantiate()\n#构建项目依赖：Pkg.build()","metadata":{"execution":{"iopub.status.busy":"2024-09-06T06:07:43.706600Z","iopub.execute_input":"2024-09-06T06:07:43.707191Z","iopub.status.idle":"2024-09-06T06:07:43.715195Z","shell.execute_reply.started":"2024-09-06T06:07:43.707123Z","shell.execute_reply":"2024-09-06T06:07:43.713551Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"#確認可以使用\n!/kaggle/working/kaggle/working/julia-1.10.4/bin/julia -e '''using Pkg; Pkg.activate(\".\"); Pkg.status()'''","metadata":{"execution":{"iopub.status.busy":"2024-09-06T06:07:43.717797Z","iopub.execute_input":"2024-09-06T06:07:43.718334Z","iopub.status.idle":"2024-09-06T06:07:54.616637Z","shell.execute_reply.started":"2024-09-06T06:07:43.718271Z","shell.execute_reply":"2024-09-06T06:07:54.615028Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"#獎準備好的環境轉移\n#先建立資料夾在移動\n!mkdir -p /kaggle/working/juliaenv\n!mkdir -p /kaggle/working/output\n\n\n#移動資料夾 \n!cp /kaggle/input/rsnajuliaenv/Project.toml /kaggle/working/\n!cp /kaggle/input/rsnajuliaenv/Manifest.toml /kaggle/working/","metadata":{"execution":{"iopub.status.busy":"2024-09-10T12:52:04.245966Z","iopub.execute_input":"2024-09-10T12:52:04.246413Z","iopub.status.idle":"2024-09-10T12:52:08.841268Z","shell.execute_reply.started":"2024-09-10T12:52:04.246372Z","shell.execute_reply":"2024-09-10T12:52:08.840009Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"#確認環境已更動\n!/kaggle/working/kaggle/working/julia-1.10.4/bin/julia -e '''using Pkg; Pkg.activate(\".\"); Pkg.status()'''","metadata":{"execution":{"iopub.status.busy":"2024-09-06T06:07:59.314321Z","iopub.execute_input":"2024-09-06T06:07:59.314901Z","iopub.status.idle":"2024-09-06T06:08:03.554917Z","shell.execute_reply.started":"2024-09-06T06:07:59.314819Z","shell.execute_reply":"2024-09-06T06:08:03.553693Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"#確認目前資料夾\n!ls /kaggle/working/juliaenv","metadata":{"execution":{"iopub.status.busy":"2024-09-10T12:52:38.627990Z","iopub.execute_input":"2024-09-10T12:52:38.628879Z","iopub.status.idle":"2024-09-10T12:52:39.779712Z","shell.execute_reply.started":"2024-09-10T12:52:38.628832Z","shell.execute_reply":"2024-09-10T12:52:39.778436Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"#開始程式\n#執行第一部分 查看資料結構\n!cp /kaggle/input/rsna4jl/structure4dir.jl /kaggle/working/juliaenv\n!cp /kaggle/input/rsna4jl/structure4dir_run.jl /kaggle/working/juliaenv\n#!/kaggle/working/kaggle/working/julia-1.10.4/bin/julia -e  'using Pkg; Pkg.activate(\".\"); include(\"/kaggle/working/juliaenv/structure4dir_run.jl\")'\n","metadata":{"execution":{"iopub.status.busy":"2024-09-10T12:53:14.394036Z","iopub.execute_input":"2024-09-10T12:53:14.394572Z","iopub.status.idle":"2024-09-10T12:53:16.764534Z","shell.execute_reply.started":"2024-09-10T12:53:14.394527Z","shell.execute_reply":"2024-09-10T12:53:16.763047Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"!ls  /kaggle/input/rsnajuliaenv/image_testrun","metadata":{"execution":{"iopub.status.busy":"2024-09-06T06:10:48.977285Z","iopub.execute_input":"2024-09-06T06:10:48.977765Z","iopub.status.idle":"2024-09-06T06:10:50.165478Z","shell.execute_reply.started":"2024-09-06T06:10:48.977716Z","shell.execute_reply":"2024-09-06T06:10:50.164066Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"#確認imgae test\n!cp /kaggle/input/rsna4jl/Draw4dataframe.jl /kaggle/working/juliaenv\n!cp /kaggle/input/rsna4jl/draw_default.jl /kaggle/working/juliaenv\n!cp /kaggle/input/rsna4jl/image_test.jl /kaggle/working/juliaenv\n!mkdir -p /kaggle/working/image_testrun\n#將環境放到 /kaggle/working/image_testrun/\n!cp /kaggle/input/rsnajuliaenv/image_testrun/* /kaggle/working/image_testrun/\n!ls /kaggle/input/rsnajuliaenv/image_testrun","metadata":{"execution":{"iopub.status.busy":"2024-09-10T12:53:23.476153Z","iopub.execute_input":"2024-09-10T12:53:23.476641Z","iopub.status.idle":"2024-09-10T12:53:30.440267Z","shell.execute_reply.started":"2024-09-10T12:53:23.476594Z","shell.execute_reply":"2024-09-10T12:53:30.438896Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"#記憶體不夠 先註解\n#!/kaggle/working/kaggle/working/julia-1.10.4/bin/julia -e 'using Pkg; Pkg.activate(\"/kaggle/working/image_testrun/\"); include(\"/kaggle/working/juliaenv/image_test.jl\")'","metadata":{"execution":{"iopub.status.busy":"2024-09-06T06:10:57.066742Z","iopub.execute_input":"2024-09-06T06:10:57.067168Z","iopub.status.idle":"2024-09-06T06:32:02.529983Z","shell.execute_reply.started":"2024-09-06T06:10:57.067124Z","shell.execute_reply":"2024-09-06T06:32:02.528182Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"#import matplotlib.pyplot as plt\n#import matplotlib.image as mpimg\n\n# 圖片路徑列表\n#image_paths = [\n#    '/kaggle/working/output/left_subarticular_stenosis_[l1_l2~l5_s1].png',\n#    '/kaggle/working/output/left_neural_foraminal_[l1_l2~l5_s1].png',\n#    '/kaggle/working/output/right_subarticular_stenosis_[l1_l2~l5_s1].png',\n#    '/kaggle/working/output/right_neural_foraminal_narrowing_[l1_l2~l5_s1].png',\n#    '/kaggle/working/output/spinal_canal_stenosis_[l1_l2~l5_s1].png'\n#]\n\n# 設置圖表大小 (每張圖片的寬度 x 數量)\n#plt.figure(figsize=(15, 5))\n\n# 迭代顯示圖片\n#for i, image_path in enumerate(image_paths):\n#    plt.subplot(1, len(image_paths), i + 1)\n#    img = mpimg.imread(image_path)\n#    plt.imshow(img)\n#    plt.axis('off')  # 隱藏坐標軸\n\n#plt.show()","metadata":{"execution":{"iopub.status.busy":"2024-09-06T06:32:02.532356Z","iopub.execute_input":"2024-09-06T06:32:02.532859Z","iopub.status.idle":"2024-09-06T06:32:04.124357Z","shell.execute_reply.started":"2024-09-06T06:32:02.532790Z","shell.execute_reply":"2024-09-06T06:32:04.123195Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"#讀取model\n!mkdir -p /kaggle/working/juliaenv/model\n!mkdir -p /kaggle/working/juliaenv/analyze\n!cp /kaggle/input/rsna4jl/data_augamentation2.jl  /kaggle/working/juliaenv\n!cp /kaggle/input/rsna4jl/result4kaggle2.jl /kaggle/working/juliaenv/model\n!cp /kaggle/input/rsna4jl/Use4model.jl /kaggle/working/juliaenv/model\n!cp /kaggle/input/rsna4jl/Use4image.jl  /kaggle/working/juliaenv/analyze","metadata":{"execution":{"iopub.status.busy":"2024-09-10T15:14:21.967053Z","iopub.execute_input":"2024-09-10T15:14:21.968046Z","iopub.status.idle":"2024-09-10T15:14:28.950942Z","shell.execute_reply.started":"2024-09-10T15:14:21.967986Z","shell.execute_reply":"2024-09-10T15:14:28.948979Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"!/kaggle/working/kaggle/working/julia-1.10.4/bin/julia -e 'using Pkg; Pkg.activate(\".\"); include(\"/kaggle/working/juliaenv/data_augamentation2.jl\")'","metadata":{"execution":{"iopub.status.busy":"2024-09-10T12:53:58.897644Z","iopub.execute_input":"2024-09-10T12:53:58.898142Z","iopub.status.idle":"2024-09-10T14:41:23.892234Z","shell.execute_reply.started":"2024-09-10T12:53:58.898094Z","shell.execute_reply":"2024-09-10T14:41:23.890232Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"import gc\n\n# 手动触发垃圾回收\ngc.collect()","metadata":{"execution":{"iopub.status.busy":"2024-09-10T14:41:24.006670Z","iopub.execute_input":"2024-09-10T14:41:24.007247Z","iopub.status.idle":"2024-09-10T14:41:24.094714Z","shell.execute_reply.started":"2024-09-10T14:41:24.007181Z","shell.execute_reply":"2024-09-10T14:41:24.093336Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"#執行結果\n!/kaggle/working/kaggle/working/julia-1.10.4/bin/julia -e  'using Pkg; Pkg.activate(\".\"); include(\"/kaggle/working/juliaenv/model/result4kaggle2.jl\")'","metadata":{"execution":{"iopub.status.busy":"2024-09-10T15:14:35.464435Z","iopub.execute_input":"2024-09-10T15:14:35.465685Z","iopub.status.idle":"2024-09-10T15:14:36.621518Z","shell.execute_reply.started":"2024-09-10T15:14:35.465634Z","shell.execute_reply":"2024-09-10T15:14:36.619981Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"#刪除部必要的檔案\n# 手动触发垃圾回收\n\n\nprint('刪除不必要的檔案')\n!rm -r /kaggle/working/kaggle/\n!rm -r /kaggle/working/juliaenv/\n!rm -r /kaggle/working/juliaenvRoot/\n!rm -r /kaggle/working/image_testrun/\n!rm -r /kaggle/working/output/\n\n\n\n","metadata":{"execution":{"iopub.status.busy":"2024-09-10T15:03:44.907425Z","iopub.execute_input":"2024-09-10T15:03:44.908369Z","iopub.status.idle":"2024-09-10T15:03:50.657649Z","shell.execute_reply.started":"2024-09-10T15:03:44.908293Z","shell.execute_reply":"2024-09-10T15:03:50.656186Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"!ls  /kaggle/working/","metadata":{"execution":{"iopub.status.busy":"2024-09-10T15:07:51.522624Z","iopub.execute_input":"2024-09-10T15:07:51.523200Z","iopub.status.idle":"2024-09-10T15:07:52.678235Z","shell.execute_reply.started":"2024-09-10T15:07:51.523155Z","shell.execute_reply":"2024-09-10T15:07:52.676607Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"#import pandas as pd\n#import os\n#df_sample = pd.read_csv('/kaggle/input/rsna-2024-lumbar-spine-degenerative-classification/sample_submission.csv')\n#print(os.path.exists('/kaggle/working/submission.csv'))\n#df_submission= pd.read_csv('/kaggle/working/submission.csv')\n# 根据 sample_submission 的 row_id 对用户的提交文件进行排序\n#df_submission_sorted = df_submission.set_index('row_id').reindex(df_sample['row_id']).reset_index()\n\n# 保存为新的提交文件\n#df_submission_sorted.to_csv('/kaggle/working/submission.csv', index=False)        \n\nimport gc\ngc.collect()                           \n\nprint('完成')","metadata":{"execution":{"iopub.status.busy":"2024-09-10T15:03:55.335084Z","iopub.execute_input":"2024-09-10T15:03:55.335612Z","iopub.status.idle":"2024-09-10T15:03:57.135969Z","shell.execute_reply.started":"2024-09-10T15:03:55.335553Z","shell.execute_reply":"2024-09-10T15:03:57.134060Z"},"trusted":true},"execution_count":null,"outputs":[]}]}