Spaces:
Running
on
CPU Upgrade
Running
on
CPU Upgrade
Commit
·
ac9c6c1
1
Parent(s):
7b2eca8
Moved pth file to HF dataset
Browse files- .dockerignore +33 -0
- Dockerfile +3 -0
- vit_captioning/generate.py +9 -3
.dockerignore
ADDED
@@ -0,0 +1,33 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# Bytecode, cache, notebooks
|
2 |
+
__pycache__/
|
3 |
+
*.pyc
|
4 |
+
*.pyo
|
5 |
+
*.pyd
|
6 |
+
*.ipynb
|
7 |
+
*.ipynb_checkpoints
|
8 |
+
|
9 |
+
# Virtual environments and editor files
|
10 |
+
.env
|
11 |
+
.venv/
|
12 |
+
*.log
|
13 |
+
.DS_Store
|
14 |
+
.vscode/
|
15 |
+
.idea/
|
16 |
+
|
17 |
+
# Git and Hugging Face system files
|
18 |
+
.git/
|
19 |
+
*.gitignore
|
20 |
+
|
21 |
+
# Local data/artifacts
|
22 |
+
artifacts/
|
23 |
+
data/
|
24 |
+
datasets/
|
25 |
+
checkpoints/
|
26 |
+
clip-checkpoints/
|
27 |
+
*.pt
|
28 |
+
*.pth
|
29 |
+
*.onnx
|
30 |
+
|
31 |
+
# Docker or Space-specific
|
32 |
+
docker-compose.yaml
|
33 |
+
Caddyfile
|
Dockerfile
CHANGED
@@ -4,6 +4,9 @@ FROM python:3.11-slim
|
|
4 |
WORKDIR /app
|
5 |
COPY . .
|
6 |
|
|
|
|
|
|
|
7 |
RUN pip install --upgrade pip
|
8 |
RUN pip install -r requirements.txt
|
9 |
|
|
|
4 |
WORKDIR /app
|
5 |
COPY . .
|
6 |
|
7 |
+
RUN wget https://huggingface.co/datasets/ClemSummer/clip-checkpoints/resolve/main/CLIPEncoder_40epochs_unfreeze12.pth \
|
8 |
+
-O vit_captioning/artifacts/CLIPEncoder_40epochs_unfreeze12.pth
|
9 |
+
|
10 |
RUN pip install --upgrade pip
|
11 |
RUN pip install -r requirements.txt
|
12 |
|
vit_captioning/generate.py
CHANGED
@@ -24,17 +24,23 @@ class CaptionGenerator:
|
|
24 |
print("No GPU found, falling back to CPU.")
|
25 |
|
26 |
# Load tokenizer
|
27 |
-
self.tokenizer = AutoTokenizer.from_pretrained('bert-base-uncased')
|
|
|
|
|
28 |
|
29 |
# Select encoder, processor, output dim
|
30 |
if model_type == "ViTEncoder":
|
31 |
self.encoder = ViTEncoder().to(self.device)
|
32 |
self.encoder_dim = 768
|
33 |
-
self.processor = ViTImageProcessor.from_pretrained("google/vit-base-patch16-224-in21k")
|
|
|
|
|
34 |
elif model_type == "CLIPEncoder":
|
35 |
self.encoder = CLIPEncoder().to(self.device)
|
36 |
self.encoder_dim = 512
|
37 |
-
self.processor = CLIPProcessor.from_pretrained("openai/clip-vit-base-patch32")
|
|
|
|
|
38 |
else:
|
39 |
raise ValueError("Unknown model type")
|
40 |
|
|
|
24 |
print("No GPU found, falling back to CPU.")
|
25 |
|
26 |
# Load tokenizer
|
27 |
+
#self.tokenizer = AutoTokenizer.from_pretrained('bert-base-uncased')
|
28 |
+
#HF needs all model downloads to a special read-write cache dir
|
29 |
+
self.tokenizer = AutoTokenizer.from_pretrained('bert-base-uncased', cache_dir="/data")
|
30 |
|
31 |
# Select encoder, processor, output dim
|
32 |
if model_type == "ViTEncoder":
|
33 |
self.encoder = ViTEncoder().to(self.device)
|
34 |
self.encoder_dim = 768
|
35 |
+
#self.processor = ViTImageProcessor.from_pretrained("google/vit-base-patch16-224-in21k")
|
36 |
+
#HF needs all model downloads to a special read-write cache dir
|
37 |
+
self.processor = ViTImageProcessor.from_pretrained("google/vit-base-patch16-224-in21k", cache_dir="/data")
|
38 |
elif model_type == "CLIPEncoder":
|
39 |
self.encoder = CLIPEncoder().to(self.device)
|
40 |
self.encoder_dim = 512
|
41 |
+
#self.processor = CLIPProcessor.from_pretrained("openai/clip-vit-base-patch32")
|
42 |
+
#HF needs all model downloads to a special read-write cache dir
|
43 |
+
self.processor = CLIPProcessor.from_pretrained("openai/clip-vit-base-patch32", cache_dir="/data")
|
44 |
else:
|
45 |
raise ValueError("Unknown model type")
|
46 |
|