tellurion-kanata / colorizeDiffusion

Implementation of ColorizeDiffusion
23 stars 1 forks source link

FileNotFoundError: [Errno 2] No such file or directory: 'pretrained_models/anime2sketch.pth' #2

Closed zhenglinpan closed 9 months ago

zhenglinpan commented 9 months ago

Hi there. Thanks for the contribution, your work is impressive. 👍

When I executed the gradio_ui.py, it raised an error that said anime2skecth.pth was not found.

I did not find this pre-trained model on hugging face, could you upload it to the working space?

You help is much appreciated.

zhenglinpan commented 9 months ago

Here's complete log for your information.

+--------------------- Traceback (most recent call last) ---------------------+
| d:\Anita\colorizeDiffusion\gradio_ui.py:130 in load_model                   |
|                                                                             |
|   127                 if not initialize and model.type == configs["model"][ |
|   128                     model.init_from_ckpt(configs["model"]["params"][" |
|   129                 else:                                                 |
| > 130                     model = utils.instantiate_from_config(configs["mo |
|   131             model.name = model_name                                   |
|   132         gr.Textbox("Loaded model successfully.")                      |
|   133         return f"## ColorizeDiffusion, current model: {model.name}"   |
|                                                                             |
| d:\Anita\colorizeDiffusion\utils.py:26 in instantiate_from_config           |
|                                                                             |
|   23         elif config == "__is_unconditional__":                         |
|   24             return None                                                |
|   25         raise KeyError("Expected key `target` to instantiate.")        |
| > 26     return get_obj_from_str(config["target"])(**config.get("params", d |
|   27                                                                        |
|   28                                                                        |
|   29 def get_obj_from_str(string, reload=False):                            |
|                                                                             |
| d:\Anita\colorizeDiffusion\models\wrapper.py:172 in __init__                |
|                                                                             |
|   169         super().__init__(*args, **kwargs)                             |
|   170         self.hook_unet = UnetHook()                                   |
|   171         self.type = type                                              |
| > 172         self.preprocessor = create_model().eval()                     |
|   173         self.noise_level = 0.                                         |
|   174         self.switch_to_fp16()                                         |
|   175                                                                       |
|                                                                             |
| d:\Anita\colorizeDiffusion\preprocessor\anime2sketch.py:110 in create_model |
|                                                                             |
|   107     """                                                               |
|   108     norm_layer = functools.partial(nn.InstanceNorm2d, affine=False, t |
|   109     net = UnetGenerator(3, 1, 8, 64, norm_layer=norm_layer, use_dropo |
| > 110     ckpt = torch.load('pretrained_models/anime2sketch.pth')           |
|   111     for key in list(ckpt.keys()):                                     |
|   112         if 'module.' in key:                                          |
|   113             ckpt[key.replace('module.', '')] = ckpt[key]              |
|                                                                             |
| D:\Python310\lib\site-packages\torch\serialization.py:771 in load           |
|                                                                             |
|    768     if 'encoding' not in pickle_load_args.keys():                    |
|    769         pickle_load_args['encoding'] = 'utf-8'                       |
|    770                                                                      |
| >  771     with _open_file_like(f, 'rb') as opened_file:                    |
|    772         if _is_zipfile(opened_file):                                 |
|    773             # The zipfile reader is going to advance the current fil |
|    774             # If we want to actually tail call to torch.jit.load, we |
|                                                                             |
| D:\Python310\lib\site-packages\torch\serialization.py:270 in                |
| _open_file_like                                                             |
|                                                                             |
|    267                                                                      |
|    268 def _open_file_like(name_or_buffer, mode):                           |
|    269     if _is_path(name_or_buffer):                                     |
| >  270         return _open_file(name_or_buffer, mode)                      |
|    271     else:                                                            |
|    272         if 'w' in mode:                                              |
|    273             return _open_buffer_writer(name_or_buffer)               |
|                                                                             |
| D:\Python310\lib\site-packages\torch\serialization.py:251 in __init__       |
|                                                                             |
|    248                                                                      |
|    249 class _open_file(_opener):                                           |
|    250     def __init__(self, name, mode):                                  |
| >  251         super(_open_file, self).__init__(open(name, mode))           |
|    252                                                                      |
|    253     def __exit__(self, *args):                                       |
|    254         self.file_like.close()                                       |
+-----------------------------------------------------------------------------+
FileNotFoundError: [Errno 2] No such file or directory: 
'pretrained_models/anime2sketch.pth'
tellurion-kanata commented 9 months ago

this model is available on github https://github.com/Mukosame/Anime2Sketch

On Tue, Jan 23, 2024 at 9:12 AM zhenglin @.***> wrote:

Here's complete log for your information.

+--------------------- Traceback (most recent call last) ---------------------+| d:\Anita\colorizeDiffusion\gradio_ui.py:130 in load_model || || 127 if not initialize and model.type == configs["model"][ || 128 model.init_from_ckpt(configs["model"]["params"][" || 129 else: || > 130 model = utils.instantiate_from_config(configs["mo || 131 model.name = model_name || 132 gr.Textbox("Loaded model successfully.") || 133 return f"## ColorizeDiffusion, current model: {model.name}" || || d:\Anita\colorizeDiffusion\utils.py:26 in instantiate_from_config || || 23 elif config == "is_unconditional": || 24 return None || 25 raise KeyError("Expected key target to instantiate.") || > 26 return get_obj_from_str(config["target"])(**config.get("params", d || 27 || 28 || 29 def get_obj_from_str(string, reload=False): || || d:\Anita\colorizeDiffusion\models\wrapper.py:172 in init || || 169 super().init__(*args, **kwargs) || 170 self.hook_unet = UnetHook() || 171 self.type = type || > 172 self.preprocessor = create_model().eval() || 173 self.noise_level = 0. || 174 self.switch_to_fp16() || 175 || || d:\Anita\colorizeDiffusion\preprocessor\anime2sketch.py:110 in create_model || || 107 """ || 108 norm_layer = functools.partial(nn.InstanceNorm2d, affine=False, t || 109 net = UnetGenerator(3, 1, 8, 64, norm_layer=norm_layer, use_dropo || > 110 ckpt = torch.load('pretrained_models/anime2sketch.pth') || 111 for key in list(ckpt.keys()): || 112 if 'module.' in key: || 113 ckpt[key.replace('module.', '')] = ckpt[key] || || D:\Python310\lib\site-packages\torch\serialization.py:771 in load || || 768 if 'encoding' not in pickle_load_args.keys(): || 769 pickle_load_args['encoding'] = 'utf-8' || 770 || > 771 with _open_file_like(f, 'rb') as opened_file: || 772 if _is_zipfile(opened_file): || 773 # The zipfile reader is going to advance the current fil || 774 # If we want to actually tail call to torch.jit.load, we || || D:\Python310\lib\site-packages\torch\serialization.py:270 in || _open_file_like || || 267 || 268 def _open_file_like(name_or_buffer, mode): || 269 if _is_path(name_or_buffer): || > 270 return _open_file(name_or_buffer, mode) || 271 else: || 272 if 'w' in mode: || 273 return _open_buffer_writer(name_or_buffer) || || D:\Python310\lib\site-packages\torch\serialization.py:251 in init__ || || 248 || 249 class _open_file(_opener): || 250 def init(self, name, mode): || > 251 super(_open_file, self).init(open(name, mode)) || 252 || 253 def exit(self, *args): || 254 self.file_like.close() |+-----------------------------------------------------------------------------+FileNotFoundError: [Errno 2] No such file or directory: 'pretrained_models/anime2sketch.pth'

— Reply to this email directly, view it on GitHub https://github.com/ydk-tellurion/colorizeDiffusion/issues/2#issuecomment-1905060484, or unsubscribe https://github.com/notifications/unsubscribe-auth/AGL2YJ7LV475EEZ4FYRJK73YP357ZAVCNFSM6AAAAABCGCGEX6VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTSMBVGA3DANBYGQ . You are receiving this because you are subscribed to this thread.Message ID: @.***>

zhenglinpan commented 9 months ago

Cool! Thanks much!