cuio commited on
Commit
43349a0
·
verified ·
1 Parent(s): d59b51c

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -1
app.py CHANGED
@@ -28,6 +28,9 @@ from diffnext.utils import export_to_image, export_to_video
28
 
29
  # =========================
30
  # 🔧 修复 Qwen3Config 缺失 rope_theta
 
 
 
31
  # =========================
32
  def _patch_diffnext_qwen3():
33
  try:
@@ -39,6 +42,7 @@ def _patch_diffnext_qwen3():
39
 
40
  @classmethod
41
  def patched_from_config(cls, config):
 
42
  if not hasattr(config, "rope_theta"):
43
  rp = getattr(config, "rope_parameters", None)
44
  if isinstance(rp, dict) and "rope_theta" in rp:
@@ -46,12 +50,14 @@ def _patch_diffnext_qwen3():
46
  else:
47
  config.rope_theta = float(1e6)
48
 
 
49
  if not hasattr(config, "max_position_embeddings"):
50
  config.max_position_embeddings = int(
51
  getattr(config, "max_seq_len", 2048)
52
  )
53
 
54
- return orig_from_config(cls, config)
 
55
 
56
  qwen3.Qwen3RotaryEmbedding.from_config = patched_from_config
57
 
@@ -59,6 +65,7 @@ def _patch_diffnext_qwen3():
59
  _patch_diffnext_qwen3()
60
  # =========================
61
 
 
62
  # ✅ HF Token(从环境变量读取,不写死)
63
  os.environ["HF_TOKEN"] = os.environ.get("HF_TOKEN", "")
64
  os.environ["HUGGINGFACE_HUB_TOKEN"] = os.environ.get("HF_TOKEN", "")
 
28
 
29
  # =========================
30
  # 🔧 修复 Qwen3Config 缺失 rope_theta
31
+ # =========================
32
+ # =========================
33
+
34
  # =========================
35
  def _patch_diffnext_qwen3():
36
  try:
 
42
 
43
  @classmethod
44
  def patched_from_config(cls, config):
45
+ # rope_theta
46
  if not hasattr(config, "rope_theta"):
47
  rp = getattr(config, "rope_parameters", None)
48
  if isinstance(rp, dict) and "rope_theta" in rp:
 
50
  else:
51
  config.rope_theta = float(1e6)
52
 
53
+ # max_position_embeddings
54
  if not hasattr(config, "max_position_embeddings"):
55
  config.max_position_embeddings = int(
56
  getattr(config, "max_seq_len", 2048)
57
  )
58
 
59
+ # 正确:只传 config,不要传 cls
60
+ return orig_from_config(config)
61
 
62
  qwen3.Qwen3RotaryEmbedding.from_config = patched_from_config
63
 
 
65
  _patch_diffnext_qwen3()
66
  # =========================
67
 
68
+
69
  # ✅ HF Token(从环境变量读取,不写死)
70
  os.environ["HF_TOKEN"] = os.environ.get("HF_TOKEN", "")
71
  os.environ["HUGGINGFACE_HUB_TOKEN"] = os.environ.get("HF_TOKEN", "")