Spaces:
Running
Running
Commit
·
3b37178
1
Parent(s):
4318933
handle both ar and eng
Browse files- Dockerfile +3 -3
- app.py +3 -3
Dockerfile
CHANGED
@@ -1,5 +1,5 @@
|
|
1 |
-
# Use Python 3.
|
2 |
-
FROM python:3.
|
3 |
|
4 |
# Set working directory in the container
|
5 |
WORKDIR /app
|
@@ -22,7 +22,7 @@ COPY --chown=myuser:myuser requirements.txt .
|
|
22 |
RUN pip install --no-cache-dir -r requirements.txt
|
23 |
|
24 |
# Clear cache and pre-download models
|
25 |
-
RUN rm -rf /app/.cache/huggingface/* && python -c "from transformers import pipeline, AutoTokenizer, AutoModelForCausalLM; pipeline('text-classification', model='Hello-SimpleAI/chatgpt-detector-roberta'); pipeline('text-classification', model='openai-community/roberta-large-openai-detector'); pipeline('text-classification', model='sabaridsnfuji/arabic-ai-text-detector'); AutoTokenizer.from_pretrained('gpt2'); AutoModelForCausalLM.from_pretrained('gpt2'); AutoTokenizer.from_pretrained('aubmindlab/
|
26 |
|
27 |
# Copy the application code
|
28 |
COPY --chown=myuser:myuser . .
|
|
|
1 |
+
# Use Python 3.9 as the base image
|
2 |
+
FROM python:3.9
|
3 |
|
4 |
# Set working directory in the container
|
5 |
WORKDIR /app
|
|
|
22 |
RUN pip install --no-cache-dir -r requirements.txt
|
23 |
|
24 |
# Clear cache and pre-download models
|
25 |
+
RUN rm -rf /app/.cache/huggingface/* && python -c "from transformers import pipeline, AutoTokenizer, AutoModelForCausalLM; pipeline('text-classification', model='Hello-SimpleAI/chatgpt-detector-roberta'); pipeline('text-classification', model='openai-community/roberta-large-openai-detector'); pipeline('text-classification', model='sabaridsnfuji/arabic-ai-text-detector'); AutoTokenizer.from_pretrained('gpt2'); AutoModelForCausalLM.from_pretrained('gpt2'); AutoTokenizer.from_pretrained('aubmindlab/aragpt2-base'); AutoModelForCausalLM.from_pretrained('aubmindlab/aragpt2-base')"
|
26 |
|
27 |
# Copy the application code
|
28 |
COPY --chown=myuser:myuser . .
|
app.py
CHANGED
@@ -2,7 +2,7 @@ from fastapi import FastAPI, HTTPException
|
|
2 |
from pydantic import BaseModel, validator
|
3 |
import re
|
4 |
import torch
|
5 |
-
from transformers import
|
6 |
from collections import Counter
|
7 |
import logging
|
8 |
import numpy as np
|
@@ -29,8 +29,8 @@ ppl_english = {
|
|
29 |
"model": AutoModelForCausalLM.from_pretrained("gpt2").to(device)
|
30 |
}
|
31 |
ppl_arabic = {
|
32 |
-
"tokenizer": AutoTokenizer.from_pretrained("aubmindlab/
|
33 |
-
"model": AutoModelForCausalLM.from_pretrained("aubmindlab/
|
34 |
}
|
35 |
|
36 |
def detect_language(text: str) -> str:
|
|
|
2 |
from pydantic import BaseModel, validator
|
3 |
import re
|
4 |
import torch
|
5 |
+
from transformers import pipeline, AutoTokenizer, AutoModelForCausalLM
|
6 |
from collections import Counter
|
7 |
import logging
|
8 |
import numpy as np
|
|
|
29 |
"model": AutoModelForCausalLM.from_pretrained("gpt2").to(device)
|
30 |
}
|
31 |
ppl_arabic = {
|
32 |
+
"tokenizer": AutoTokenizer.from_pretrained("aubmindlab/aragpt2-base"),
|
33 |
+
"model": AutoModelForCausalLM.from_pretrained("aubmindlab/aragpt2-base").to(device)
|
34 |
}
|
35 |
|
36 |
def detect_language(text: str) -> str:
|