huggingface / huggingface/diffusers
How can I manually update some of their checkpoints of UNet2/3DConditionModel objects?
- 主要言語
- Python
- スター
- 34.5k
- フォーク
- 7.3k
- 平均マージ
- 3日 3時間
- マージ済み PR(30日)
- 91
説明
### Discussed in https://github.com/huggingface/diffusers/discussions/9273
Originally posted by **justin4ai** August 26, 2024
Hello, I'm quite new to diffusers package and trying to implement fine-tuning code that uses the saved checkpoints initialized with ```UNet2/3DConditionModel.from_pretrained``` method as shown below:
```python
reference_unet = UNet2DConditionModel.from_pretrained( # ReferenceNet은 2D condition만 받음 (reference image via CLIP)
cfg.base_model_path,
subfolder="unet",
).to(device="cuda")
denoising_unet = UNet3DConditionModel.from_pretrained_2d(
cfg.base_model_path,
"",
subfolder="unet",
unet_additional_kwargs={
"use_motion_module": False,
"unet_use_temporal_attention": False,
},
).to(device="cuda")
prev = denoising_unet.state_dict()
li = torch.load("./pretrained_weights/denoising_unet.pth")
for key in li:
denoising_unet[key] = li[key] # I know this kind of direct assigning to the object doesn't make sense though.
reference_unet.load_state_dict(torch.load("./pretrained_weights/reference_unet.pth"))
```
The checkpoint I try to load is saved from the previous training of ``` UNet2/3DConditionModel objects``` with ```state_dict = model.state_dict()``` and ```torch.save(state_dict, save_path)```. But I have no Idea about how to directly assign certain values to specific layers in those class objects.
If you help me out with this, I will be so much glad! Looking forward to your help. Also please let me know if my description of the situation is not enough for you to help me out.
Cheers,
Junstin
コントリビューションガイド
調査の方向性
まず、例に示されている PyTorch の state_dict と load_state_dict のエントリポイントから始め、次に denoising_unet.state_dict() と保存されたチェックポイントによって返されるキーを調べます。これらのキーを、要求された UNet2DConditionModel と UNet3DConditionModel のレイヤーと比較します。完了とは、選択したチェックポイント値を更新する方法について再現可能な説明が得られることです。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- python, pytorch
- 領域
- documentation, machine-learning
- issue の種類
- ドキュメント
- 難易度
- 3/5
- 見積もり時間
- 1〜2日
- 活発さ
- 停滞
- 明瞭さ
- 説明が足りない
- 初心者へのやさしさ
- 25/100