Spaces:
Running
Running
Upload folder using huggingface_hub
Browse files- Dockerfile +1 -5
- app.py +4 -7
Dockerfile
CHANGED
|
@@ -9,11 +9,7 @@ RUN pip install --no-cache-dir -r requirements.txt
|
|
| 9 |
# Copy app code
|
| 10 |
COPY . .
|
| 11 |
|
| 12 |
-
# Pre-download model weights during build
|
| 13 |
-
COPY app_preload.py /app/app_preload.py
|
| 14 |
-
RUN python app_preload.py && rm app_preload.py
|
| 15 |
-
|
| 16 |
# Remove build-time files
|
| 17 |
-
RUN rm -f requirements.txt Dockerfile
|
| 18 |
|
| 19 |
CMD ["python", "app.py"]
|
|
|
|
| 9 |
# Copy app code
|
| 10 |
COPY . .
|
| 11 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 12 |
# Remove build-time files
|
| 13 |
+
RUN rm -f requirements.txt Dockerfile app_preload.py
|
| 14 |
|
| 15 |
CMD ["python", "app.py"]
|
app.py
CHANGED
|
@@ -7,14 +7,11 @@ from tinydoc_vlm import TinyDocVLMForConditionalGeneration, TinyDocVLMProcessor
|
|
| 7 |
|
| 8 |
MODEL_ID = "eulogik/TinyDoc-VLM-256M"
|
| 9 |
device = "cuda" if torch.cuda.is_available() else "cpu"
|
|
|
|
| 10 |
|
| 11 |
-
print(f"Loading {MODEL_ID} on {device}
|
| 12 |
-
model = TinyDocVLMForConditionalGeneration.from_pretrained(
|
| 13 |
-
|
| 14 |
-
torch_dtype=torch.float16,
|
| 15 |
-
low_cpu_mem_usage=True,
|
| 16 |
-
)
|
| 17 |
-
model.to(device).half().eval()
|
| 18 |
processor = TinyDocVLMProcessor()
|
| 19 |
print("Model loaded!")
|
| 20 |
|
|
|
|
| 7 |
|
| 8 |
MODEL_ID = "eulogik/TinyDoc-VLM-256M"
|
| 9 |
device = "cuda" if torch.cuda.is_available() else "cpu"
|
| 10 |
+
dtype = torch.float16 if torch.cuda.is_available() else torch.float32
|
| 11 |
|
| 12 |
+
print(f"Loading {MODEL_ID} on {device}...")
|
| 13 |
+
model = TinyDocVLMForConditionalGeneration.from_pretrained(MODEL_ID)
|
| 14 |
+
model.to(device).eval()
|
|
|
|
|
|
|
|
|
|
|
|
|
| 15 |
processor = TinyDocVLMProcessor()
|
| 16 |
print("Model loaded!")
|
| 17 |
|