Kuberwastaken commited on
Commit
b4b3712
·
1 Parent(s): 83c0537

Fixed Runtime error

Browse files
Files changed (1) hide show
  1. gradio_app.py +22 -17
gradio_app.py CHANGED
@@ -5,6 +5,12 @@ import time
5
 
6
  # Custom CSS for styling
7
  custom_css = """
 
 
 
 
 
 
8
  .treat-title {
9
  text-align: center;
10
  padding: 20px;
@@ -31,7 +37,7 @@ custom_css = """
31
  font-weight: bold;
32
  }
33
 
34
- .content-box {
35
  background: rgba(255, 255, 255, 0.9);
36
  border-radius: 15px;
37
  padding: 20px;
@@ -39,7 +45,7 @@ custom_css = """
39
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
40
  }
41
 
42
- .results-box {
43
  background: rgba(255, 255, 255, 0.9);
44
  border-radius: 15px;
45
  padding: 20px;
@@ -48,10 +54,10 @@ custom_css = """
48
  }
49
 
50
  .gradio-container {
51
- background: linear-gradient(135deg, #fce4ec 0%, #e3f2fd 100%);
52
  }
53
 
54
- .analyze-button {
55
  background-color: #d81b60 !important;
56
  color: white !important;
57
  border-radius: 25px !important;
@@ -60,7 +66,7 @@ custom_css = """
60
  transition: transform 0.2s !important;
61
  }
62
 
63
- .analyze-button:hover {
64
  transform: scale(1.05) !important;
65
  }
66
  """
@@ -71,7 +77,7 @@ def analyze_with_loading(text, progress=gr.Progress()):
71
 
72
  # Simulate initial loading (model preparation)
73
  for i in range(30):
74
- time.sleep(0.1) # Reduced sleep time for better UX
75
  progress((i + 1) / 100)
76
 
77
  # Perform actual analysis
@@ -80,7 +86,7 @@ def analyze_with_loading(text, progress=gr.Progress()):
80
 
81
  # Simulate final processing
82
  for i in range(70, 100):
83
- time.sleep(0.05) # Reduced sleep time
84
  progress((i + 1) / 100)
85
 
86
  # Format the results for display
@@ -92,19 +98,19 @@ def analyze_with_loading(text, progress=gr.Progress()):
92
  return f"Triggers Detected:\n{trigger_list}"
93
 
94
  with gr.Blocks(css=custom_css) as iface:
95
- # Title section
96
- with gr.Box(elem_classes="treat-title"):
97
- gr.HTML("""
98
  <h1>TREAT</h1>
99
  <p><span class="highlight">T</span>rigger
100
  <span class="highlight">R</span>ecognition for
101
  <span class="highlight">E</span>njoyable and
102
  <span class="highlight">A</span>ppropriate
103
  <span class="highlight">T</span>elevision</p>
104
- """)
 
105
 
106
- # Content input section
107
- with gr.Box(elem_classes="content-box"):
108
  input_text = gr.Textbox(
109
  label="Content to Analyze",
110
  placeholder="Paste your content here...",
@@ -113,12 +119,11 @@ with gr.Blocks(css=custom_css) as iface:
113
 
114
  # Analysis button
115
  analyze_btn = gr.Button(
116
- "Analyze Content",
117
- elem_classes="analyze-button"
118
  )
119
 
120
- # Results section
121
- with gr.Box(elem_classes="results-box"):
122
  output_text = gr.Textbox(
123
  label="Analysis Results",
124
  lines=5,
 
5
 
6
  # Custom CSS for styling
7
  custom_css = """
8
+ .container {
9
+ max-width: 800px;
10
+ margin: 0 auto;
11
+ padding: 20px;
12
+ }
13
+
14
  .treat-title {
15
  text-align: center;
16
  padding: 20px;
 
37
  font-weight: bold;
38
  }
39
 
40
+ .content-area {
41
  background: rgba(255, 255, 255, 0.9);
42
  border-radius: 15px;
43
  padding: 20px;
 
45
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
46
  }
47
 
48
+ .results-area {
49
  background: rgba(255, 255, 255, 0.9);
50
  border-radius: 15px;
51
  padding: 20px;
 
54
  }
55
 
56
  .gradio-container {
57
+ background: linear-gradient(135deg, #fce4ec 0%, #e3f2fd 100%) !important;
58
  }
59
 
60
+ #analyze-btn {
61
  background-color: #d81b60 !important;
62
  color: white !important;
63
  border-radius: 25px !important;
 
66
  transition: transform 0.2s !important;
67
  }
68
 
69
+ #analyze-btn:hover {
70
  transform: scale(1.05) !important;
71
  }
72
  """
 
77
 
78
  # Simulate initial loading (model preparation)
79
  for i in range(30):
80
+ time.sleep(0.1)
81
  progress((i + 1) / 100)
82
 
83
  # Perform actual analysis
 
86
 
87
  # Simulate final processing
88
  for i in range(70, 100):
89
+ time.sleep(0.05)
90
  progress((i + 1) / 100)
91
 
92
  # Format the results for display
 
98
  return f"Triggers Detected:\n{trigger_list}"
99
 
100
  with gr.Blocks(css=custom_css) as iface:
101
+ # Title section using HTML
102
+ gr.HTML("""
103
+ <div class="treat-title">
104
  <h1>TREAT</h1>
105
  <p><span class="highlight">T</span>rigger
106
  <span class="highlight">R</span>ecognition for
107
  <span class="highlight">E</span>njoyable and
108
  <span class="highlight">A</span>ppropriate
109
  <span class="highlight">T</span>elevision</p>
110
+ </div>
111
+ """)
112
 
113
+ with gr.Column(elem_classes="content-area"):
 
114
  input_text = gr.Textbox(
115
  label="Content to Analyze",
116
  placeholder="Paste your content here...",
 
119
 
120
  # Analysis button
121
  analyze_btn = gr.Button(
122
+ "Analyze Content",
123
+ elem_id="analyze-btn"
124
  )
125
 
126
+ with gr.Column(elem_classes="results-area"):
 
127
  output_text = gr.Textbox(
128
  label="Analysis Results",
129
  lines=5,