duclo90 commited on
Commit
9ef3372
·
verified ·
1 Parent(s): b24dad5

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +50 -10
app.py CHANGED
@@ -12,7 +12,12 @@ model.eval()
12
 
13
  def classify_text(text):
14
  if not text.strip():
15
- return "⚠️ Please enter some text to analyze."
 
 
 
 
 
16
 
17
  inputs = tokenizer(
18
  text,
@@ -27,14 +32,49 @@ def classify_text(text):
27
 
28
  label = model.config.id2label[pred.item()]
29
 
30
- # Format output with icons and styling
31
- icon = "👤" if label.lower() == "human" else "🤖"
32
-
33
- result = f"""
34
- ### {icon} Classification Result
35
-
36
- **Prediction:** {label}-Written Text
37
- """
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
38
 
39
  return result
40
 
@@ -104,7 +144,7 @@ iface = gr.Interface(
104
  label="Enter Text",
105
  elem_id="input-text"
106
  ),
107
- outputs=gr.Markdown(label="Analysis Result"),
108
  title="<div id='title'>🔍 AI Text Classifier</div>",
109
  description="<div id='description'>Detect whether text is human-written or AI-generated using advanced NLP</div>",
110
  theme=gr.themes.Soft(
 
12
 
13
  def classify_text(text):
14
  if not text.strip():
15
+ return """
16
+ <div style="text-align: center; padding: 40px; background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%); border-radius: 20px; color: white;">
17
+ <h2 style="margin: 0;">⚠️ Oops!</h2>
18
+ <p style="margin-top: 10px; font-size: 18px;">Please enter some text to analyze</p>
19
+ </div>
20
+ """
21
 
22
  inputs = tokenizer(
23
  text,
 
32
 
33
  label = model.config.id2label[pred.item()]
34
 
35
+ # Create attractive HTML output
36
+ if label.lower() == "human":
37
+ result = """
38
+ <div style="text-align: center; padding: 50px 30px; background: linear-gradient(135deg, #667eea 0%, #764ba2 100%); border-radius: 25px; box-shadow: 0 20px 60px rgba(0,0,0,0.3); animation: slideIn 0.5s ease-out;">
39
+ <div style="font-size: 80px; margin-bottom: 20px; animation: bounce 1s ease;">👤</div>
40
+ <h1 style="color: white; font-size: 42px; margin: 0; font-weight: 700; text-shadow: 2px 2px 4px rgba(0,0,0,0.2);">Human-Written</h1>
41
+ <p style="color: rgba(255,255,255,0.9); font-size: 20px; margin-top: 15px;">This text appears to be written by a human</p>
42
+ <div style="margin-top: 30px; padding: 15px 30px; background: rgba(255,255,255,0.2); border-radius: 15px; display: inline-block;">
43
+ <span style="color: white; font-size: 18px; font-weight: 600;">✨ Natural & Authentic</span>
44
+ </div>
45
+ </div>
46
+ <style>
47
+ @keyframes slideIn {
48
+ from { opacity: 0; transform: translateY(20px); }
49
+ to { opacity: 1; transform: translateY(0); }
50
+ }
51
+ @keyframes bounce {
52
+ 0%, 100% { transform: translateY(0); }
53
+ 50% { transform: translateY(-10px); }
54
+ }
55
+ </style>
56
+ """
57
+ else:
58
+ result = """
59
+ <div style="text-align: center; padding: 50px 30px; background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%); border-radius: 25px; box-shadow: 0 20px 60px rgba(0,0,0,0.3); animation: slideIn 0.5s ease-out;">
60
+ <div style="font-size: 80px; margin-bottom: 20px; animation: bounce 1s ease;">🤖</div>
61
+ <h1 style="color: white; font-size: 42px; margin: 0; font-weight: 700; text-shadow: 2px 2px 4px rgba(0,0,0,0.2);">AI-Generated</h1>
62
+ <p style="color: rgba(255,255,255,0.9); font-size: 20px; margin-top: 15px;">This text appears to be machine-generated</p>
63
+ <div style="margin-top: 30px; padding: 15px 30px; background: rgba(255,255,255,0.2); border-radius: 15px; display: inline-block;">
64
+ <span style="color: white; font-size: 18px; font-weight: 600;">⚡ AI-Powered Content</span>
65
+ </div>
66
+ </div>
67
+ <style>
68
+ @keyframes slideIn {
69
+ from { opacity: 0; transform: translateY(20px); }
70
+ to { opacity: 1; transform: translateY(0); }
71
+ }
72
+ @keyframes bounce {
73
+ 0%, 100% { transform: translateY(0); }
74
+ 50% { transform: translateY(-10px); }
75
+ }
76
+ </style>
77
+ """
78
 
79
  return result
80
 
 
144
  label="Enter Text",
145
  elem_id="input-text"
146
  ),
147
+ outputs=gr.HTML(label="Analysis Result"),
148
  title="<div id='title'>🔍 AI Text Classifier</div>",
149
  description="<div id='description'>Detect whether text is human-written or AI-generated using advanced NLP</div>",
150
  theme=gr.themes.Soft(