Loading

ROVER CLASSIFICATION

Notebook To Execute git code

I take advantage of Colab GPU after cloning the git repository

gfluz94

I take advantage of Colab GPU after cloning the git repository

In [ ]:
!git clone https://github.com/gfluz94/mars-rover-classification.git
Cloning into 'mars-rover-classification'...
remote: Enumerating objects: 47, done.
remote: Counting objects: 100% (47/47), done.
remote: Compressing objects: 100% (26/26), done.
remote: Total 47 (delta 22), reused 44 (delta 19), pack-reused 0
Unpacking objects: 100% (47/47), done.
In [ ]:
%cd mars-rover-classification/
/content/mars-rover-classification
In [ ]:
!ls
evaluation.py  main.py	 preprocessing.py  requirements.txt
LICENSE        model.py  README.md
In [ ]:
!python main.py --epochs 10 --batch_size 40 --num_neurons 1024 --learning_rate 0.0001 --threshold 0.4
2021-03-16 11:31:01.731712: I tensorflow/stream_executor/platform/default/dso_loader.cc:49] Successfully opened dynamic library libcudart.so.11.0
Adjusting directory structure...
Directory structure OK!!!

Downloading training, validation and test sets...
Files succesfully downloaded!!!

Organizing images and labels according to ImageGenerator input...
Preprocessing completed!!!

Preparing file streamer...
	Found 40000 images belonging to 2 classes.
	Found 4000 images belonging to 2 classes.
File streamer is ready!!!

Checking class labels:
	{'curiosity': 0, 'perseverance': 1}
	{'curiosity': 0, 'perseverance': 1}
2021-03-16 11:31:28.963916: I tensorflow/compiler/jit/xla_cpu_device.cc:41] Not creating XLA devices, tf_xla_enable_xla_devices not set
2021-03-16 11:31:28.965884: I tensorflow/stream_executor/platform/default/dso_loader.cc:49] Successfully opened dynamic library libcuda.so.1
2021-03-16 11:31:29.055200: I tensorflow/stream_executor/cuda/cuda_gpu_executor.cc:941] successful NUMA node read from SysFS had negative value (-1), but there must be at least one NUMA node, so returning NUMA node zero
2021-03-16 11:31:29.055871: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1720] Found device 0 with properties: 
pciBusID: 0000:00:04.0 name: Tesla T4 computeCapability: 7.5
coreClock: 1.59GHz coreCount: 40 deviceMemorySize: 14.75GiB deviceMemoryBandwidth: 298.08GiB/s
2021-03-16 11:31:29.055935: I tensorflow/stream_executor/platform/default/dso_loader.cc:49] Successfully opened dynamic library libcudart.so.11.0
2021-03-16 11:31:29.154824: I tensorflow/stream_executor/platform/default/dso_loader.cc:49] Successfully opened dynamic library libcublas.so.11
2021-03-16 11:31:29.154923: I tensorflow/stream_executor/platform/default/dso_loader.cc:49] Successfully opened dynamic library libcublasLt.so.11
2021-03-16 11:31:29.286017: I tensorflow/stream_executor/platform/default/dso_loader.cc:49] Successfully opened dynamic library libcufft.so.10
2021-03-16 11:31:29.337713: I tensorflow/stream_executor/platform/default/dso_loader.cc:49] Successfully opened dynamic library libcurand.so.10
2021-03-16 11:31:29.579057: I tensorflow/stream_executor/platform/default/dso_loader.cc:49] Successfully opened dynamic library libcusolver.so.10
2021-03-16 11:31:29.593483: I tensorflow/stream_executor/platform/default/dso_loader.cc:49] Successfully opened dynamic library libcusparse.so.11
2021-03-16 11:31:29.597510: I tensorflow/stream_executor/platform/default/dso_loader.cc:49] Successfully opened dynamic library libcudnn.so.8
2021-03-16 11:31:29.597689: I tensorflow/stream_executor/cuda/cuda_gpu_executor.cc:941] successful NUMA node read from SysFS had negative value (-1), but there must be at least one NUMA node, so returning NUMA node zero
2021-03-16 11:31:29.598346: I tensorflow/stream_executor/cuda/cuda_gpu_executor.cc:941] successful NUMA node read from SysFS had negative value (-1), but there must be at least one NUMA node, so returning NUMA node zero
2021-03-16 11:31:29.601343: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1862] Adding visible gpu devices: 0
2021-03-16 11:31:29.601810: I tensorflow/compiler/jit/xla_gpu_device.cc:99] Not creating XLA devices, tf_xla_enable_xla_devices not set
2021-03-16 11:31:29.601932: I tensorflow/stream_executor/cuda/cuda_gpu_executor.cc:941] successful NUMA node read from SysFS had negative value (-1), but there must be at least one NUMA node, so returning NUMA node zero
2021-03-16 11:31:29.602519: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1720] Found device 0 with properties: 
pciBusID: 0000:00:04.0 name: Tesla T4 computeCapability: 7.5
coreClock: 1.59GHz coreCount: 40 deviceMemorySize: 14.75GiB deviceMemoryBandwidth: 298.08GiB/s
2021-03-16 11:31:29.602556: I tensorflow/stream_executor/platform/default/dso_loader.cc:49] Successfully opened dynamic library libcudart.so.11.0
2021-03-16 11:31:29.602597: I tensorflow/stream_executor/platform/default/dso_loader.cc:49] Successfully opened dynamic library libcublas.so.11
2021-03-16 11:31:29.602638: I tensorflow/stream_executor/platform/default/dso_loader.cc:49] Successfully opened dynamic library libcublasLt.so.11
2021-03-16 11:31:29.602679: I tensorflow/stream_executor/platform/default/dso_loader.cc:49] Successfully opened dynamic library libcufft.so.10
2021-03-16 11:31:29.602708: I tensorflow/stream_executor/platform/default/dso_loader.cc:49] Successfully opened dynamic library libcurand.so.10
2021-03-16 11:31:29.602730: I tensorflow/stream_executor/platform/default/dso_loader.cc:49] Successfully opened dynamic library libcusolver.so.10
2021-03-16 11:31:29.602751: I tensorflow/stream_executor/platform/default/dso_loader.cc:49] Successfully opened dynamic library libcusparse.so.11
2021-03-16 11:31:29.602772: I tensorflow/stream_executor/platform/default/dso_loader.cc:49] Successfully opened dynamic library libcudnn.so.8
2021-03-16 11:31:29.602845: I tensorflow/stream_executor/cuda/cuda_gpu_executor.cc:941] successful NUMA node read from SysFS had negative value (-1), but there must be at least one NUMA node, so returning NUMA node zero
2021-03-16 11:31:29.603453: I tensorflow/stream_executor/cuda/cuda_gpu_executor.cc:941] successful NUMA node read from SysFS had negative value (-1), but there must be at least one NUMA node, so returning NUMA node zero
2021-03-16 11:31:29.604005: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1862] Adding visible gpu devices: 0
2021-03-16 11:31:29.637255: I tensorflow/stream_executor/platform/default/dso_loader.cc:49] Successfully opened dynamic library libcudart.so.11.0
2021-03-16 11:31:34.066373: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1261] Device interconnect StreamExecutor with strength 1 edge matrix:
2021-03-16 11:31:34.066422: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1267]      0 
2021-03-16 11:31:34.066438: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1280] 0:   N 
2021-03-16 11:31:34.069310: I tensorflow/stream_executor/cuda/cuda_gpu_executor.cc:941] successful NUMA node read from SysFS had negative value (-1), but there must be at least one NUMA node, so returning NUMA node zero
2021-03-16 11:31:34.069987: I tensorflow/stream_executor/cuda/cuda_gpu_executor.cc:941] successful NUMA node read from SysFS had negative value (-1), but there must be at least one NUMA node, so returning NUMA node zero
2021-03-16 11:31:34.070570: I tensorflow/stream_executor/cuda/cuda_gpu_executor.cc:941] successful NUMA node read from SysFS had negative value (-1), but there must be at least one NUMA node, so returning NUMA node zero
2021-03-16 11:31:34.071076: W tensorflow/core/common_runtime/gpu/gpu_bfc_allocator.cc:39] Overriding allow_growth setting because the TF_FORCE_GPU_ALLOW_GROWTH environment variable is set. Original config value was 0.
2021-03-16 11:31:34.071126: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1406] Created TensorFlow device (/job:localhost/replica:0/task:0/device:GPU:0 with 13994 MB memory) -> physical GPU (device: 0, name: Tesla T4, pci bus id: 0000:00:04.0, compute capability: 7.5)
Last layer output shape:  (None, 14, 14, 768)
2021-03-16 11:31:36.659969: I tensorflow/compiler/mlir/mlir_graph_optimization_pass.cc:116] None of the MLIR optimization passes are enabled (registered 2)
2021-03-16 11:31:36.662168: I tensorflow/core/platform/profile_utils/cpu_utils.cc:112] CPU Frequency: 2199995000 Hz
Epoch 1/6
2021-03-16 11:31:39.249076: I tensorflow/stream_executor/platform/default/dso_loader.cc:49] Successfully opened dynamic library libcublas.so.11
2021-03-16 11:31:41.825262: I tensorflow/stream_executor/platform/default/dso_loader.cc:49] Successfully opened dynamic library libcublasLt.so.11
2021-03-16 11:31:41.882593: I tensorflow/stream_executor/platform/default/dso_loader.cc:49] Successfully opened dynamic library libcudnn.so.8
1000/1000 [==============================] - 614s 579ms/step - loss: 0.4647 - acc: 0.7972 - val_loss: 0.1396 - val_acc: 0.9492
Epoch 2/6
1000/1000 [==============================] - 575s 575ms/step - loss: 0.1937 - acc: 0.9216 - val_loss: 0.1386 - val_acc: 0.9425
Epoch 3/6
1000/1000 [==============================] - 573s 573ms/step - loss: 0.1666 - acc: 0.9325 - val_loss: 0.0986 - val_acc: 0.9610
Epoch 4/6
1000/1000 [==============================] - 580s 579ms/step - loss: 0.1527 - acc: 0.9380 - val_loss: 0.1041 - val_acc: 0.9610
Epoch 5/6
1000/1000 [==============================] - 579s 579ms/step - loss: 0.1429 - acc: 0.9410 - val_loss: 0.0998 - val_acc: 0.9580
Epoch 6/6
1000/1000 [==============================] - 581s 581ms/step - loss: 0.1409 - acc: 0.9443 - val_loss: 0.0900 - val_acc: 0.9655
Found 4000 images belonging to 2 classes.
>> Evaluating model on validation set:

              Accuracy  ...   AUC-ROC
InceptionNet    0.9655  ...  0.995711

[1 rows x 5 columns]
<Figure size 1200x1000 with 4 Axes>
Found 10000 images belonging to 1 classes.
Output file succesfully saved in `output/submission.csv`

In [ ]:
from model import build_inception_net, get_prediction_generator
from evaluation import evaluate
In [ ]:
model, _ = build_inception_net()
Last layer output shape:  (None, 14, 14, 768)
In [ ]:
model.load_weights("./log/mars-rover-06.hdf5")
In [ ]:
val_gen = get_prediction_generator("./dataset/val")
Found 4000 images belonging to 2 classes.
In [ ]:
y_proba = model.predict(val_gen)
y_pred = 1*(y_proba>0.4)

evaluate(val_gen.labels, y_pred, y_proba)
Out[ ]:
Accuracy Recall Precision F1-Score AUC-ROC
InceptionNet 0.9655 0.946356 0.983176 0.964415 0.995711

Comments

You must login before you can post a comment.

Execute