DDColor icon indicating copy to clipboard operation
DDColor copied to clipboard

question about training

Open lecanhduc02 opened this issue 1 year ago • 3 comments

How to train by google colab?

lecanhduc02 avatar May 07 '24 06:05 lecanhduc02

Hi @lecanhduc02 , currently we do not have the code for colab training. Here is a colab example of inference that might be helpful:https://github.com/camenduru/DDColor-colab

piddnad avatar May 08 '24 07:05 piddnad

I found this code on https://modelscope.cn/models/iic/cv_ddcolor_image-colorization/summary. Can it be used for training? import os import tempfile

from modelscope.hub.snapshot_download import snapshot_download from modelscope.msdatasets import MsDataset from modelscope.msdatasets.dataset_cls.custom_datasets.image_colorization import
ImageColorizationDataset from modelscope.trainers import build_trainer from modelscope.utils.config import Config from modelscope.utils.constant import DownloadMode, ModelFile

tmp_dir = tempfile.TemporaryDirectory().name if not os.path.exists(tmp_dir): os.makedirs(tmp_dir) model_id = 'damo/cv_ddcolor_image-colorization' cache_path = snapshot_download(model_id) config = Config.from_file( os.path.join(cache_path, ModelFile.CONFIGURATION))

dataset_train = MsDataset.load( 'imagenet-val5k-image', namespace='damo', subset_name='default', split='validation', download_mode=DownloadMode.REUSE_DATASET_IF_EXISTS)._hf_ds dataset_val = MsDataset.load( 'imagenet-val5k-image', namespace='damo', subset_name='default', split='validation', download_mode=DownloadMode.REUSE_DATASET_IF_EXISTS)._hf_ds

dataset_train = ImageColorizationDataset( dataset_train, config.dataset, is_train=True) dataset_val = ImageColorizationDataset( dataset_val, config.dataset, is_train=False)

kwargs = dict( model=model_id, train_dataset=dataset_train, eval_dataset=dataset_val, work_dir=tmp_dir) trainer = build_trainer(default_args=kwargs) trainer.train()

lecanhduc02 avatar May 08 '24 15:05 lecanhduc02

Yes, it is possible to use the modelscope library for training. However, the reliability of this method (i.e., the alignment of the final results with our model results) is not guaranteed, as our model training was completed through the training code provided in this repository.

piddnad avatar May 10 '24 06:05 piddnad