File size: 1,665 Bytes
3f7e397
66668a0
3f7e397
 
 
 
 
 
 
66668a0
3f7e397
 
76e60ef
 
 
 
3b7a372
 
76e60ef
 
 
 
 
 
 
952db43
76e60ef
 
 
 
 
 
 
 
 
 
 
4642679
76e60ef
c269ab0
 
3b7a372
952db43
 
 
 
 
696ae63
 
 
 
686c304
696ae63
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
---
title: ZeroGPU
emoji: 🖼
colorFrom: purple
colorTo: red
sdk: gradio
sdk_version: 5.25.2
app_file: app.py
pinned: false
license: apache-2.0
---

Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference

commands:

pip install git+https://github.com/huggingface/diffusers

accelerate launch \
  --deepspeed_config_file ds_config.json \
  diffusers/examples/dreambooth/train_dreambooth.py \
    --pretrained_model_name_or_path="runwayml/stable-diffusion-v1-5" \
    --instance_data_dir="./nyc_ads_dataset" \
    --instance_prompt="a photo of an urbanad nyc" \
    --output_dir="./nyc-ad-model" \
    --resolution=100 \
    --train_batch_size=1 \
    --gradient_accumulation_steps=1 \
    --gradient_checkpointing \
    --learning_rate=5e-6 \
    --lr_scheduler="constant" \
    --lr_warmup_steps=0 \
    --max_train_steps=400 \
    --mixed_precision="fp16" \
    --checkpointing_steps=100 \
    --checkpoints_total_limit=1 \
    --report_to="tensorboard" \
    --logging_dir="./nyc-ad-model/logs" 

fine tune a trained model: --pretrained_model_name_or_path="./nyc-ad-model/checkpoint-400" \



export PYTORCH_CUDA_ALLOC_CONF=expandable_segments:True

import torch
torch.cuda.empty_cache()
torch.cuda.reset_peak_memory_stats()

7/12
# 1 Fine‑tune image model LoRA+QLoRA
accelerate launch --deepspeed_config_file=ds_config_zero3.json train_lora.py
python train_lora.py

# 2 SFT 语言模型
python sft_train.py

# 3 Build RAG index
python build_embeddings.py

# 4 (可选) 收集偏好 → 训练 reward model
python reward_model.py

# 5 PPO RLHF 微调
python ppo_tune.py

# 6 Inference with RAG
python rag_infer.py