parth parekh commited on
Commit
ccac5e2
·
1 Parent(s): 3562e57

working now after owning the directory if this dosent work i will do it

Browse files
Files changed (3) hide show
  1. Dockerfile +8 -0
  2. README.md +1 -1
  3. app.py +2 -2
Dockerfile CHANGED
@@ -1,5 +1,8 @@
1
  FROM python:3.8-slim
2
 
 
 
 
3
  WORKDIR /app
4
 
5
  RUN apt-get update && apt-get install -y \
@@ -16,5 +19,10 @@ RUN pip install --no-cache-dir -r requirements.txt
16
 
17
  COPY . .
18
 
 
 
 
 
 
19
 
20
  CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860", "--workers", "4"]
 
1
  FROM python:3.8-slim
2
 
3
+ # Create a new user
4
+ RUN useradd -m user
5
+
6
  WORKDIR /app
7
 
8
  RUN apt-get update && apt-get install -y \
 
19
 
20
  COPY . .
21
 
22
+ # Change ownership of the /app directory to the new user
23
+ RUN chown -R user:user /app
24
+
25
+ # Switch to the new user
26
+ USER user
27
 
28
  CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860", "--workers", "4"]
README.md CHANGED
@@ -1,6 +1,6 @@
1
  ---
2
  title: Contact Sharing Recognizer API
3
- emoji: 💻
4
  colorFrom: indigo
5
  colorTo: pink
6
  sdk: docker
 
1
  ---
2
  title: Contact Sharing Recognizer API
3
+ emoji: 🤙
4
  colorFrom: indigo
5
  colorTo: pink
6
  sdk: docker
app.py CHANGED
@@ -14,8 +14,8 @@ app = FastAPI(
14
  class ContactDetector:
15
  def __init__(self):
16
  cache_dir = "/app/model_cache"
17
- self.tokenizer = DistilBertTokenizer.from_pretrained('distilbert-base-uncased', use_fast=True, no_cache=True)
18
- self.model = DistilBertForSequenceClassification.from_pretrained('distilbert-base-uncased', num_labels=2, no_cache=True)
19
  self.device = torch.device('cuda' if torch.cuda.is_available() else 'cpu')
20
  self.model.to(self.device)
21
  self.model.eval()
 
14
  class ContactDetector:
15
  def __init__(self):
16
  cache_dir = "/app/model_cache"
17
+ self.tokenizer = DistilBertTokenizer.from_pretrained('distilbert-base-uncased', cache_dir=cache_dir)
18
+ self.model = DistilBertForSequenceClassification.from_pretrained('distilbert-base-uncased', num_labels=2, cache_dir=cache_dir)
19
  self.device = torch.device('cuda' if torch.cuda.is_available() else 'cpu')
20
  self.model.to(self.device)
21
  self.model.eval()