Ozgur Unlu
commited on
Commit
β’
052a382
1
Parent(s):
62a1dcb
UI changesi still on CPU
Browse files- interface.py +59 -27
interface.py
CHANGED
@@ -2,36 +2,68 @@ import gradio as gr
|
|
2 |
from analyzer import analyze_ad_copy
|
3 |
|
4 |
def create_interface():
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
5 |
demo = gr.Interface(
|
6 |
fn=analyze_ad_copy,
|
7 |
-
inputs=
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
|
|
|
|
|
|
|
|
|
|
16 |
title="Marketing Campaign Compliance Checker",
|
17 |
description="Upload marketing material to check compliance with US (SEC), UK (FCA), and EU financial regulations.",
|
18 |
-
|
19 |
-
|
20 |
-
.report-container { font-family: 'Arial', sans-serif; padding: 20px; }
|
21 |
-
.status { font-size: 1.2em; margin-bottom: 20px; padding: 10px; border-radius: 5px; }
|
22 |
-
.compliant { background-color: #e7f5e7; color: #0d5f0d; }
|
23 |
-
.non-compliant { background-color: #fce8e8; color: #c41e3a; }
|
24 |
-
.section { margin: 15px 0; }
|
25 |
-
.section-title { font-weight: bold; color: #2c3e50; margin: 10px 0; }
|
26 |
-
.item { margin: 5px 0 5px 20px; }
|
27 |
-
.severity-high { color: #c41e3a; }
|
28 |
-
.severity-medium { color: #f39c12; }
|
29 |
-
.severity-low { color: #27ae60; }
|
30 |
-
.risk-high { background-color: #fce8e8; }
|
31 |
-
.risk-medium { background-color: #fff3cd; }
|
32 |
-
.risk-low { background-color: #e7f5e7; }
|
33 |
-
.channel { margin: 10px 0; padding: 10px; border-radius: 5px; }
|
34 |
-
.details { margin-left: 20px; font-size: 0.9em; color: #555; }
|
35 |
-
"""
|
36 |
)
|
37 |
return demo
|
|
|
2 |
from analyzer import analyze_ad_copy
|
3 |
|
4 |
def create_interface():
|
5 |
+
css = """
|
6 |
+
.report-container { font-family: 'Arial', sans-serif; padding: 20px; }
|
7 |
+
.status { font-size: 1.2em; margin-bottom: 20px; padding: 10px; border-radius: 5px; }
|
8 |
+
.compliant { background-color: #e7f5e7; color: #0d5f0d; }
|
9 |
+
.non-compliant { background-color: #fce8e8; color: #c41e3a; }
|
10 |
+
.section { margin: 15px 0; }
|
11 |
+
.section-title { font-weight: bold; color: #2c3e50; margin: 10px 0; }
|
12 |
+
.item { margin: 5px 0 5px 20px; }
|
13 |
+
.severity-high { color: #c41e3a; }
|
14 |
+
.severity-medium { color: #f39c12; }
|
15 |
+
.severity-low { color: #27ae60; }
|
16 |
+
.risk-high { background-color: #fce8e8; }
|
17 |
+
.risk-medium { background-color: #fff3cd; }
|
18 |
+
.risk-low { background-color: #e7f5e7; }
|
19 |
+
.channel { margin: 10px 0; padding: 10px; border-radius: 5px; }
|
20 |
+
.details { margin-left: 20px; font-size: 0.9em; color: #555; }
|
21 |
+
.placeholder {
|
22 |
+
padding: 20px;
|
23 |
+
background-color: #f8f9fa;
|
24 |
+
border: 1px dashed #dee2e6;
|
25 |
+
border-radius: 5px;
|
26 |
+
color: #6c757d;
|
27 |
+
text-align: center;
|
28 |
+
}
|
29 |
+
"""
|
30 |
+
|
31 |
+
# Create a placeholder HTML
|
32 |
+
placeholder_html = """
|
33 |
+
<div class="report-container">
|
34 |
+
<div class="placeholder">
|
35 |
+
<h3>π Compliance Report Will Appear Here</h3>
|
36 |
+
<p>Upload a marketing material image and click "Submit" to analyze compliance with financial regulations.</p>
|
37 |
+
<p>The report will check:</p>
|
38 |
+
<ul style="list-style-type: none; padding: 0;">
|
39 |
+
<li>β Prohibited financial terms</li>
|
40 |
+
<li>β Required disclaimers</li>
|
41 |
+
<li>β Multi-region compliance</li>
|
42 |
+
<li>β Channel-specific risks</li>
|
43 |
+
</ul>
|
44 |
+
</div>
|
45 |
+
</div>
|
46 |
+
"""
|
47 |
+
|
48 |
demo = gr.Interface(
|
49 |
fn=analyze_ad_copy,
|
50 |
+
inputs=[
|
51 |
+
gr.Image(
|
52 |
+
type="numpy",
|
53 |
+
label="Upload Marketing Material",
|
54 |
+
height=300,
|
55 |
+
width=400
|
56 |
+
)
|
57 |
+
],
|
58 |
+
outputs=[
|
59 |
+
gr.HTML(
|
60 |
+
label="Compliance Report",
|
61 |
+
value=placeholder_html # Set the initial placeholder
|
62 |
+
)
|
63 |
+
],
|
64 |
title="Marketing Campaign Compliance Checker",
|
65 |
description="Upload marketing material to check compliance with US (SEC), UK (FCA), and EU financial regulations.",
|
66 |
+
css=css,
|
67 |
+
theme=gr.themes.Default()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
68 |
)
|
69 |
return demo
|