Spaces:
Runtime error
Runtime error
John Doe
commited on
Commit
·
3ab5798
1
Parent(s):
73df9d6
fix error
Browse files- Dockerfile +7 -4
- download_models.py +6 -0
- image_moderator.py +1 -1
Dockerfile
CHANGED
@@ -1,10 +1,13 @@
|
|
1 |
-
FROM python:3.9
|
2 |
|
3 |
WORKDIR /app
|
4 |
|
5 |
-
COPY .
|
6 |
-
|
7 |
-
RUN pip install --upgrade pip
|
8 |
RUN pip install -r requirements.txt
|
9 |
|
|
|
|
|
|
|
|
|
|
|
10 |
CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "7860"]
|
|
|
1 |
+
FROM python:3.9
|
2 |
|
3 |
WORKDIR /app
|
4 |
|
5 |
+
COPY requirements.txt .
|
|
|
|
|
6 |
RUN pip install -r requirements.txt
|
7 |
|
8 |
+
COPY . .
|
9 |
+
|
10 |
+
# Download models at build time
|
11 |
+
RUN python download_models.py
|
12 |
+
|
13 |
CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "7860"]
|
download_models.py
ADDED
@@ -0,0 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from transformers import pipeline
|
2 |
+
|
3 |
+
# This will download and cache the model
|
4 |
+
print("Downloading toxic-bert model...")
|
5 |
+
_ = pipeline("text-classification", model="unitary/toxic-bert")
|
6 |
+
print("Done.")
|
image_moderator.py
CHANGED
@@ -68,7 +68,7 @@ from transformers import pipeline
|
|
68 |
from better_profanity import profanity
|
69 |
|
70 |
# Load profanity model
|
71 |
-
toxic_classifier = pipeline("text-classification", model="unitary/toxic-bert")
|
72 |
profanity.load_censor_words()
|
73 |
custom_words = [
|
74 |
"idiot", "moron", "dumb", "stupid", "loser", "bastard", "retard", "scumbag",
|
|
|
68 |
from better_profanity import profanity
|
69 |
|
70 |
# Load profanity model
|
71 |
+
toxic_classifier = pipeline("text-classification", model="unitary/toxic-bert", cache_dir="./")
|
72 |
profanity.load_censor_words()
|
73 |
custom_words = [
|
74 |
"idiot", "moron", "dumb", "stupid", "loser", "bastard", "retard", "scumbag",
|