Update app.py
Browse files
app.py
CHANGED
|
@@ -1708,6 +1708,7 @@ def process_text(input_text):
|
|
| 1708 |
|
| 1709 |
# Main processing function (encapsulates the pipeline)
|
| 1710 |
|
|
|
|
| 1711 |
# ================== NEW SAFE GRADIO BLOCK (2026 version) ===================
|
| 1712 |
print(" All three models loaded successfully!")
|
| 1713 |
print("Creating Gradio interface...")
|
|
@@ -1739,10 +1740,95 @@ if __name__ == "__main__":
|
|
| 1739 |
ssr_mode=False,
|
| 1740 |
)
|
| 1741 |
|
|
|
|
|
|
|
| 1742 |
'''
|
| 1743 |
test = (
|
| 1744 |
"Joshua told me that John, who lives in London, is going to Wolverhampton, Jack loves Norwich, and Mary, who is a bit nervous, adores Birmingham, just as Fred predicted."
|
| 1745 |
)
|
| 1746 |
print(process_text(test))
|
| 1747 |
'''
|
|
|
|
| 1748 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1708 |
|
| 1709 |
# Main processing function (encapsulates the pipeline)
|
| 1710 |
|
| 1711 |
+
'''
|
| 1712 |
# ================== NEW SAFE GRADIO BLOCK (2026 version) ===================
|
| 1713 |
print(" All three models loaded successfully!")
|
| 1714 |
print("Creating Gradio interface...")
|
|
|
|
| 1740 |
ssr_mode=False,
|
| 1741 |
)
|
| 1742 |
|
| 1743 |
+
'''
|
| 1744 |
+
|
| 1745 |
'''
|
| 1746 |
test = (
|
| 1747 |
"Joshua told me that John, who lives in London, is going to Wolverhampton, Jack loves Norwich, and Mary, who is a bit nervous, adores Birmingham, just as Fred predicted."
|
| 1748 |
)
|
| 1749 |
print(process_text(test))
|
| 1750 |
'''
|
| 1751 |
+
'''
|
| 1752 |
|
| 1753 |
+
'''
|
| 1754 |
+
# ================== GRADIO INTERFACE ===================
|
| 1755 |
+
print(" All three models loaded successfully!")
|
| 1756 |
+
print("Creating Gradio interface...")
|
| 1757 |
+
|
| 1758 |
+
custom_css = """
|
| 1759 |
+
/* Slightly larger base font */
|
| 1760 |
+
.gradio-container, .gradio-container * {
|
| 1761 |
+
font-size: 16px !important;
|
| 1762 |
+
}
|
| 1763 |
+
|
| 1764 |
+
/* Input = original text → bright pink */
|
| 1765 |
+
.input-text textarea {
|
| 1766 |
+
font-size: 17px !important;
|
| 1767 |
+
color: #ffd0d0 !important; /* DeepPink */
|
| 1768 |
+
font-weight: 500 !important;
|
| 1769 |
+
line-height: 1.45 !important;
|
| 1770 |
+
}
|
| 1771 |
+
|
| 1772 |
+
/* Output = simplified text → bright green */
|
| 1773 |
+
.output-text textarea {
|
| 1774 |
+
font-size: 17px !important;
|
| 1775 |
+
color: #d0ffd0 !important; /* bright green */
|
| 1776 |
+
font-weight: 500 !important;
|
| 1777 |
+
line-height: 1.45 !important;
|
| 1778 |
+
}
|
| 1779 |
+
|
| 1780 |
+
/* Labels under the boxes */
|
| 1781 |
+
.input-text label,
|
| 1782 |
+
.output-text label {
|
| 1783 |
+
font-size: 15px !important;
|
| 1784 |
+
font-weight: 600 !important;
|
| 1785 |
+
}
|
| 1786 |
+
|
| 1787 |
+
.input-text label {
|
| 1788 |
+
color: #ffd0d0 !important;
|
| 1789 |
+
}
|
| 1790 |
+
|
| 1791 |
+
.output-text label {
|
| 1792 |
+
color: #d0ffd0 !important;
|
| 1793 |
+
}
|
| 1794 |
+
"""
|
| 1795 |
+
|
| 1796 |
+
with gr.Blocks(
|
| 1797 |
+
title="Syntactic Sentence Simplifier",
|
| 1798 |
+
css=custom_css,
|
| 1799 |
+
) as demo:
|
| 1800 |
+
gr.Markdown("# Syntactic Sentence Simplifier")
|
| 1801 |
+
gr.Markdown(
|
| 1802 |
+
"Paste or type your text below. Uses Hugging Face models + simplification logic."
|
| 1803 |
+
)
|
| 1804 |
+
|
| 1805 |
+
input_text = gr.Textbox(
|
| 1806 |
+
lines=10,
|
| 1807 |
+
label="Original text",
|
| 1808 |
+
placeholder="Paste your text here...",
|
| 1809 |
+
elem_classes=["input-text"],
|
| 1810 |
+
)
|
| 1811 |
+
|
| 1812 |
+
output_text = gr.Textbox(
|
| 1813 |
+
lines=10,
|
| 1814 |
+
label="Simplified text",
|
| 1815 |
+
elem_classes=["output-text"],
|
| 1816 |
+
)
|
| 1817 |
+
|
| 1818 |
+
btn = gr.Button("Process & Simplify", variant="primary")
|
| 1819 |
+
|
| 1820 |
+
btn.click(
|
| 1821 |
+
fn=process_text,
|
| 1822 |
+
inputs=input_text,
|
| 1823 |
+
outputs=output_text,
|
| 1824 |
+
)
|
| 1825 |
+
|
| 1826 |
+
print(" Gradio interface ready. Starting web server...")
|
| 1827 |
+
|
| 1828 |
+
if __name__ == "__main__":
|
| 1829 |
+
demo.launch(
|
| 1830 |
+
server_name="0.0.0.0",
|
| 1831 |
+
server_port=7860,
|
| 1832 |
+
debug=True,
|
| 1833 |
+
share=False,
|
| 1834 |
+
)
|