Spaces:
Sleeping
Sleeping
Commit
·
527842b
1
Parent(s):
8ef4148
update css
Browse files- .gitignore +1 -0
- app.py +10 -14
.gitignore
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
.env
|
app.py
CHANGED
|
@@ -51,7 +51,12 @@ def on_run(image, ptxt, social, agent_name, agent_phone,
|
|
| 51 |
)
|
| 52 |
return json.dumps(payload, indent=2)
|
| 53 |
|
| 54 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 55 |
gr.Markdown("# Image + Text Compliance Check")
|
| 56 |
|
| 57 |
with gr.Row():
|
|
@@ -87,7 +92,7 @@ with gr.Blocks(title="Image + Text Compliance Check") as demo:
|
|
| 87 |
with gr.Row():
|
| 88 |
fair_housing_out = gr.Textbox(label="Fair Housing", interactive=False)
|
| 89 |
ptxt_out = gr.Textbox(label="Post Text", interactive=False)
|
| 90 |
-
img_out = gr.Textbox(label="Image Text", interactive=False)
|
| 91 |
|
| 92 |
def update_results(results_json):
|
| 93 |
results = json.loads(results_json)
|
|
@@ -99,24 +104,15 @@ with gr.Blocks(title="Image + Text Compliance Check") as demo:
|
|
| 99 |
return {
|
| 100 |
fair_housing_out: gr.update(
|
| 101 |
value="Compliant" if fh_compliant else "Not Compliant",
|
| 102 |
-
|
| 103 |
-
"background-color": "green" if fh_compliant else "red",
|
| 104 |
-
"color": "white",
|
| 105 |
-
}
|
| 106 |
),
|
| 107 |
ptxt_out: gr.update(
|
| 108 |
value="Compliant" if ptxt_compliant else "Not Compliant",
|
| 109 |
-
|
| 110 |
-
"background-color": "green" if ptxt_compliant else "red",
|
| 111 |
-
"color": "white",
|
| 112 |
-
}
|
| 113 |
),
|
| 114 |
img_out: gr.update(
|
| 115 |
value="Compliant" if img_compliant else "Not Compliant",
|
| 116 |
-
|
| 117 |
-
"background-color": "green" if img_compliant else "red",
|
| 118 |
-
"color": "white",
|
| 119 |
-
}
|
| 120 |
)
|
| 121 |
}
|
| 122 |
|
|
|
|
| 51 |
)
|
| 52 |
return json.dumps(payload, indent=2)
|
| 53 |
|
| 54 |
+
css = """
|
| 55 |
+
.compliant { background-color: green; color: white; }
|
| 56 |
+
.not-compliant { background-color: red; color: white; }
|
| 57 |
+
"""
|
| 58 |
+
|
| 59 |
+
with gr.Blocks(title="Image + Text Compliance Check", css=css) as demo:
|
| 60 |
gr.Markdown("# Image + Text Compliance Check")
|
| 61 |
|
| 62 |
with gr.Row():
|
|
|
|
| 92 |
with gr.Row():
|
| 93 |
fair_housing_out = gr.Textbox(label="Fair Housing", interactive=False)
|
| 94 |
ptxt_out = gr.Textbox(label="Post Text", interactive=False)
|
| 95 |
+
1 img_out = gr.Textbox(label="Image Text", interactive=False)
|
| 96 |
|
| 97 |
def update_results(results_json):
|
| 98 |
results = json.loads(results_json)
|
|
|
|
| 104 |
return {
|
| 105 |
fair_housing_out: gr.update(
|
| 106 |
value="Compliant" if fh_compliant else "Not Compliant",
|
| 107 |
+
elem_classes="compliant" if fh_compliant else "not-compliant"
|
|
|
|
|
|
|
|
|
|
| 108 |
),
|
| 109 |
ptxt_out: gr.update(
|
| 110 |
value="Compliant" if ptxt_compliant else "Not Compliant",
|
| 111 |
+
elem_classes="compliant" if ptxt_compliant else "not-compliant"
|
|
|
|
|
|
|
|
|
|
| 112 |
),
|
| 113 |
img_out: gr.update(
|
| 114 |
value="Compliant" if img_compliant else "Not Compliant",
|
| 115 |
+
elem_classes="compliant" if img_compliant else "not-compliant"
|
|
|
|
|
|
|
|
|
|
| 116 |
)
|
| 117 |
}
|
| 118 |
|