SamSak09 commited on
Commit
147c40d
·
verified ·
1 Parent(s): ed3057b

Update app2.py

Browse files
Files changed (1) hide show
  1. app2.py +14 -3
app2.py CHANGED
@@ -1,3 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
  from flask import Flask, request, jsonify
2
  from flask_sock import Sock
3
  from transformers import AutoModel
@@ -19,12 +31,11 @@ model = AutoModel.from_pretrained(
19
  trust_remote_code=True
20
  )
21
 
22
- # 2. M1 Architecture Override
23
  device = torch.device('cuda' if torch.cuda.is_available() else 'cpu')
24
  model = model.to(device)
25
  print(f"[SYSTEM] Model loaded successfully onto device: {device}")
26
 
27
-
28
  # --- THE NEW WEBSOCKET PIPELINE ---
29
  @sock.route('/api/generate_stream')
30
  def stream_motion(ws):
@@ -65,5 +76,5 @@ def stream_motion(ws):
65
  break
66
 
67
  if __name__ == '__main__':
68
- # --- CHANGE THE PORT TO 7860 ---
69
  app.run(host='0.0.0.0', port=7860, debug=False)
 
1
+ import os
2
+ import shutil
3
+
4
+ # --- SEARCH AND DESTROY POISONED CACHE ---
5
+ corrupted_dir = "/root/.cache/huggingface/hub/models--google--umt5-base"
6
+ if os.path.exists(corrupted_dir):
7
+ print("[SYSTEM] Found corrupted UMT5 cache. Deleting...")
8
+ shutil.rmtree(corrupted_dir, ignore_errors=True)
9
+ else:
10
+ print("[SYSTEM] Cache is clean.")
11
+
12
+ # --- YOUR ORIGINAL CODE STARTS HERE ---
13
  from flask import Flask, request, jsonify
14
  from flask_sock import Sock
15
  from transformers import AutoModel
 
31
  trust_remote_code=True
32
  )
33
 
34
+ # 2. Cloud Architecture Override
35
  device = torch.device('cuda' if torch.cuda.is_available() else 'cpu')
36
  model = model.to(device)
37
  print(f"[SYSTEM] Model loaded successfully onto device: {device}")
38
 
 
39
  # --- THE NEW WEBSOCKET PIPELINE ---
40
  @sock.route('/api/generate_stream')
41
  def stream_motion(ws):
 
76
  break
77
 
78
  if __name__ == '__main__':
79
+ # --- PORT 7860 FOR HUGGING FACE ---
80
  app.run(host='0.0.0.0', port=7860, debug=False)