Update Dockerfile to set HF_TOKEN as an environment variable and remove debug print statements from encoder.py for cleaner code.
Browse files- Dockerfile +1 -0
- src/encoder.py +0 -5
Dockerfile
CHANGED
|
@@ -3,6 +3,7 @@ FROM python:3.9
|
|
| 3 |
WORKDIR /app
|
| 4 |
|
| 5 |
ENV HF_HOME=/app/hf_cache
|
|
|
|
| 6 |
RUN mkdir -p /app/hf_cache && chmod 777 /app/hf_cache
|
| 7 |
|
| 8 |
COPY requirements.txt .
|
|
|
|
| 3 |
WORKDIR /app
|
| 4 |
|
| 5 |
ENV HF_HOME=/app/hf_cache
|
| 6 |
+
ENV HF_TOKEN=${HF_TOKEN}
|
| 7 |
RUN mkdir -p /app/hf_cache && chmod 777 /app/hf_cache
|
| 8 |
|
| 9 |
COPY requirements.txt .
|
src/encoder.py
CHANGED
|
@@ -1,14 +1,11 @@
|
|
| 1 |
from typing import List, Dict
|
| 2 |
from PIL.Image import Image
|
| 3 |
-
import os
|
| 4 |
|
| 5 |
import torch
|
| 6 |
from transformers import AutoModel, AutoProcessor
|
| 7 |
|
| 8 |
|
| 9 |
MODEL_NAME = "Marqo/marqo-fashionCLIP"
|
| 10 |
-
HF_TOKEN = os.environ.get("HF_TOKEN")
|
| 11 |
-
print("token", HF_TOKEN)
|
| 12 |
|
| 13 |
|
| 14 |
class FashionCLIPEncoder:
|
|
@@ -18,13 +15,11 @@ class FashionCLIPEncoder:
|
|
| 18 |
self.processor = AutoProcessor.from_pretrained(
|
| 19 |
MODEL_NAME,
|
| 20 |
trust_remote_code=True,
|
| 21 |
-
token=HF_TOKEN
|
| 22 |
)
|
| 23 |
|
| 24 |
self.model = AutoModel.from_pretrained(
|
| 25 |
MODEL_NAME,
|
| 26 |
trust_remote_code=True,
|
| 27 |
-
token=HF_TOKEN,
|
| 28 |
)
|
| 29 |
|
| 30 |
self.model.to(self.device)
|
|
|
|
| 1 |
from typing import List, Dict
|
| 2 |
from PIL.Image import Image
|
|
|
|
| 3 |
|
| 4 |
import torch
|
| 5 |
from transformers import AutoModel, AutoProcessor
|
| 6 |
|
| 7 |
|
| 8 |
MODEL_NAME = "Marqo/marqo-fashionCLIP"
|
|
|
|
|
|
|
| 9 |
|
| 10 |
|
| 11 |
class FashionCLIPEncoder:
|
|
|
|
| 15 |
self.processor = AutoProcessor.from_pretrained(
|
| 16 |
MODEL_NAME,
|
| 17 |
trust_remote_code=True,
|
|
|
|
| 18 |
)
|
| 19 |
|
| 20 |
self.model = AutoModel.from_pretrained(
|
| 21 |
MODEL_NAME,
|
| 22 |
trust_remote_code=True,
|
|
|
|
| 23 |
)
|
| 24 |
|
| 25 |
self.model.to(self.device)
|