SeaWolf-AI commited on
Commit
1bf9a4a
ยท
verified ยท
1 Parent(s): 53738af

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +31 -6
app.py CHANGED
@@ -114,10 +114,11 @@ from huggingface_hub import snapshot_download
114
  tokenizer = AutoTokenizer.from_pretrained(MODEL_ID, trust_remote_code=True)
115
  print(f"[vLLM] Tokenizer loaded โœ“", flush=True)
116
 
117
- # โ”€โ”€ ๋ชจ๋ธ ๋‹ค์šด๋กœ๋“œ + config.json ํŒจ์น˜ (ํ…์ŠคํŠธ ์ „์šฉ ๊ฐ•์ œ) โ”€โ”€
118
- print(f"[vLLM] Downloading {MODEL_ID}...", flush=True)
119
- MODEL_PATH = snapshot_download(MODEL_ID)
120
  print(f"[vLLM] Downloaded โ†’ {MODEL_PATH}", flush=True)
 
121
 
122
  _config_path = os.path.join(MODEL_PATH, "config.json")
123
  try:
@@ -160,9 +161,33 @@ try:
160
  if _removed_keys:
161
  print(f"[vLLM] Removed MM keys: {_removed_keys}", flush=True)
162
 
163
- # 5. ํ”„๋กœ์„ธ์„œ ํŒŒ์ผ์€ ์œ ์ง€ โ€” vLLM์ด model_type ๊ธฐ๋ฐ˜์œผ๋กœ ํ•„์š”๋กœ ํ•จ
164
- # CausalLM์œผ๋กœ ๋ณ€๊ฒฝํ•ด๋„ ํ”„๋กœ์„ธ์„œ ๋กœ๋“œ๋Š” ์‹œ๋„ํ•˜๋ฏ€๋กœ, ํŒŒ์ผ์ด ์žˆ์–ด์•ผ ์—๋Ÿฌ ์•ˆ ๋‚จ
165
- print(f"[vLLM] Preprocessor files kept (required by vLLM model registry)", flush=True)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
166
 
167
  except Exception as e:
168
  print(f"[vLLM] Config patch failed: {e} โ€” proceeding with original", flush=True)
 
114
  tokenizer = AutoTokenizer.from_pretrained(MODEL_ID, trust_remote_code=True)
115
  print(f"[vLLM] Tokenizer loaded โœ“", flush=True)
116
 
117
+ # โ”€โ”€ ๋ชจ๋ธ ๋‹ค์šด๋กœ๋“œ (๋กœ์ปฌ ๋ณต์‚ฌ, symlink ์•„๋‹Œ ์‹ค์ œ ํŒŒ์ผ) โ”€โ”€
118
+ print(f"[vLLM] Downloading {MODEL_ID} to /app/model ...", flush=True)
119
+ MODEL_PATH = snapshot_download(MODEL_ID, local_dir="/app/model")
120
  print(f"[vLLM] Downloaded โ†’ {MODEL_PATH}", flush=True)
121
+ print(f"[vLLM] Files: {os.listdir(MODEL_PATH)[:15]}", flush=True)
122
 
123
  _config_path = os.path.join(MODEL_PATH, "config.json")
124
  try:
 
161
  if _removed_keys:
162
  print(f"[vLLM] Removed MM keys: {_removed_keys}", flush=True)
163
 
164
+ # 5. preprocessor_config.json ํŒจ์น˜ โ€” video processor ์ฐธ์กฐ ์ œ๊ฑฐ
165
+ _preproc_path = os.path.join(MODEL_PATH, "preprocessor_config.json")
166
+ if os.path.exists(_preproc_path):
167
+ try:
168
+ with open(_preproc_path) as f:
169
+ _preproc = json.load(f)
170
+ # video ๊ด€๋ จ ํ‚ค ์ œ๊ฑฐ
171
+ _video_keys = [k for k in _preproc if "video" in k.lower()]
172
+ for k in _video_keys:
173
+ del _preproc[k]
174
+ _removed_keys.append(f"preproc.{k}")
175
+ # processor_class๊ฐ€ ๋น„๋””์˜ค๋ฅผ ์ฐธ์กฐํ•˜๋ฉด ์ œ๊ฑฐ
176
+ if "processor_class" in _preproc:
177
+ _removed_keys.append(f"preproc.processor_class={_preproc['processor_class']}")
178
+ with open(_preproc_path, "w") as f:
179
+ json.dump(_preproc, f, indent=2)
180
+ print(f"[vLLM] preprocessor_config.json patched", flush=True)
181
+ except Exception as e:
182
+ print(f"[vLLM] preprocessor patch error: {e}", flush=True)
183
+
184
+ # video_preprocessor_config.json์ด ์žˆ์œผ๋ฉด ์‚ญ์ œ (์ด๊ฑด ํ•„์š” ์—†์Œ)
185
+ _vidproc = os.path.join(MODEL_PATH, "video_preprocessor_config.json")
186
+ if os.path.exists(_vidproc):
187
+ os.remove(_vidproc)
188
+ print(f"[vLLM] Removed video_preprocessor_config.json", flush=True)
189
+
190
+ print(f"[vLLM] Preprocessor files handled", flush=True)
191
 
192
  except Exception as e:
193
  print(f"[vLLM] Config patch failed: {e} โ€” proceeding with original", flush=True)