InfosysResponsibleAiToolKit commited on
Commit
c308e29
·
1 Parent(s): 6619f2b

Dockerfile

Browse files
Files changed (2) hide show
  1. .gitattributes +1 -0
  2. Dockerfile +57 -0
.gitattributes CHANGED
@@ -33,3 +33,4 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
33
  *.zip filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
 
 
33
  *.zip filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
36
+ *.whl filter=lfs diff=lfs merge=lfs -text
Dockerfile ADDED
@@ -0,0 +1,57 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ FROM python:3.10
2
+
3
+ # Set environment variables to force Hugging Face to use a fresh cache directory
4
+ ENV TRANSFORMERS_CACHE=/tmp/transformers_cache
5
+ ENV HF_HOME=/tmp/huggingface_cache
6
+
7
+ # Clean Hugging Face cache
8
+ RUN rm -rf ~/.cache/huggingface/transformers
9
+
10
+ # Install system dependencies
11
+ RUN apt-get update && apt-get install -y git wget git-lfs && git lfs install && apt-get clean
12
+
13
+ # Create a non-root user
14
+ RUN useradd -m -u 1000 user
15
+
16
+ # Create directory for repo and give access to non-root user
17
+ RUN mkdir /ModerationModelCode && chown -R user:user /ModerationModelCode
18
+
19
+ USER user
20
+ ENV PATH="/home/user/.local/bin:$PATH"
21
+
22
+ # Clone the repo with LFS files
23
+ USER root
24
+ ARG CACHEBUST=4
25
+ RUN GIT_LFS_SKIP_SMUDGE=0 git clone --depth 1 https://huggingface.co/InfosysEnterprise/ModerationModelCode /ModerationModelCode
26
+ RUN git config --global --add safe.directory /ModerationModelCode
27
+ RUN cd /Responsible-Ai-Moderation-Models && git log -1 --oneline && rm -rf .git
28
+
29
+ USER user
30
+
31
+ # Check models directory and files
32
+ RUN ls -lR /ModerationModelCode/models
33
+ RUN find /ModerationModelCode/models -type f -exec ls -lh {} +
34
+
35
+ # Copy local files to Docker (if needed)
36
+ COPY --chown=user . /ModerationModelCode
37
+
38
+ WORKDIR /ModerationModelCode
39
+
40
+ # Install .whl files
41
+ RUN pip install --no-cache-dir /ModerationModelCode/lib/privacy-2.0.8-py3-none-any.whl
42
+ RUN pip install --no-cache-dir /ModerationModelCode/lib/en_core_web_lg-3.5.0-py3-none-any.whl
43
+
44
+ # Install PyTorch and Transformers
45
+ RUN pip install torch==2.2.0 torchvision==0.17.0 --index-url https://download.pytorch.org/whl/cpu
46
+ RUN pip install transformers==4.48.0 diffusers==0.27.2
47
+
48
+ # Install additional requirements
49
+ RUN pip install --user --no-cache-dir -r requirements/requirement.txt
50
+
51
+ WORKDIR /ModerationModelCode/src
52
+
53
+ # Expose Hugging Face Spaces port
54
+ EXPOSE 7860
55
+
56
+ # Run main app
57
+ CMD ["python", "main.py"]