From 652a29650aa137c84786ef62ef9b0489ee413449 Mon Sep 17 00:00:00 2001 From: Erez Date: Sun, 16 May 2021 14:37:04 +0300 Subject: [PATCH] Remove old model upload examples --- .../frameworks/keras/manual_model_upload.py | 55 ------------------- .../frameworks/pytorch/manual_model_upload.py | 44 --------------- .../tensorflow/manual_model_upload.py | 45 --------------- 3 files changed, 144 deletions(-) delete mode 100644 examples/frameworks/keras/manual_model_upload.py delete mode 100644 examples/frameworks/pytorch/manual_model_upload.py delete mode 100644 examples/frameworks/tensorflow/manual_model_upload.py diff --git a/examples/frameworks/keras/manual_model_upload.py b/examples/frameworks/keras/manual_model_upload.py deleted file mode 100644 index 7aec6518..00000000 --- a/examples/frameworks/keras/manual_model_upload.py +++ /dev/null @@ -1,55 +0,0 @@ -# ClearML - Example of manual model configuration and uploading -# -import os -from tempfile import gettempdir - -from tensorflow.keras import Input, layers, Model - -from clearml import Task - -# Connecting ClearML with the current process, -# from here on everything is logged automatically -task = Task.init(project_name='examples', task_name='Model configuration and upload') - - -def get_model(): - # Create a simple model. - inputs = Input(shape=(32,)) - outputs = layers.Dense(1)(inputs) - keras_model = Model(inputs, outputs) - keras_model.compile(optimizer='adam', loss='mean_squared_error') - return keras_model - - -# create a model -model = get_model() - -# Connect a local configuration file -config_file = os.path.join('..', '..', 'reporting', 'data_samples', 'sample.json') -config_file = task.connect_configuration(config_file) -# then read configuration as usual, the backend will contain a copy of it. -# later when executing remotely, the returned `config_file` will be a temporary file -# containing a new copy of the configuration retrieved form the backend -# # model_config_dict = json.load(open(config_file, 'rt')) - -# Or Store dictionary of definition for a specific network design -model_config_dict = { - 'value': 13.37, - 'dict': {'sub_value': 'string', 'sub_integer': 11}, - 'list_of_ints': [1, 2, 3, 4], -} -model_config_dict = task.connect_configuration(model_config_dict) - -# We now update the dictionary after connecting it, and the changes will be tracked as well. -model_config_dict['new value'] = 10 -model_config_dict['value'] *= model_config_dict['new value'] - -# store the label enumeration of the training model -labels = {'background': 0, 'cat': 1, 'dog': 2} -task.connect_label_enumeration(labels) - -# storing the model, it will have the task network configuration and label enumeration -print('Any model stored from this point onwards, will contain both model_config and label_enumeration') - -model.save(os.path.join(gettempdir(), "model")) -print('Model saved') diff --git a/examples/frameworks/pytorch/manual_model_upload.py b/examples/frameworks/pytorch/manual_model_upload.py deleted file mode 100644 index a6f6a986..00000000 --- a/examples/frameworks/pytorch/manual_model_upload.py +++ /dev/null @@ -1,44 +0,0 @@ -# ClearML - Example of manual model configuration and uploading -# -import os -from tempfile import gettempdir - -import torch -from clearml import Task - -# Connecting ClearML with the current process, -# from here on everything is logged automatically -task = Task.init(project_name='examples', task_name='Model configuration and upload') - -# create a model -model = torch.nn.Module - -# Connect a local configuration file -config_file = os.path.join('..', '..', 'reporting', 'data_samples', 'sample.json') -config_file = task.connect_configuration(config_file) -# then read configuration as usual, the backend will contain a copy of it. -# later when executing remotely, the returned `config_file` will be a temporary file -# containing a new copy of the configuration retrieved form the backend -# # model_config_dict = json.load(open(config_file, 'rt')) - -# Or Store dictionary of definition for a specific network design -model_config_dict = { - 'value': 13.37, - 'dict': {'sub_value': 'string', 'sub_integer': 11}, - 'list_of_ints': [1, 2, 3, 4], -} -model_config_dict = task.connect_configuration(model_config_dict) - -# We now update the dictionary after connecting it, and the changes will be tracked as well. -model_config_dict['new value'] = 10 -model_config_dict['value'] *= model_config_dict['new value'] - -# store the label enumeration of the training model -labels = {'background': 0, 'cat': 1, 'dog': 2} -task.connect_label_enumeration(labels) - -# storing the model, it will have the task network configuration and label enumeration -print('Any model stored from this point onwards, will contain both model_config and label_enumeration') - -torch.save(model, os.path.join(gettempdir(), "model.pt")) -print('Model saved') diff --git a/examples/frameworks/tensorflow/manual_model_upload.py b/examples/frameworks/tensorflow/manual_model_upload.py deleted file mode 100644 index f05508f8..00000000 --- a/examples/frameworks/tensorflow/manual_model_upload.py +++ /dev/null @@ -1,45 +0,0 @@ -# ClearML - Example of manual model configuration and uploading -# -import os -import tempfile - -import tensorflow as tf -from clearml import Task - - -# Connecting ClearML with the current process, -# from here on everything is logged automatically -task = Task.init(project_name='examples', task_name='Model configuration and upload') - -model = tf.Module() - -# Connect a local configuration file -config_file = os.path.join('..', '..', 'reporting', 'data_samples', 'sample.json') -config_file = task.connect_configuration(config_file) -# then read configuration as usual, the backend will contain a copy of it. -# later when executing remotely, the returned `config_file` will be a temporary file -# containing a new copy of the configuration retrieved form the backend -# # model_config_dict = json.load(open(config_file, 'rt')) - -# Or Store dictionary of definition for a specific network design -model_config_dict = { - 'value': 13.37, - 'dict': {'sub_value': 'string', 'sub_integer': 11}, - 'list_of_ints': [1, 2, 3, 4], -} -model_config_dict = task.connect_configuration(model_config_dict) - -# We now update the dictionary after connecting it, and the changes will be tracked as well. -model_config_dict['new value'] = 10 -model_config_dict['value'] *= model_config_dict['new value'] - -# store the label enumeration of the training model -labels = {'background': 0, 'cat': 1, 'dog': 2} -task.connect_label_enumeration(labels) - -# storing the model, it will have the task network configuration and label enumeration -print('Any model stored from this point onwards, will contain both model_config and label_enumeration') - -tempdir = tempfile.mkdtemp() -tf.saved_model.save(model, os.path.join(tempdir, "model")) -print('Model saved')