diff --git a/Machine_Learning/notebook.ipynb b/Machine_Learning/notebook.ipynb index 793bf30..d863e0a 100644 --- a/Machine_Learning/notebook.ipynb +++ b/Machine_Learning/notebook.ipynb @@ -170,7 +170,7 @@ "outputId": "30228ce8-1b64-47f5-93f7-30632b2af1c5" }, "outputs": [], - "source": "if IS_COLAB:\n drive.mount('/content/drive')\n archive_path = '/content/drive/MyDrive/jagung/dataset_jagung.zip'\n destination_path = '/content/dataset_jagung.zip'\n extract_path = '/content/dataset'\nelse:\n # Local: dataset assumed at Machine_Learning/dataset_jagung.zip\n base = os.getcwd()\n archive_path = os.path.join(base, 'dataset_jagung.zip')\n destination_path = archive_path # no copy needed\n extract_path = os.path.join(base, 'dataset')\n\nif os.path.exists(archive_path):\n if not IS_COLAB:\n print(f\"Found dataset at {archive_path}\")\n else:\n print(\"Moving ZIP file to /content...\")\n shutil.copy(archive_path, destination_path)\n print(\"File successfully moved.\")\nelse:\n print(f\"Error: File not found at {archive_path}\")\n\nif os.path.exists(destination_path):\n if not os.path.exists(extract_path) or len(os.listdir(extract_path)) == 0:\n os.makedirs(extract_path, exist_ok=True)\n print(\"Extracting dataset...\")\n try:\n with zipfile.ZipFile(destination_path, 'r') as zip_ref:\n zip_ref.extractall(path=extract_path)\n print(\"Extraction completed!\")\n except Exception as e:\n print(f\"Extraction failed: {e}\")\n else:\n print(\"Dataset is already extracted and ready for use.\")" + "source": "if IS_COLAB:\n drive.mount('/content/drive')\n archive_path = '/content/drive/MyDrive/jagung/dataset_jagung.zip'\n destination_path = '/content/dataset_jagung.zip'\n extract_path = '/content/dataset'\nelse:\n import gdown\n base = os.getcwd()\n archive_path = os.path.join(base, 'dataset_jagung.zip')\n destination_path = archive_path\n extract_path = os.path.join(base, 'dataset')\n # If dataset doesn't exist locally, download from Google Drive\n DRIVE_FILE_ID = \"1iP1J5o-wJZXslI21TF0H9txNvFgV0tFZ\"\n if not os.path.exists(archive_path):\n print(\"Dataset not found locally. Downloading from Google Drive...\")\n try:\n gdown.download(f\"https://drive.google.com/uc?id={DRIVE_FILE_ID}\", archive_path, quiet=False)\n except Exception as e:\n print(f\"Download failed: {e}\")\n\nif os.path.exists(destination_path):\n if not os.path.exists(extract_path) or len(os.listdir(extract_path)) == 0:\n os.makedirs(extract_path, exist_ok=True)\n print(\"Extracting dataset...\")\n try:\n with zipfile.ZipFile(destination_path, 'r') as zip_ref:\n zip_ref.extractall(path=extract_path)\n print(\"Extraction completed!\")\n except Exception as e:\n print(f\"Extraction failed: {e}\")\n else:\n print(\"Dataset is already extracted and ready for use.\")" }, { "cell_type": "markdown", diff --git a/Machine_Learning/requirements.txt b/Machine_Learning/requirements.txt index 5ba1f16..a1feaaf 100644 --- a/Machine_Learning/requirements.txt +++ b/Machine_Learning/requirements.txt @@ -1,5 +1,6 @@ tensorflow==2.19.0 # CPU + Colab; for local GPU, install tensorflow[and-cuda] tensorflowjs==4.22.0 +gdown # download dataset from Google Drive numpy matplotlib seaborn