File size: 915 Bytes
1e7ca15
 
 
 
 
 
 
 
7806632
 
1e7ca15
 
 
 
 
 
 
 
ce9ddaa
 
 
 
 
 
 
 
1e7ca15
 
 
 
 
 
 
 
 
 
 
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
37
38
FROM python:3.10-slim

# Install system dependencies
RUN apt-get update && apt-get install -y \
    tesseract-ocr \
    tesseract-ocr-mar \
    tesseract-ocr-hin \
    poppler-utils \
    libgl1 \
    libglx-mesa0 \
    libglib2.0-0 \
    git \
    build-essential \
    && rm -rf /var/lib/apt/lists/*

WORKDIR /app

COPY requirements.txt .

# Install Torch for CPU first (to avoid dependency issues with detectron2)
RUN pip install --no-cache-dir torch torchvision --index-url https://download.pytorch.org/whl/cpu

# Install Detectron2 with CPU flags
RUN FORCE_CUDA=0 pip install --no-cache-dir 'git+https://github.com/facebookresearch/detectron2.git'

# Install the rest of the requirements
RUN pip install --no-cache-dir -r requirements.txt

COPY . .

# Hugging Face Spaces uses user 1000
RUN useradd -m -u 1000 user
USER user
ENV HOME=/home/user \
    PATH=/home/user/.local/bin:$PATH

CMD ["python", "app.py"]