Spaces:
Runtime error
Runtime error
Commit
·
82f856d
1
Parent(s):
8a74fe1
set seed
Browse files
kaggle/kernel-metadata.json
CHANGED
@@ -1,6 +1,5 @@
|
|
1 |
{
|
2 |
"id": "anujpanthri/train-image-colorization",
|
3 |
-
"id_no":345,
|
4 |
"title": "training-image-colorization-model",
|
5 |
"code_file": "train-image-colorization.ipynb",
|
6 |
"language": "python",
|
|
|
1 |
{
|
2 |
"id": "anujpanthri/train-image-colorization",
|
|
|
3 |
"title": "training-image-colorization-model",
|
4 |
"code_file": "train-image-colorization.ipynb",
|
5 |
"language": "python",
|
kaggle/train-image-colorization.ipynb
CHANGED
@@ -1,55 +1 @@
|
|
1 |
-
{
|
2 |
-
"cells": [
|
3 |
-
{
|
4 |
-
"cell_type": "code",
|
5 |
-
"execution_count": null,
|
6 |
-
"metadata": {},
|
7 |
-
"outputs": [],
|
8 |
-
"source": [
|
9 |
-
"!git clone https://github.com/AnujPanthri/Image-Colorization.git\n",
|
10 |
-
"%cd Image-Colorization"
|
11 |
-
]
|
12 |
-
},
|
13 |
-
{
|
14 |
-
"cell_type": "code",
|
15 |
-
"execution_count": null,
|
16 |
-
"metadata": {},
|
17 |
-
"outputs": [],
|
18 |
-
"source": [
|
19 |
-
"!pip install -r requirements.txt --quiet\n",
|
20 |
-
"!pip install -e ."
|
21 |
-
]
|
22 |
-
},
|
23 |
-
{
|
24 |
-
"cell_type": "code",
|
25 |
-
"execution_count": null,
|
26 |
-
"metadata": {},
|
27 |
-
"outputs": [],
|
28 |
-
"source": [
|
29 |
-
"!python3 src/scripts/train.py configs/experiment1.yaml"
|
30 |
-
]
|
31 |
-
},
|
32 |
-
{
|
33 |
-
"cell_type": "code",
|
34 |
-
"execution_count": null,
|
35 |
-
"metadata": {},
|
36 |
-
"outputs": [],
|
37 |
-
"source": [
|
38 |
-
"!python3 src/scripts/visualize_results.py configs/experiment1.yaml"
|
39 |
-
]
|
40 |
-
}
|
41 |
-
],
|
42 |
-
"metadata": {
|
43 |
-
"kernelspec": {
|
44 |
-
"display_name": "Python 3",
|
45 |
-
"language": "python",
|
46 |
-
"name": "python3"
|
47 |
-
},
|
48 |
-
"language_info": {
|
49 |
-
"name": "python",
|
50 |
-
"version": "3.12.1"
|
51 |
-
}
|
52 |
-
},
|
53 |
-
"nbformat": 4,
|
54 |
-
"nbformat_minor": 2
|
55 |
-
}
|
|
|
1 |
+
{"metadata":{"kernelspec":{"display_name":"Python 3","language":"python","name":"python3"},"language_info":{"name":"python","version":"3.10.13","mimetype":"text/x-python","codemirror_mode":{"name":"ipython","version":3},"pygments_lexer":"ipython3","nbconvert_exporter":"python","file_extension":".py"},"kaggle":{"accelerator":"none","dataSources":[],"dockerImageVersionId":30698,"isInternetEnabled":true,"language":"python","sourceType":"notebook","isGpuEnabled":false}},"nbformat_minor":4,"nbformat":4,"cells":[{"cell_type":"code","source":"!git clone https://github.com/AnujPanthri/Image-Colorization.git\n%cd Image-Colorization","metadata":{"execution":{"iopub.status.busy":"2024-05-07T05:57:35.422571Z","iopub.execute_input":"2024-05-07T05:57:35.423893Z","iopub.status.idle":"2024-05-07T05:57:37.744423Z","shell.execute_reply.started":"2024-05-07T05:57:35.423838Z","shell.execute_reply":"2024-05-07T05:57:37.743082Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# %cd ..\n# !rm -r Image-Colorization","metadata":{"execution":{"iopub.status.busy":"2024-05-07T05:57:38.982736Z","iopub.execute_input":"2024-05-07T05:57:38.983147Z","iopub.status.idle":"2024-05-07T05:57:38.989575Z","shell.execute_reply.started":"2024-05-07T05:57:38.983115Z","shell.execute_reply":"2024-05-07T05:57:38.987925Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"!pip install -r requirements.txt --quiet\n!pip install -e .","metadata":{"execution":{"iopub.status.busy":"2024-05-07T05:57:39.454444Z","iopub.execute_input":"2024-05-07T05:57:39.454828Z","iopub.status.idle":"2024-05-07T05:58:13.154377Z","shell.execute_reply.started":"2024-05-07T05:57:39.4548Z","shell.execute_reply":"2024-05-07T05:58:13.152964Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"from kaggle_secrets import UserSecretsClient\nuser_secrets = UserSecretsClient()\nCOMET_API_KEY = user_secrets.get_secret(\"comet_api_key\")\n\n!export COMET_API_KEY={COMET_API_KEY}","metadata":{"execution":{"iopub.status.busy":"2024-05-07T05:58:13.157513Z","iopub.execute_input":"2024-05-07T05:58:13.15798Z","iopub.status.idle":"2024-05-07T05:58:14.401676Z","shell.execute_reply.started":"2024-05-07T05:58:13.157935Z","shell.execute_reply":"2024-05-07T05:58:14.400055Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"import os\n\nos.environ[\"COMET_API_KEY\"]=COMET_API_KEY\nconfig_file = \"configs/experiment1.yaml\"","metadata":{"execution":{"iopub.status.busy":"2024-05-07T05:58:14.412023Z","iopub.execute_input":"2024-05-07T05:58:14.412388Z","iopub.status.idle":"2024-05-07T05:58:14.422002Z","shell.execute_reply.started":"2024-05-07T05:58:14.41236Z","shell.execute_reply":"2024-05-07T05:58:14.420946Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"!python3 src/scripts/prepare_dataset.py {config_file}","metadata":{"execution":{"iopub.status.busy":"2024-05-07T05:58:14.423359Z","iopub.execute_input":"2024-05-07T05:58:14.423858Z","iopub.status.idle":"2024-05-07T05:58:20.695681Z","shell.execute_reply.started":"2024-05-07T05:58:14.423828Z","shell.execute_reply":"2024-05-07T05:58:20.694312Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# !cat src/utils/data_utils.py","metadata":{"execution":{"iopub.status.busy":"2024-05-07T05:58:20.697592Z","iopub.execute_input":"2024-05-07T05:58:20.697948Z","iopub.status.idle":"2024-05-07T05:58:20.703728Z","shell.execute_reply.started":"2024-05-07T05:58:20.697915Z","shell.execute_reply":"2024-05-07T05:58:20.702527Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# !python3 src/scripts/visualize_dataset.py {config_file}","metadata":{"execution":{"iopub.status.busy":"2024-05-07T05:58:24.072343Z","iopub.execute_input":"2024-05-07T05:58:24.072758Z","iopub.status.idle":"2024-05-07T05:58:27.518713Z","shell.execute_reply.started":"2024-05-07T05:58:24.072725Z","shell.execute_reply":"2024-05-07T05:58:27.517194Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"!python3 src/scripts/train.py {config_file}","metadata":{"execution":{"iopub.status.busy":"2024-05-07T05:58:41.523307Z","iopub.execute_input":"2024-05-07T05:58:41.523718Z","iopub.status.idle":"2024-05-07T06:03:03.088039Z","shell.execute_reply.started":"2024-05-07T05:58:41.523683Z","shell.execute_reply":"2024-05-07T06:03:03.086519Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# !python3 src/scripts/visualize_results.py {config_file}","metadata":{"execution":{"iopub.status.busy":"2024-05-07T06:03:34.594725Z","iopub.execute_input":"2024-05-07T06:03:34.595185Z","iopub.status.idle":"2024-05-07T06:03:46.842693Z","shell.execute_reply.started":"2024-05-07T06:03:34.595147Z","shell.execute_reply":"2024-05-07T06:03:46.841521Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"","metadata":{},"execution_count":null,"outputs":[]}]}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
src/scripts/train.py
CHANGED
@@ -3,6 +3,7 @@ import argparse
|
|
3 |
from comet_ml import Experiment
|
4 |
from src.utils.config_loader import Config
|
5 |
from src.utils import config_loader
|
|
|
6 |
from src.utils.script_utils import validate_config
|
7 |
import importlib
|
8 |
from pathlib import Path
|
@@ -47,6 +48,8 @@ def train(args):
|
|
47 |
if "LOCAL_SYSTEM" not in os.environ:
|
48 |
experiment.log_model(f"{config.task}_{config.dataset}_{config.model}",model_save_path)
|
49 |
|
|
|
|
|
50 |
metrics = model.evaluate()
|
51 |
print("Model Evaluation Metrics:",metrics)
|
52 |
|
|
|
3 |
from comet_ml import Experiment
|
4 |
from src.utils.config_loader import Config
|
5 |
from src.utils import config_loader
|
6 |
+
from src.utils.data_utils import print_title
|
7 |
from src.utils.script_utils import validate_config
|
8 |
import importlib
|
9 |
from pathlib import Path
|
|
|
48 |
if "LOCAL_SYSTEM" not in os.environ:
|
49 |
experiment.log_model(f"{config.task}_{config.dataset}_{config.model}",model_save_path)
|
50 |
|
51 |
+
# evaluate model
|
52 |
+
print_title("\nEvaluating Model")
|
53 |
metrics = model.evaluate()
|
54 |
print("Model Evaluation Metrics:",metrics)
|
55 |
|
src/simple_regression_colorization/model/dataloaders.py
CHANGED
@@ -19,7 +19,7 @@ def get_datasets():
|
|
19 |
|
20 |
train_paths,val_paths = sklearn.model_selection.train_test_split(trainval_paths,
|
21 |
train_size=0.8,
|
22 |
-
random_state=
|
23 |
|
24 |
print("train|val|test:",len(train_paths),"|",len(val_paths),"|",len(test_paths))
|
25 |
|
@@ -53,7 +53,7 @@ def load_img(img_path):
|
|
53 |
|
54 |
def get_tf_ds(image_paths,bs=8,shuffle=False,is_val=False):
|
55 |
ds = tf.data.Dataset.from_tensor_slices(image_paths)
|
56 |
-
if shuffle: ds = ds.shuffle(len(image_paths))
|
57 |
ds = ds.map(load_img,num_parallel_calls=tf.data.AUTOTUNE)
|
58 |
ds = ds.batch(bs,num_parallel_calls=tf.data.AUTOTUNE,drop_remainder=not is_val)
|
59 |
|
|
|
19 |
|
20 |
train_paths,val_paths = sklearn.model_selection.train_test_split(trainval_paths,
|
21 |
train_size=0.8,
|
22 |
+
random_state=config.seed)
|
23 |
|
24 |
print("train|val|test:",len(train_paths),"|",len(val_paths),"|",len(test_paths))
|
25 |
|
|
|
53 |
|
54 |
def get_tf_ds(image_paths,bs=8,shuffle=False,is_val=False):
|
55 |
ds = tf.data.Dataset.from_tensor_slices(image_paths)
|
56 |
+
if shuffle: ds = ds.shuffle(len(image_paths),seed=config.seed)
|
57 |
ds = ds.map(load_img,num_parallel_calls=tf.data.AUTOTUNE)
|
58 |
ds = ds.batch(bs,num_parallel_calls=tf.data.AUTOTUNE,drop_remainder=not is_val)
|
59 |
|