Spaces:
Running
on
Zero
Running
on
Zero
Advik
commited on
Commit
·
6a337be
1
Parent(s):
f53d5a5
potential cuda-xgb conflicts
Browse files
app.py
CHANGED
@@ -4,7 +4,6 @@ import os
|
|
4 |
import pandas as pd
|
5 |
from transformers import AutoModelForCausalLM, AutoTokenizer
|
6 |
import torch
|
7 |
-
import xgboost as xgb
|
8 |
import pandas as pd
|
9 |
import numpy as np
|
10 |
import torch
|
@@ -22,6 +21,12 @@ theme = gr.Theme.from_hub("gstaff/xkcd")
|
|
22 |
@spaces.GPU
|
23 |
def detect_ai_text(text):
|
24 |
global loaded
|
|
|
|
|
|
|
|
|
|
|
|
|
25 |
if not loaded:
|
26 |
return "❗ Model not loaded. We require a GPU to run DivEye.", 0.0, pd.DataFrame({
|
27 |
"Source": ["AI Generated", "Human Written"],
|
@@ -41,7 +46,7 @@ def detect_ai_text(text):
|
|
41 |
|
42 |
# Call software
|
43 |
# ===========================================================
|
44 |
-
global
|
45 |
|
46 |
# =====================================================================
|
47 |
# DivEye features
|
@@ -153,10 +158,7 @@ if torch.cuda.is_available():
|
|
153 |
|
154 |
div_model.eval()
|
155 |
bi_model.eval()
|
156 |
-
|
157 |
-
model_path = Path(__file__).parent / "model.json"
|
158 |
-
model = xgb.XGBClassifier()
|
159 |
-
model.load_model(model_path)
|
160 |
|
161 |
# Gradio app setup
|
162 |
with gr.Blocks(title="DivEye") as demo:
|
|
|
4 |
import pandas as pd
|
5 |
from transformers import AutoModelForCausalLM, AutoTokenizer
|
6 |
import torch
|
|
|
7 |
import pandas as pd
|
8 |
import numpy as np
|
9 |
import torch
|
|
|
21 |
@spaces.GPU
|
22 |
def detect_ai_text(text):
|
23 |
global loaded
|
24 |
+
|
25 |
+
import xgboost as xgb
|
26 |
+
model_path = Path(__file__).parent / "model.json"
|
27 |
+
model = xgb.XGBClassifier()
|
28 |
+
model.load_model(model_path)
|
29 |
+
|
30 |
if not loaded:
|
31 |
return "❗ Model not loaded. We require a GPU to run DivEye.", 0.0, pd.DataFrame({
|
32 |
"Source": ["AI Generated", "Human Written"],
|
|
|
46 |
|
47 |
# Call software
|
48 |
# ===========================================================
|
49 |
+
global div_model, div_tokenizer, bi_model, bi_tokenizer
|
50 |
|
51 |
# =====================================================================
|
52 |
# DivEye features
|
|
|
158 |
|
159 |
div_model.eval()
|
160 |
bi_model.eval()
|
161 |
+
|
|
|
|
|
|
|
162 |
|
163 |
# Gradio app setup
|
164 |
with gr.Blocks(title="DivEye") as demo:
|