Spaces:
Build error
Build error
Nupur Kumari
commited on
Commit
·
d2a1d65
1
Parent(s):
eb4a287
custom-diffusion-space
Browse files- app.py +1 -0
- inference.py +0 -21
app.py
CHANGED
|
@@ -154,6 +154,7 @@ def create_training_demo(trainer: Trainer,
|
|
| 154 |
def find_weight_files() -> list[str]:
|
| 155 |
curr_dir = pathlib.Path(__file__).parent
|
| 156 |
paths = sorted(curr_dir.rglob('*.bin'))
|
|
|
|
| 157 |
return [path.relative_to(curr_dir).as_posix() for path in paths]
|
| 158 |
|
| 159 |
|
|
|
|
| 154 |
def find_weight_files() -> list[str]:
|
| 155 |
curr_dir = pathlib.Path(__file__).parent
|
| 156 |
paths = sorted(curr_dir.rglob('*.bin'))
|
| 157 |
+
paths = [path for path in paths if '.lfs' not in path.name]
|
| 158 |
return [path.relative_to(curr_dir).as_posix() for path in paths]
|
| 159 |
|
| 160 |
|
inference.py
CHANGED
|
@@ -13,27 +13,6 @@ from diffusers import StableDiffusionPipeline
|
|
| 13 |
sys.path.insert(0, './custom-diffusion')
|
| 14 |
|
| 15 |
|
| 16 |
-
# def load_model(text_encoder, tokenizer, unet, save_path, modifier_token, freeze_model='crossattn_kv'):
|
| 17 |
-
# st = torch.load(save_path)
|
| 18 |
-
# if 'text_encoder' in st:
|
| 19 |
-
# text_encoder.load_state_dict(st['text_encoder'])
|
| 20 |
-
# if modifier_token in st:
|
| 21 |
-
# _ = tokenizer.add_tokens(modifier_token)
|
| 22 |
-
# modifier_token_id = tokenizer.convert_tokens_to_ids(modifier_token)
|
| 23 |
-
# # Resize the token embeddings as we are adding new special tokens to the tokenizer
|
| 24 |
-
# text_encoder.resize_token_embeddings(len(tokenizer))
|
| 25 |
-
# token_embeds = text_encoder.get_input_embeddings().weight.data
|
| 26 |
-
# token_embeds[modifier_token_id] = st[modifier_token]
|
| 27 |
-
# print(st.keys())
|
| 28 |
-
# for name, params in unet.named_parameters():
|
| 29 |
-
# if freeze_model == 'crossattn':
|
| 30 |
-
# if 'attn2' in name:
|
| 31 |
-
# params.data.copy_(st['unet'][f'{name}'])
|
| 32 |
-
# else:
|
| 33 |
-
# if 'attn2.to_k' in name or 'attn2.to_v' in name:
|
| 34 |
-
# params.data.copy_(st['unet'][f'{name}'])
|
| 35 |
-
|
| 36 |
-
|
| 37 |
class InferencePipeline:
|
| 38 |
def __init__(self):
|
| 39 |
self.pipe = None
|
|
|
|
| 13 |
sys.path.insert(0, './custom-diffusion')
|
| 14 |
|
| 15 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 16 |
class InferencePipeline:
|
| 17 |
def __init__(self):
|
| 18 |
self.pipe = None
|