jonathanrstern commited on
Commit
194051d
1 Parent(s): 675b21b

safetensors

Browse files
__pycache__/handler.cpython-39.pyc CHANGED
Binary files a/__pycache__/handler.cpython-39.pyc and b/__pycache__/handler.cpython-39.pyc differ
 
convert.py ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import torch
2
+ import safetensors
3
+
4
+ def load_safetensors(file_path: str):
5
+ return safetensors.load(file_path)
6
+
7
+ def save_as_pytorch_bin(tensor_or_state_dict, file_path: str):
8
+ torch.save(tensor_or_state_dict, file_path)
9
+
10
+ if __name__ == "__main__":
11
+ safetensors_file_path = "path/to/your/file.safetensors"
12
+ pytorch_bin_file_path = "path/to/save/pytorch_lora_weights.bin"
13
+
14
+ loaded_data = load_safetensors(safetensors_file_path)
15
+ save_as_pytorch_bin(loaded_data, pytorch_bin_file_path)
16
+
17
+ load_safetensors('./LogoRedmond-LogoLoraForSDXL/LogoRedmond_LogoRedAF.safetensors')
handler.py CHANGED
@@ -1,11 +1,10 @@
1
  from typing import Dict, List, Any
2
- from diffusers import DiffusionPipeline
 
3
 
4
  class EndpointHandler():
5
  def __init__(self, path=""):
6
- # Preload all the elements you are going to need at inference.
7
- self.pipeline = DiffusionPipeline.from_pretrained("stabilityai/stable-diffusion-xl-base-1.0")
8
- self.pipeline.load_lora_weights("jonathanrstern/logo-generator")
9
 
10
  def __call__(self, data: Dict[str, Any]) -> List[Dict[str, Any]]:
11
  """
 
1
  from typing import Dict, List, Any
2
+ from diffusers import StableDiffusionPipeline
3
+
4
 
5
  class EndpointHandler():
6
  def __init__(self, path=""):
7
+ self.pipeline = StableDiffusionPipeline.from_single_file("./safetensors.safetensors")
 
 
8
 
9
  def __call__(self, data: Dict[str, Any]) -> List[Dict[str, Any]]:
10
  """
requirements.txt CHANGED
@@ -15,4 +15,6 @@ packaging
15
  zipp
16
  charset-normalizer
17
  urllib3
18
- certifi
 
 
 
15
  zipp
16
  charset-normalizer
17
  urllib3
18
+ certifi
19
+ torch
20
+ torchvision
LogoRedmond_LogoRedAF.safetensors → safetensors.safetensors RENAMED
File without changes
test.py ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from handler import EndpointHandler
2
+
3
+ # init handler
4
+ my_handler = EndpointHandler(path=".")
5
+
6
+ # prepare sample payload
7
+ payload = {"inputs": "geometric minimal, landscaping company, logo, line, simple"}
8
+
9
+ # test the handler
10
+ test=my_handler(payload)
11
+
12
+ # show results
13
+ print("test:", test)