Spaces:
Sleeping
Sleeping
File size: 1,020 Bytes
4f48282 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
from pathlib import Path
from urllib.request import urlopen
from uuid import uuid4
import modal
MINUTES = 60 # seconds
app = modal.App("chat-with-pdf")
CACHE_DIR = "/hf-cache"
model_image = (
modal.Image.debian_slim(python_version="3.12")
.apt_install("git")
.pip_install(
[
"git+https://github.com/illuin-tech/colpali.git@782edcd50108d1842d154730ad3ce72476a2d17d", # we pin the commit id
"hf_transfer==0.1.8",
"qwen-vl-utils==0.0.8",
"torchvision==0.19.1",
]
)
.env({"HF_HUB_ENABLE_HF_TRANSFER": "1", "HF_HUB_CACHE": CACHE_DIR})
)
# These dependencies are only installed remotely, so we can’t import them locally. Use the .imports context manager to import them only on Modal instead.
with model_image.imports():
import torch
from colpali_engine.models import ColQwen2, ColQwen2Processor
from qwen_vl_utils import process_vision_info
from transformers import AutoProcessor, Qwen2VLForConditionalGeneration
|