File size: 1,669 Bytes
116a187
4827f56
1d55c54
 
 
 
116a187
 
 
1d55c54
116a187
 
 
 
 
 
 
 
 
 
 
 
81b7736
 
116a187
 
c4af1bb
116a187
 
 
 
 
 
1d55c54
c4af1bb
1d55c54
ca81b44
c4af1bb
1d55c54
116a187
 
 
1d55c54
 
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
39
40
41
42
43
44
45
# Custom docker image for DeTikZify. The default HF Spaces GPU image installs a
# tex live version that is too old for our needs, so we install the correct one
# ourselves. This simplified Dockerfile is based on an intermediate image
# (./Dockerfile.base) that already has Tex Live and pyenv installed, thereby
# greatly improving build time. It also defers preloading of detikzify models
# to runtime to avoid OOM errors.

## system setup
# -----------------------------------------------------------------------------
FROM registry.hf.space/nllg-detikzify:gpu-7ec758b-nmbqkl3l

## setup user
# -----------------------------------------------------------------------------
RUN useradd -m -G users -u 1000 user

ENV HOME=/home/user \
  PATH=/home/user/.local/bin:$PATH

WORKDIR $HOME/app

## install python dependencies
# -----------------------------------------------------------------------------
RUN pyenv install 3.11 \
  && pyenv global 3.11 \
  && pyenv rehash \
  && pip install --no-cache-dir --upgrade setuptools wheel \
  && pip install --no-cache-dir 'detikzify[legacy] @ git+https://github.com/potamides/DeTikZify' \
  && pip install --no-cache-dir flash-attn --no-build-isolation \
  && pip install --no-cache-dir spaces

RUN chown -R user $HOME/app
COPY --chown=user . $HOME/app

## prepare cache for models
# -----------------------------------------------------------------------------
RUN mkdir -p $HOME/.cache \
  && chown -R user $HOME/.cache

## preload detikzify-v2.5 and launch app
# -----------------------------------------------------------------------------
USER user

CMD huggingface-cli download nllg/detikzify-v2.5-8b \
  && python app.py