File size: 1,326 Bytes
66ef536
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
# ===============================
# Base image: includes Python 3.9, PyTorch (CPU), and Transformers
# ===============================
FROM huggingface/transformers-pytorch-cpu:latest

# Set working directory
WORKDIR /app

# ===============================
# Pre-download and cache model weights
# ===============================
RUN python -c "from transformers import AutoTokenizer, AutoModelForSequenceClassification; \
model='fakespot-ai/roberta-base-ai-text-detection-v1'; \
AutoTokenizer.from_pretrained(model, cache_dir='/app/model'); \
AutoModelForSequenceClassification.from_pretrained(model, cache_dir='/app/model')"

# ===============================
# Copy dependency list and install packages
# ===============================
COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt

# ===============================
# Copy application files
# ===============================
COPY . .

# ===============================
# Environment configuration
# ===============================
ENV TRANSFORMERS_CACHE=/app/model \
    HF_HOME=/app/model \
    PYTHONUNBUFFERED=1

# ===============================
# Expose Gradio default port
# ===============================
EXPOSE 7860

# ===============================
# Start the Gradio app
# ===============================
CMD ["python", "app.py"]