Spaces:
Paused
Paused
style: create layout
Browse files
app.py
CHANGED
|
@@ -1,60 +1,201 @@
|
|
| 1 |
import gradio as gr
|
| 2 |
import os
|
|
|
|
| 3 |
|
| 4 |
# Organization details
|
| 5 |
-
ORG_NAME = "
|
| 6 |
DESCRIPTION = """
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 12 |
"""
|
| 13 |
-
LOGO_PATH = "path_to_your_logo.png" # Add your logo file to the repository
|
| 14 |
-
THEME_COLOR = "#ff7f50" # Customize the theme color
|
| 15 |
|
| 16 |
-
#
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 17 |
custom_css = """
|
| 18 |
-
.
|
| 19 |
-
|
|
|
|
|
|
|
|
|
|
| 20 |
padding: 20px;
|
| 21 |
background: white;
|
| 22 |
box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
|
|
|
|
|
|
|
|
|
|
|
|
|
| 23 |
}
|
| 24 |
-
.
|
| 25 |
-
font-size:
|
| 26 |
font-weight: bold;
|
| 27 |
-
margin-bottom:
|
| 28 |
-
color:
|
| 29 |
}
|
| 30 |
-
.
|
| 31 |
font-size: 16px;
|
| 32 |
-
|
| 33 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 34 |
}
|
| 35 |
"""
|
| 36 |
|
| 37 |
-
def
|
| 38 |
-
""
|
| 39 |
-
|
| 40 |
-
|
|
|
|
|
|
|
| 41 |
with gr.Blocks(css=custom_css) as interface:
|
| 42 |
-
with gr.
|
| 43 |
-
|
| 44 |
-
|
| 45 |
-
|
| 46 |
-
|
| 47 |
-
|
| 48 |
-
|
| 49 |
-
|
| 50 |
-
|
| 51 |
-
|
| 52 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 53 |
|
| 54 |
return interface
|
| 55 |
|
| 56 |
# Create and launch the interface
|
| 57 |
-
demo =
|
| 58 |
|
| 59 |
# Launch the app
|
| 60 |
if __name__ == "__main__":
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
import os
|
| 3 |
+
from datetime import datetime
|
| 4 |
|
| 5 |
# Organization details
|
| 6 |
+
ORG_NAME = "Narrative I/O"
|
| 7 |
DESCRIPTION = """
|
| 8 |
+
Narrative I/O is at the forefront of data transformation and enrichment. We specialize in:
|
| 9 |
+
|
| 10 |
+
• Building scalable data enrichment pipelines
|
| 11 |
+
• Developing cutting-edge machine learning models
|
| 12 |
+
• Creating efficient data processing solutions
|
| 13 |
+
• Enabling businesses to leverage their data assets effectively
|
| 14 |
+
|
| 15 |
+
Our platform combines advanced ML capabilities with robust data processing to deliver
|
| 16 |
+
actionable insights and enhanced data quality for our clients.
|
| 17 |
"""
|
|
|
|
|
|
|
| 18 |
|
| 19 |
+
# News/Announcements
|
| 20 |
+
ANNOUNCEMENTS = [
|
| 21 |
+
{
|
| 22 |
+
"date": "2024-03-15",
|
| 23 |
+
"title": "New Model Release",
|
| 24 |
+
"content": "Introducing our latest data enrichment model for enhanced entity resolution."
|
| 25 |
+
},
|
| 26 |
+
{
|
| 27 |
+
"date": "2024-02-28",
|
| 28 |
+
"title": "Dataset Publication",
|
| 29 |
+
"content": "Released a new benchmark dataset for entity matching evaluation."
|
| 30 |
+
}
|
| 31 |
+
]
|
| 32 |
+
|
| 33 |
+
# Public Models
|
| 34 |
+
PUBLIC_MODELS = [
|
| 35 |
+
{
|
| 36 |
+
"name": "entity-matcher-v1",
|
| 37 |
+
"description": "High-performance entity matching model",
|
| 38 |
+
"link": "https://huggingface.co/Narrative-IO/entity-matcher-v1"
|
| 39 |
+
},
|
| 40 |
+
{
|
| 41 |
+
"name": "data-enrichment-v2",
|
| 42 |
+
"description": "Advanced data enrichment pipeline",
|
| 43 |
+
"link": "https://huggingface.co/Narrative-IO/data-enrichment-v2"
|
| 44 |
+
}
|
| 45 |
+
]
|
| 46 |
+
|
| 47 |
+
# Public Datasets
|
| 48 |
+
PUBLIC_DATASETS = [
|
| 49 |
+
{
|
| 50 |
+
"name": "entity-matching-benchmark",
|
| 51 |
+
"description": "Large-scale entity matching benchmark dataset",
|
| 52 |
+
"link": "https://huggingface.co/datasets/Narrative-IO/entity-matching-benchmark"
|
| 53 |
+
},
|
| 54 |
+
{
|
| 55 |
+
"name": "data-quality-samples",
|
| 56 |
+
"description": "Sample datasets for data quality assessment",
|
| 57 |
+
"link": "https://huggingface.co/datasets/Narrative-IO/data-quality-samples"
|
| 58 |
+
}
|
| 59 |
+
]
|
| 60 |
+
|
| 61 |
+
# Demo configurations
|
| 62 |
+
DEMOS = [
|
| 63 |
+
{
|
| 64 |
+
"title": "Entity Matching Demo",
|
| 65 |
+
"description": "Try our entity matching model with your own data",
|
| 66 |
+
"function": lambda x, y: f"Similarity score: {0.85}" # Placeholder function
|
| 67 |
+
},
|
| 68 |
+
{
|
| 69 |
+
"title": "Data Quality Assessment",
|
| 70 |
+
"description": "Check your data quality metrics",
|
| 71 |
+
"function": lambda x: {"completeness": 0.95, "accuracy": 0.92} # Placeholder function
|
| 72 |
+
}
|
| 73 |
+
]
|
| 74 |
+
|
| 75 |
+
# Custom CSS for styling
|
| 76 |
custom_css = """
|
| 77 |
+
.container {
|
| 78 |
+
gap: 1rem;
|
| 79 |
+
}
|
| 80 |
+
.card {
|
| 81 |
+
border-radius: 10px;
|
| 82 |
padding: 20px;
|
| 83 |
background: white;
|
| 84 |
box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
|
| 85 |
+
margin-bottom: 1rem;
|
| 86 |
+
}
|
| 87 |
+
.main-card {
|
| 88 |
+
background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
|
| 89 |
}
|
| 90 |
+
.title {
|
| 91 |
+
font-size: 20px;
|
| 92 |
font-weight: bold;
|
| 93 |
+
margin-bottom: 10px;
|
| 94 |
+
color: #2d3748;
|
| 95 |
}
|
| 96 |
+
.subtitle {
|
| 97 |
font-size: 16px;
|
| 98 |
+
color: #4a5568;
|
| 99 |
+
margin-bottom: 15px;
|
| 100 |
+
}
|
| 101 |
+
.news-item {
|
| 102 |
+
padding: 10px 0;
|
| 103 |
+
border-bottom: 1px solid #e2e8f0;
|
| 104 |
+
}
|
| 105 |
+
.news-date {
|
| 106 |
+
font-size: 14px;
|
| 107 |
+
color: #718096;
|
| 108 |
+
}
|
| 109 |
+
.model-item, .dataset-item {
|
| 110 |
+
padding: 10px;
|
| 111 |
+
margin: 5px 0;
|
| 112 |
+
background: #f7fafc;
|
| 113 |
+
border-radius: 5px;
|
| 114 |
}
|
| 115 |
"""
|
| 116 |
|
| 117 |
+
def format_date(date_str):
|
| 118 |
+
date = datetime.strptime(date_str, "%Y-%m-%d")
|
| 119 |
+
return date.strftime("%B %d, %Y")
|
| 120 |
+
|
| 121 |
+
def create_organization_page():
|
| 122 |
+
"""Creates the organization page with multiple cards and demos"""
|
| 123 |
with gr.Blocks(css=custom_css) as interface:
|
| 124 |
+
with gr.Row(elem_classes="container"):
|
| 125 |
+
# Left section (2/3 width)
|
| 126 |
+
with gr.Column(scale=2):
|
| 127 |
+
# Main organization card
|
| 128 |
+
with gr.Column(elem_classes="card main-card"):
|
| 129 |
+
gr.Markdown(f"# {ORG_NAME}")
|
| 130 |
+
gr.Markdown(DESCRIPTION)
|
| 131 |
+
with gr.Row():
|
| 132 |
+
gr.Button("Website", link="https://narrative.io")
|
| 133 |
+
gr.Button("GitHub", link="https://github.com/narrative-io")
|
| 134 |
+
gr.Button("Twitter", link="https://twitter.com/narrative_io")
|
| 135 |
+
|
| 136 |
+
# News and Announcements
|
| 137 |
+
with gr.Column(elem_classes="card"):
|
| 138 |
+
gr.Markdown("## Latest News & Announcements")
|
| 139 |
+
for announcement in ANNOUNCEMENTS:
|
| 140 |
+
with gr.Row(elem_classes="news-item"):
|
| 141 |
+
gr.Markdown(f"""
|
| 142 |
+
**{announcement['title']}**
|
| 143 |
+
<span class="news-date">{format_date(announcement['date'])}</span>
|
| 144 |
+
{announcement['content']}
|
| 145 |
+
""")
|
| 146 |
+
|
| 147 |
+
# Interactive Demos
|
| 148 |
+
with gr.Column(elem_classes="card"):
|
| 149 |
+
gr.Markdown("## Interactive Demos")
|
| 150 |
+
for demo in DEMOS:
|
| 151 |
+
with gr.Column(elem_classes="demo-item"):
|
| 152 |
+
gr.Markdown(f"### {demo['title']}")
|
| 153 |
+
gr.Markdown(demo['description'])
|
| 154 |
+
if demo['title'] == "Entity Matching Demo":
|
| 155 |
+
with gr.Row():
|
| 156 |
+
text1 = gr.Textbox(label="Entity 1")
|
| 157 |
+
text2 = gr.Textbox(label="Entity 2")
|
| 158 |
+
gr.Button("Compare").click(
|
| 159 |
+
demo['function'],
|
| 160 |
+
inputs=[text1, text2],
|
| 161 |
+
outputs=gr.Textbox(label="Result")
|
| 162 |
+
)
|
| 163 |
+
elif demo['title'] == "Data Quality Assessment":
|
| 164 |
+
file_input = gr.File(label="Upload your data")
|
| 165 |
+
gr.Button("Analyze").click(
|
| 166 |
+
demo['function'],
|
| 167 |
+
inputs=[file_input],
|
| 168 |
+
outputs=gr.JSON(label="Quality Metrics")
|
| 169 |
+
)
|
| 170 |
+
|
| 171 |
+
# Right section (1/3 width)
|
| 172 |
+
with gr.Column(scale=1):
|
| 173 |
+
# Public Models card
|
| 174 |
+
with gr.Column(elem_classes="card"):
|
| 175 |
+
gr.Markdown("## Public Models")
|
| 176 |
+
for model in PUBLIC_MODELS:
|
| 177 |
+
with gr.Row(elem_classes="model-item"):
|
| 178 |
+
gr.Markdown(f"""
|
| 179 |
+
**{model['name']}**
|
| 180 |
+
{model['description']}
|
| 181 |
+
[View Model]({model['link']})
|
| 182 |
+
""")
|
| 183 |
+
|
| 184 |
+
# Public Datasets card
|
| 185 |
+
with gr.Column(elem_classes="card"):
|
| 186 |
+
gr.Markdown("## Public Datasets")
|
| 187 |
+
for dataset in PUBLIC_DATASETS:
|
| 188 |
+
with gr.Row(elem_classes="dataset-item"):
|
| 189 |
+
gr.Markdown(f"""
|
| 190 |
+
**{dataset['name']}**
|
| 191 |
+
{dataset['description']}
|
| 192 |
+
[View Dataset]({dataset['link']})
|
| 193 |
+
""")
|
| 194 |
|
| 195 |
return interface
|
| 196 |
|
| 197 |
# Create and launch the interface
|
| 198 |
+
demo = create_organization_page()
|
| 199 |
|
| 200 |
# Launch the app
|
| 201 |
if __name__ == "__main__":
|