kalhdrawi commited on
Commit
92d3191
·
1 Parent(s): 3e60980

إضافة ملفات جديدة

Browse files
Files changed (2) hide show
  1. Dockerfile +3 -0
  2. server.py +4 -2
Dockerfile CHANGED
@@ -29,6 +29,9 @@ RUN pip install --no-cache-dir --upgrade pip && \
29
 
30
  # Copy application code
31
  COPY . /app
 
 
 
32
 
33
  # Expose port
34
  EXPOSE 7860
 
29
 
30
  # Copy application code
31
  COPY . /app
32
+ # Optional: allow passing HF_TOKEN at runtime for private models
33
+ # ENV HF_TOKEN=""
34
+
35
 
36
  # Expose port
37
  EXPOSE 7860
server.py CHANGED
@@ -1,4 +1,5 @@
1
  import io
 
2
  import base64
3
  from typing import Optional
4
 
@@ -82,8 +83,9 @@ def remove_background(pil_image: Image.Image) -> Image.Image:
82
  async def _load_model():
83
  global net, _device
84
  _device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
85
- # Pass empty token to avoid reading a potentially unreadable token file in HF_HOME
86
- net = BriaRMBG.from_pretrained("briaai/RMBG-1.4", token="")
 
87
  net.to(_device)
88
  net.eval()
89
 
 
1
  import io
2
+ import os
3
  import base64
4
  from typing import Optional
5
 
 
83
  async def _load_model():
84
  global net, _device
85
  _device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
86
+ # If HF_TOKEN env is provided, use it; otherwise pass token=None to avoid sending bad headers
87
+ hf_token = os.environ.get("HF_TOKEN") or None
88
+ net = BriaRMBG.from_pretrained("briaai/RMBG-1.4", token=hf_token)
89
  net.to(_device)
90
  net.eval()
91