AttributeError: 'str' object has no attribute 'load_state_dict'

Any help please

def load_model(model,epoch,model_type):
  path = models_path + 'saved_'+model_type+'_epoch'+str(epoch)+'.txt'
  print("Loading model from %s" % path)
  
  model.load_state_dict(torch.load(path)['model_state_dict'])


  return model
# load model
embed_epoch = 1
model_embed = load_model(model_embed,embed_epoch,'embed')
model_embed.to(device)

Loading model from /content/drive/MyDrive/Models/saved_embed_epoch1.txt
---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-64-da43c88e687e> in <module>()
      1 # load model
      2 embed_epoch = 1
----> 3 model_embed = load_model(model_embed,embed_epoch,'embed')
      4 model_embed.to(device)
      5 # load model

<ipython-input-63-7b862763f577> in load_model(model, epoch, model_type)
      3   print("Loading model from %s" % path)
      4 
----> 5   model.load_state_dict(state_dict['state_dict'])
      6 
      7 

AttributeError: 'str' object has no attribute 'load_state_dict'

Try this:

model.load_state_dict(torch.load(model_path))

thanks for you but after try this it gives me this Error

Loading model from /content/drive/MyDrive/Models/saved_embed_epoch1.txt
---------------------------------------------------------------------------
IsADirectoryError                         Traceback (most recent call last)
<ipython-input-57-da43c88e687e> in <module>()
      1 # load model
      2 embed_epoch = 1
----> 3 model_embed = load_model(model_embed,embed_epoch,'embed')
      4 model_embed.to(device)
      5 # load model

3 frames
/usr/local/lib/python3.6/dist-packages/torch/serialization.py in __init__(self, name, mode)
    209 class _open_file(_opener):
    210     def __init__(self, name, mode):
--> 211         super(_open_file, self).__init__(open(name, mode))
    212 
    213     def __exit__(self, *args):

IsADirectoryError: [Errno 21] Is a directory: '/content/drive/MyDrive/Models/'