Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,26 +1,48 @@
|
|
| 1 |
import os
|
| 2 |
import gradio as gr
|
| 3 |
from dotenv import load_dotenv
|
| 4 |
-
from utils import EXAMPLE_ITEMS, analyze
|
| 5 |
|
| 6 |
load_dotenv()
|
| 7 |
TOKEN = os.getenv("HF_TOKEN")
|
| 8 |
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 21 |
|
| 22 |
with gr.Accordion("📄 BibTeX entry for citation", open=False):
|
| 23 |
-
gr.
|
| 24 |
value="""@article{akyon2023nudity,
|
| 25 |
title={State-of-the-art in nudity classification: A comparative analysis},
|
| 26 |
author={Akyon, Fatih Cagatay and Temizel, Alptekin},
|
|
@@ -29,8 +51,9 @@ with gr.Blocks(title="Visual Content Moderation") as demo:
|
|
| 29 |
year={2023},
|
| 30 |
organization={IEEE}
|
| 31 |
}""",
|
| 32 |
-
language="bibtex",
|
| 33 |
show_label=False,
|
|
|
|
|
|
|
| 34 |
)
|
| 35 |
|
| 36 |
with gr.Row():
|
|
@@ -52,12 +75,12 @@ with gr.Blocks(title="Visual Content Moderation") as demo:
|
|
| 52 |
with gr.Column(scale=1):
|
| 53 |
output = gr.Label(label="Classification Scores", num_top_classes=10)
|
| 54 |
|
| 55 |
-
gr.
|
| 56 |
-
|
| 57 |
-
|
| 58 |
-
|
| 59 |
-
|
| 60 |
-
|
| 61 |
)
|
| 62 |
|
| 63 |
analyze_btn.click(
|
|
@@ -66,9 +89,6 @@ with gr.Blocks(title="Visual Content Moderation") as demo:
|
|
| 66 |
outputs=output,
|
| 67 |
)
|
| 68 |
|
| 69 |
-
|
| 70 |
-
fn=lambda evt: run_example(evt, TOKEN),
|
| 71 |
-
outputs=[output, model_choice, url_input],
|
| 72 |
-
)
|
| 73 |
|
| 74 |
demo.launch()
|
|
|
|
| 1 |
import os
|
| 2 |
import gradio as gr
|
| 3 |
from dotenv import load_dotenv
|
| 4 |
+
from utils import EXAMPLE_ITEMS, analyze
|
| 5 |
|
| 6 |
load_dotenv()
|
| 7 |
TOKEN = os.getenv("HF_TOKEN")
|
| 8 |
|
| 9 |
+
CSS = """
|
| 10 |
+
.header {
|
| 11 |
+
text-align: center;
|
| 12 |
+
padding: 2rem 1rem;
|
| 13 |
+
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
|
| 14 |
+
color: white;
|
| 15 |
+
border-radius: 8px;
|
| 16 |
+
margin-bottom: 2rem;
|
| 17 |
+
}
|
| 18 |
+
.header h1 { margin: 0; font-size: 2.5em; }
|
| 19 |
+
.header p { margin: 0.5rem 0; opacity: 0.9; }
|
| 20 |
+
.header a { color: white; text-decoration: underline; }
|
| 21 |
+
.footer {
|
| 22 |
+
text-align: center;
|
| 23 |
+
padding: 1rem;
|
| 24 |
+
color: #888;
|
| 25 |
+
margin-top: 2rem;
|
| 26 |
+
}
|
| 27 |
+
"""
|
| 28 |
+
|
| 29 |
+
with gr.Blocks(title="Visual Content Moderation", css=CSS) as demo:
|
| 30 |
+
gr.HTML("""
|
| 31 |
+
<div class="header">
|
| 32 |
+
<h1>Viddexa - Visual Content Moderation</h1>
|
| 33 |
+
<p>Official demo for <a href="https://github.com/viddexa/moderators" target="_blank">moderators</a> package</p>
|
| 34 |
+
<p>
|
| 35 |
+
<a href="https://huggingface.co/viddexa/nsfw-mini" target="_blank">Model: nsfw-mini</a> |
|
| 36 |
+
<a href="https://huggingface.co/viddexa/nsfw-nano" target="_blank">Model: nsfw-nano</a> |
|
| 37 |
+
<a href="https://arxiv.org/abs/2312.16338" target="_blank">Arxiv</a> |
|
| 38 |
+
<a href="https://github.com/viddexa/moderators" target="_blank">GitHub</a> |
|
| 39 |
+
<a href="https://pypi.org/project/moderators/" target="_blank">PyPI</a>
|
| 40 |
+
</p>
|
| 41 |
+
</div>
|
| 42 |
+
""")
|
| 43 |
|
| 44 |
with gr.Accordion("📄 BibTeX entry for citation", open=False):
|
| 45 |
+
gr.Textbox(
|
| 46 |
value="""@article{akyon2023nudity,
|
| 47 |
title={State-of-the-art in nudity classification: A comparative analysis},
|
| 48 |
author={Akyon, Fatih Cagatay and Temizel, Alptekin},
|
|
|
|
| 51 |
year={2023},
|
| 52 |
organization={IEEE}
|
| 53 |
}""",
|
|
|
|
| 54 |
show_label=False,
|
| 55 |
+
lines=8,
|
| 56 |
+
max_lines=8,
|
| 57 |
)
|
| 58 |
|
| 59 |
with gr.Row():
|
|
|
|
| 75 |
with gr.Column(scale=1):
|
| 76 |
output = gr.Label(label="Classification Scores", num_top_classes=10)
|
| 77 |
|
| 78 |
+
gr.Examples(
|
| 79 |
+
examples=[[None, url, model] for url, model in EXAMPLE_ITEMS],
|
| 80 |
+
inputs=[image_input, url_input, model_choice],
|
| 81 |
+
outputs=output,
|
| 82 |
+
fn=lambda img, url, model: analyze(img, url, model, TOKEN),
|
| 83 |
+
cache_examples=False,
|
| 84 |
)
|
| 85 |
|
| 86 |
analyze_btn.click(
|
|
|
|
| 89 |
outputs=output,
|
| 90 |
)
|
| 91 |
|
| 92 |
+
gr.HTML('<div class="footer">Developed by Viddexa</div>')
|
|
|
|
|
|
|
|
|
|
| 93 |
|
| 94 |
demo.launch()
|