Spaces:
Runtime error
Runtime error
File size: 2,636 Bytes
8ac6752 d2b2682 c292beb 1b4e7f4 d2b2682 1b4e7f4 d2b2682 c292beb 1b4e7f4 c292beb d2b2682 1b4e7f4 c292beb 1b4e7f4 c292beb 1b4e7f4 c292beb d2b2682 1b4e7f4 c292beb 1b4e7f4 c292beb d2b2682 1b4e7f4 c292beb d2b2682 1b4e7f4 c292beb 1b4e7f4 c292beb 1b4e7f4 c292beb d2b2682 c292beb 1b4e7f4 c292beb 1b4e7f4 c292beb 1b4e7f4 c292beb 1b4e7f4 c292beb 1b4e7f4 c292beb 1b4e7f4 c292beb d2b2682 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 |
import gradio as gr
from inference import predict
def predict_ui(sequence):
result = predict(sequence)
if isinstance(result, float):
prob = result
else:
prob = result["probability"]
percent = prob * 100
is_positive = prob > 0.5
label = "🧬 Cleavage Site Likely" if is_positive else "❌ No Cleavage Site"
color = "#22c55e" if is_positive else "#ef4444"
return (
f"{prob:.5f}",
f"{percent:.3f}%",
f"<span style='color:{color}; font-weight:bold; font-size:18px'>{label}</span>",
percent
)
# -----------------------------
# 🎨 Compact + Visible UI
# -----------------------------
css = """
body {
background: linear-gradient(135deg, #0f172a, #020617);
font-family: 'Segoe UI', sans-serif;
}
/* Center container */
.container {
max-width: 650px;
margin: auto;
padding-top: 30px;
}
/* Card */
.card {
background: rgba(255,255,255,0.05);
backdrop-filter: blur(10px);
border-radius: 16px;
padding: 18px;
box-shadow: 0 6px 20px rgba(0,0,0,0.25);
}
/* Title fix */
h1 {
color: #ffffff !important;
text-align: center;
margin-bottom: 5px;
}
h3 {
color: #cbd5f5;
text-align: center;
margin-top: 0;
}
/* Reduce input height */
textarea {
min-height: 70px !important;
border-radius: 10px !important;
}
/* Buttons */
button {
border-radius: 10px !important;
padding: 8px 12px !important;
font-weight: bold;
}
/* Reduce spacing */
.gr-box {
padding: 5px !important;
}
"""
with gr.Blocks(css=css) as demo:
with gr.Column(elem_classes="container"):
with gr.Column(elem_classes="card"):
gr.Markdown(
"# 🧬 BiTransformer Cleavage Site Predictor\n"
)
seq_input = gr.Textbox(
label="Protein Sequence",
placeholder="Paste sequence...",
lines=2
)
predict_btn = gr.Button("🔍 Predict")
with gr.Row():
prob_output = gr.Textbox(label="Probability")
percent_output = gr.Textbox(label="Percentage")
label_output = gr.HTML(label="Result")
confidence_bar = gr.Slider(
minimum=0,
maximum=100,
step=0.1,
label="Confidence",
interactive=False
)
predict_btn.click(
fn=predict_ui,
inputs=seq_input,
outputs=[prob_output, percent_output, label_output, confidence_bar]
)
demo.launch()
|