Spaces:
Runtime error
Runtime error
Ravi Pandey
commited on
Commit
•
89c340e
1
Parent(s):
492d13b
Docker deploy
Browse files- Dockerfile +1 -1
- server/caption_server.py +7 -3
Dockerfile
CHANGED
@@ -6,7 +6,7 @@ COPY ./requirements.txt /code/requirements.txt
|
|
6 |
|
7 |
RUN pip install --no-cache-dir --upgrade -r /code/requirements.txt
|
8 |
|
9 |
-
ENV
|
10 |
|
11 |
COPY . .
|
12 |
|
|
|
6 |
|
7 |
RUN pip install --no-cache-dir --upgrade -r /code/requirements.txt
|
8 |
|
9 |
+
ENV HF_HOME='/.cache'
|
10 |
|
11 |
COPY . .
|
12 |
|
server/caption_server.py
CHANGED
@@ -20,13 +20,17 @@ app.add_middleware(
|
|
20 |
)
|
21 |
|
22 |
import os
|
23 |
-
|
|
|
|
|
|
|
24 |
|
25 |
# Initialize the BLIP and GIT models for image captioning
|
26 |
blip_model_name = "Salesforce/blip-image-captioning-large"
|
27 |
git_model_name = "microsoft/git-large-coco"
|
28 |
-
|
29 |
-
|
|
|
30 |
|
31 |
# Initialize the model for semantic similarity
|
32 |
model = SentenceTransformer('all-MiniLM-L6-v2')
|
|
|
20 |
)
|
21 |
|
22 |
import os
|
23 |
+
|
24 |
+
# Get the cache directory from the environment variable
|
25 |
+
hf_cache_dir = os.getenv("HF_HOME", default="/.cache")
|
26 |
+
|
27 |
|
28 |
# Initialize the BLIP and GIT models for image captioning
|
29 |
blip_model_name = "Salesforce/blip-image-captioning-large"
|
30 |
git_model_name = "microsoft/git-large-coco"
|
31 |
+
# Use hf_cache_dir in the model initialization
|
32 |
+
blip_pipeline = pipeline("image-to-text", model=blip_model_name, cache_dir=hf_cache_dir)
|
33 |
+
git_coco_pipeline = pipeline("image-to-text", model=git_model_name, cache_dir=hf_cache_dir)
|
34 |
|
35 |
# Initialize the model for semantic similarity
|
36 |
model = SentenceTransformer('all-MiniLM-L6-v2')
|