Skip to content

Commit

Permalink
Remove pytorch_lightning dependency.
Browse files Browse the repository at this point in the history
  • Loading branch information
comfyanonymous committed Jun 13, 2023
1 parent cb180b9 commit 735ac4c
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 2 deletions.
13 changes: 13 additions & 0 deletions comfy/checkpoint_pickle.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import pickle

load = pickle.load

class Empty:
pass

class Unpickler(pickle.Unpickler):
def find_class(self, module, name):
#TODO: safe unpickle
if module.startswith("pytorch_lightning"):
return Empty
return super().find_class(module, name)
3 changes: 2 additions & 1 deletion comfy/utils.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import torch
import math
import struct
import comfy.checkpoint_pickle

def load_torch_file(ckpt, safe_load=False):
if ckpt.lower().endswith(".safetensors"):
Expand All @@ -14,7 +15,7 @@ def load_torch_file(ckpt, safe_load=False):
if safe_load:
pl_sd = torch.load(ckpt, map_location="cpu", weights_only=True)
else:
pl_sd = torch.load(ckpt, map_location="cpu")
pl_sd = torch.load(ckpt, map_location="cpu", pickle_module=comfy.checkpoint_pickle)
if "global_step" in pl_sd:
print(f"Global Step: {pl_sd['global_step']}")
if "state_dict" in pl_sd:
Expand Down
1 change: 0 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ torchsde
einops
transformers>=4.25.1
safetensors>=0.3.0
pytorch_lightning
aiohttp
accelerate
pyyaml
Expand Down

0 comments on commit 735ac4c

Please sign in to comment.