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

Not able to fine-tune on fashion Try-on #77

Open
ManuelCecere opened this issue Feb 28, 2024 · 0 comments
Open

Not able to fine-tune on fashion Try-on #77

ManuelCecere opened this issue Feb 28, 2024 · 0 comments

Comments

@ManuelCecere
Copy link

ManuelCecere commented Feb 28, 2024

Hello there, thanks for all the fantastic work done for AnyDoor!
I'm trying to fine-tune the model for fashion try-on application, but when I try to unfreeze just the ResBlock or the SpatialTransformer module and not both together a RuntimeError One of the differentiated Tensors does not require grad is raised.
That's troublesome, even though now I'm working with both unfreeze, because I was planning of targeting just the convolutional and linear layers, using LoRA but doing so raises the error.
Any tip would be greatly appreciated, thanks!

The code for reference, in the run_train_anydoor script:

.... the code above is unaltered
model = create_model("./configs/anydoor.yaml").cpu()
model.load_state_dict(load_state_dict(resume_path, location="cpu"))
model.learning_rate = learning_rate
model.sd_locked = sd_locked
model.only_mid_control = only_mid_control

for name, param in model.named_parameters():
param.requires_grad = False

for block in model.model.diffusion_model.output_blocks:
for layer in block:
if isinstance(layer, SpatialTransformer):
for name, param in layer.named_parameters():
param.requires_grad = True

dataloader = DataLoader(dataset, num_workers=8, batch_size=batch_size, shuffle=True)
logger = ImageLogger(batch_frequency=logger_freq)
trainer = pl.Trainer(
gpus=n_gpus,
strategy="ddp",
precision=16,
accelerator="gpu",
callbacks=[logger],
progress_bar_refresh_rate=1,
accumulate_grad_batches=accumulate_grad_batches,
)

trainer.fit(model, dataloader)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant