Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#57 Added single file option #114

Merged
merged 3 commits into from
Apr 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
File renamed without changes.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,5 @@ We welcome contributions from everyone. There are several ways to contribute, an

## License

All code is licensed under the TBD. See [LICENSE](./LICENSE.txt) file for
All code is licensed under the TBD. See [LICENSE](./LICENSE) file for
details.
6 changes: 4 additions & 2 deletions sdk/models/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,23 +11,25 @@ class Model:
model_name: str
model_path: str
device: Union[str, Devices]

loaded: bool
single_file: bool

def __init__(self, model_name, model_path: str,
device: Union[str, Devices]):
device: Union[str, Devices], single_file: bool = False):
"""
Initializes the model with the given name

Args:
model_name (str): The name of the model
model_path (str): The path of the model
device (Union[str, Devices]): Which device the model must be on
:param single_file: Whether model is single file or not
"""
self.model_name = model_name
self.model_path = model_path
self.device = device
self.loaded = False
self.single_file = single_file

@abstractmethod
def load_model(self) -> bool:
Expand Down
8 changes: 8 additions & 0 deletions sdk/models/model_diffusers.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,14 @@ def create_pipeline(self, **kwargs) -> None:
if self.loaded:
return

# Single file loads a single ckpt/safetensors file
if self.single_file:
self.pipeline = self.model_class.from_single_file(
self.model_path,
**kwargs
)
return

self.pipeline = self.model_class.from_pretrained(
self.model_path,
**kwargs
Expand Down
Loading