Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -8,16 +8,22 @@ import string
|
|
8 |
import io
|
9 |
import os
|
10 |
import uvicorn
|
11 |
-
|
12 |
# β
Set Hugging Face Cache Directory (Fixes Permission Error)
|
13 |
-
|
14 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
15 |
|
16 |
# β
Initialize FastAPI
|
17 |
app = FastAPI()
|
18 |
-
|
19 |
# β
Load NSFW Image Classification Model (with custom cache directory)
|
20 |
-
pipe = pipeline("image-classification", model="LukeJacob2023/nsfw-image-detector", cache_dir="/tmp/hf_cache")
|
21 |
|
22 |
|
23 |
# β
Load Toxic Text Classification Model
|
|
|
8 |
import io
|
9 |
import os
|
10 |
import uvicorn
|
11 |
+
import os
|
12 |
# β
Set Hugging Face Cache Directory (Fixes Permission Error)
|
13 |
+
import os
|
14 |
+
|
15 |
+
# β
Set Hugging Face Cache to a writable directory
|
16 |
+
os.environ["TRANSFORMERS_CACHE"] = "/tmp/hf_cache"
|
17 |
+
os.environ["HF_HOME"] = "/tmp/hf_cache"
|
18 |
+
|
19 |
+
|
20 |
+
|
21 |
+
|
22 |
|
23 |
# β
Initialize FastAPI
|
24 |
app = FastAPI()
|
25 |
+
pipe = pipeline("image-classification", model="LukeJacob2023/nsfw-image-detector")
|
26 |
# β
Load NSFW Image Classification Model (with custom cache directory)
|
|
|
27 |
|
28 |
|
29 |
# β
Load Toxic Text Classification Model
|