Skip to content

Commit

Permalink
small changes for pr
Browse files Browse the repository at this point in the history
  • Loading branch information
purnelldj committed Mar 17, 2024
1 parent a098b3f commit 69f79ba
Show file tree
Hide file tree
Showing 4 changed files with 186 additions and 12 deletions.
18 changes: 12 additions & 6 deletions src/conf/model/vitmae.yaml
Original file line number Diff line number Diff line change
@@ -1,13 +1,19 @@
_target_: models.vitmae.ViTMAEmodule
wandb_plots: False
# num_labels: 10
class_list: [
"AnnualCrop",
"Forest",
"HerbaceousVegetation",
"Highway",
"Industrial",
"Pasture",
"PermanentCrop",
"Residential",
"River",
"SeaLake",
]

net:
#net:
# _target_: transformers.ViTForImageClassification.from_pretrained
# pretrained_model_name_or_path: "google/vit-base-patch16-224"
# num_labels: 10
# ignore_mismatched_sizes: True

criterion:
_target_: torch.nn.CrossEntropyLoss
Expand Down
2 changes: 1 addition & 1 deletion src/conf/trainer/default.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ default_root_dir: ${output_dir}
min_epochs: 1 # prevents early stopping
# max_epochs: 50

accelerator: cpu
# accelerator: cpu
devices: 1

# mixed precision for extra speed-up
Expand Down
5 changes: 0 additions & 5 deletions src/conf/trainer/gpu.yaml

This file was deleted.

173 changes: 173 additions & 0 deletions traintest_colab.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,173 @@
{
"cells": [
{
"cell_type": "markdown",
"metadata": {
"id": "8Hn3VNXl-wea"
},
"source": [
"If you make any changes to files in drive you need to restart session (see the 'Runtime' menu) and then re-mount the drive.\n",
"\n",
"Alternatively you can make changes locally on a specific branch and then git clone the branch after making changes.\n",
"\n",
"Take advantage of GPU by setting Runtime to GPU."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/"
},
"id": "20Q9qbstc0aa",
"outputId": "f9a6b223-5f08-48a3-ec34-502c77aea2bd"
},
"outputs": [],
"source": [
"from google.colab import drive\n",
"drive.mount('/content/drive', force_remount=True)\n",
"%cd /content/drive/MyDrive/colab/ml_template\n",
"# ctrl click on path to open it to the left"
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "QSOU6HYz9vlE"
},
"source": [
"**Download data on drive**\n",
"\n",
"To access data efficiently need to upload it as a zip and then unzip to '/content'\n",
"\n",
"[link to issue on stack overflow.](https://stackoverflow.com/questions/59120853/google-colab-is-so-slow-while-reading-images-from-google-drive)\n",
"\n",
"Also need to set: 'datamodule.dir_parent=/content/'"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "zw0LHMDreU3K"
},
"outputs": [],
"source": [
"# for eurosat_rgb dataset\n",
"!unzip \"/content/drive/MyDrive/colab/ml_template/datasets/eurosat_rgb.zip\" -d \"/content\""
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "C7xLvON9aySI"
},
"outputs": [],
"source": [
"# for waterbodies dataset\n",
"!unzip \"/content/drive/MyDrive/colab/ml_template/datasets/waterbodies.zip\" -d \"/content\""
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "VTlqECwrc1zX"
},
"outputs": [],
"source": [
"!pip install -r reqs_colab.txt"
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "6ZHj1SI0_dbd"
},
"source": [
"**Log in to wandb**\n",
"\n",
"You do not need to log in if you set logger.mode=offline"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/",
"height": 121
},
"id": "GV8nh0vXd5Uu",
"outputId": "a80480df-f919-4ad1-ba00-3411cb940776"
},
"outputs": [],
"source": [
"import wandb\n",
"wandb.login()"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/"
},
"id": "oBTSjbjqkG0x",
"outputId": "a33b6bf6-7a00-41cf-b239-ee521e7d4e2a"
},
"outputs": [],
"source": [
"# double check that you are in the project directory:\n",
"%cd /content/drive/MyDrive/colab/ml_template"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "CyVRyQYkzPXo"
},
"outputs": [],
"source": [
"# to do: why are plots not showing? neither of these seem to work\n",
"# %matplotlib inline\n",
"# %matplotlib notebook"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/"
},
"id": "i4OrXFdNJeFB",
"outputId": "7e5d82dc-670a-4d3b-f08a-2de8c3d8d8ad"
},
"outputs": [],
"source": [
"!python src/traintest.py datamodule=eurosat_rgb model=cnn"
]
}
],
"metadata": {
"accelerator": "GPU",
"colab": {
"gpuType": "T4",
"provenance": []
},
"kernelspec": {
"display_name": "Python 3",
"name": "python3"
},
"language_info": {
"name": "python"
}
},
"nbformat": 4,
"nbformat_minor": 0
}

0 comments on commit 69f79ba

Please sign in to comment.