Spaces:
Build error
Build error
''' | |
* Copyright (c) 2023 Salesforce, Inc. | |
* All rights reserved. | |
* SPDX-License-Identifier: Apache License 2.0 | |
* For full license text, see LICENSE.txt file in the repo root or http://www.apache.org/licenses/ | |
* By Can Qin | |
* Modified from ControlNet repo: https://github.com/lllyasviel/ControlNet | |
* Copyright (c) 2023 Lvmin Zhang and Maneesh Agrawala | |
''' | |
import torch | |
class BaseModel(torch.nn.Module): | |
def load(self, path): | |
"""Load model from file. | |
Args: | |
path (str): file path | |
""" | |
parameters = torch.load(path, map_location=torch.device('cpu')) | |
if "optimizer" in parameters: | |
parameters = parameters["model"] | |
self.load_state_dict(parameters) | |