Amrender commited on
Commit
2a5e7f9
·
verified ·
1 Parent(s): 8d56fd5

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +15 -4
app.py CHANGED
@@ -11,12 +11,23 @@ from transformers import SegformerForSemanticSegmentation
11
  print("🚀 BOOTING PRODUCTION B5 CARTOGRAPHY ENGINE...")
12
 
13
  # ==========================================
14
- # 1. CONFIGURATION
15
  # ==========================================
16
- # ⚠️ IMPORTANT: Ensure your uploaded weights file is named exactly this!
17
- MODEL_PATH = "b5_weights.pth"
18
- DEVICE = "cpu" # HF Free Tier uses CPU
19
 
 
 
 
 
 
 
 
 
 
 
 
 
 
20
  # ==========================================
21
  # 2. POST-PROCESSING ENGINES
22
  # ==========================================
 
11
  print("🚀 BOOTING PRODUCTION B5 CARTOGRAPHY ENGINE...")
12
 
13
  # ==========================================
14
+ # 1. CONFIGURATION & WEIGHT DOWNLOAD
15
  # ==========================================
16
+ from huggingface_hub import hf_hub_download
 
 
17
 
18
+ print("⬇️ Fetching B5 Weights from the Hub...")
19
+
20
+ # ⚠️ CHANGE 'Amrender' to your exact HF username and match the model repo name!
21
+ REPO_ID = "Amrender/b5-cartography-weights"
22
+ FILENAME = "best_model (3).pth"
23
+ DEVICE = "cpu"
24
+
25
+ # This securely downloads the weights to the Docker container's cache on boot
26
+ try:
27
+ MODEL_PATH = hf_hub_download(repo_id=REPO_ID, filename=FILENAME)
28
+ print(f"✅ Weights successfully downloaded to: {MODEL_PATH}")
29
+ except Exception as e:
30
+ print(f"❌ Failed to download weights. Check your REPO_ID. Error: {e}")
31
  # ==========================================
32
  # 2. POST-PROCESSING ENGINES
33
  # ==========================================