Spaces:
Running
on
Zero
Running
on
Zero
Advik
commited on
Commit
·
37536e7
1
Parent(s):
9ad170e
app pickle and multiproc changes
Browse files
app.py
CHANGED
|
@@ -3,9 +3,23 @@ import numpy as np
|
|
| 3 |
import pandas as pd
|
| 4 |
from software import Software
|
| 5 |
|
| 6 |
-
software =
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 7 |
|
| 8 |
def detect_ai_text(text):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 9 |
text = text.strip()
|
| 10 |
if not text or len(text.split()) < 15:
|
| 11 |
return (
|
|
@@ -36,8 +50,8 @@ def detect_ai_text(text):
|
|
| 36 |
return message, round(ai_prob, 3), bar_data
|
| 37 |
|
| 38 |
# Gradio app setup
|
| 39 |
-
with gr.Blocks(title="DivEye", theme=
|
| 40 |
-
|
| 41 |
gr.HTML("""
|
| 42 |
<div style="display: flex; justify-content: space-between; align-items: center; padding: 1.5rem; background: #f0f4f8; border-radius: 12px; margin-bottom: 1rem;">
|
| 43 |
<div style="text-align: left; max-width: 70%;">
|
|
|
|
| 3 |
import pandas as pd
|
| 4 |
from software import Software
|
| 5 |
|
| 6 |
+
software = None
|
| 7 |
+
theme = gr.Theme.from_hub("gstaff/xkcd")
|
| 8 |
+
|
| 9 |
+
def warmup():
|
| 10 |
+
global software
|
| 11 |
+
print("[DivEye] Warming up models...")
|
| 12 |
+
software = Software()
|
| 13 |
+
print("[DivEye] Models are ready.")
|
| 14 |
|
| 15 |
def detect_ai_text(text):
|
| 16 |
+
global software
|
| 17 |
+
if software is None:
|
| 18 |
+
return "❗ Models not loaded yet. Please wait for a few moments.", 0.0, pd.DataFrame({
|
| 19 |
+
"Source": ["AI Generated", "Human Written"],
|
| 20 |
+
"Probability (%)": [0, 0]
|
| 21 |
+
})
|
| 22 |
+
|
| 23 |
text = text.strip()
|
| 24 |
if not text or len(text.split()) < 15:
|
| 25 |
return (
|
|
|
|
| 50 |
return message, round(ai_prob, 3), bar_data
|
| 51 |
|
| 52 |
# Gradio app setup
|
| 53 |
+
with gr.Blocks(title="DivEye", theme=theme) as demo:
|
| 54 |
+
demo.on_start(warmup)
|
| 55 |
gr.HTML("""
|
| 56 |
<div style="display: flex; justify-content: space-between; align-items: center; padding: 1.5rem; background: #f0f4f8; border-radius: 12px; margin-bottom: 1rem;">
|
| 57 |
<div style="text-align: left; max-width: 70%;">
|