Lebuga commited on
Commit
1b4e7f4
Β·
verified Β·
1 Parent(s): c292beb

Upload app.py with huggingface_hub

Browse files
Files changed (1) hide show
  1. app.py +46 -22
app.py CHANGED
@@ -14,17 +14,17 @@ def predict_ui(sequence):
14
  is_positive = prob > 0.5
15
 
16
  label = "🧬 Cleavage Site Likely" if is_positive else "❌ No Cleavage Site"
17
- color = "#22c55e" if is_positive else "#ef4444" # green / red
18
 
19
  return (
20
  f"{prob:.5f}",
21
  f"{percent:.3f}%",
22
- f"<span style='color:{color}; font-weight:bold'>{label}</span>",
23
  percent
24
  )
25
 
26
  # -----------------------------
27
- # πŸ”₯ Modern CSS (Glass UI)
28
  # -----------------------------
29
  css = """
30
  body {
@@ -32,28 +32,52 @@ body {
32
  font-family: 'Segoe UI', sans-serif;
33
  }
34
 
 
35
  .container {
36
- max-width: 720px;
37
  margin: auto;
38
- padding: 20px;
39
  }
40
 
 
41
  .card {
42
- background: rgba(255, 255, 255, 0.05);
43
- backdrop-filter: blur(12px);
44
- border-radius: 20px;
45
- padding: 25px;
46
- box-shadow: 0 8px 30px rgba(0,0,0,0.3);
47
  }
48
 
49
- textarea, input {
50
- border-radius: 12px !important;
 
 
 
51
  }
52
 
 
 
 
 
 
 
 
 
 
 
 
 
 
53
  button {
54
- border-radius: 12px !important;
 
55
  font-weight: bold;
56
  }
 
 
 
 
 
57
  """
58
 
59
  with gr.Blocks(css=css) as demo:
@@ -62,29 +86,29 @@ with gr.Blocks(css=css) as demo:
62
  with gr.Column(elem_classes="card"):
63
 
64
  gr.Markdown(
65
- "# 🧬 BiTransformer Predictor\n"
66
- "### AI-powered protein cleavage site detection"
67
  )
68
 
69
  seq_input = gr.Textbox(
70
  label="Protein Sequence",
71
- placeholder="Paste protein sequence here...",
72
- lines=3
73
  )
74
 
75
- predict_btn = gr.Button("πŸ” Run Prediction")
76
 
77
  with gr.Row():
78
- prob_output = gr.Textbox(label="πŸ”’ Probability")
79
- percent_output = gr.Textbox(label="πŸ“Š Percentage")
80
 
81
- label_output = gr.HTML(label="🧾 Result")
82
 
83
  confidence_bar = gr.Slider(
84
  minimum=0,
85
  maximum=100,
86
  step=0.1,
87
- label="πŸ“ˆ Confidence Level",
88
  interactive=False
89
  )
90
 
 
14
  is_positive = prob > 0.5
15
 
16
  label = "🧬 Cleavage Site Likely" if is_positive else "❌ No Cleavage Site"
17
+ color = "#22c55e" if is_positive else "#ef4444"
18
 
19
  return (
20
  f"{prob:.5f}",
21
  f"{percent:.3f}%",
22
+ f"<span style='color:{color}; font-weight:bold; font-size:18px'>{label}</span>",
23
  percent
24
  )
25
 
26
  # -----------------------------
27
+ # 🎨 Compact + Visible UI
28
  # -----------------------------
29
  css = """
30
  body {
 
32
  font-family: 'Segoe UI', sans-serif;
33
  }
34
 
35
+ /* Center container */
36
  .container {
37
+ max-width: 650px;
38
  margin: auto;
39
+ padding-top: 30px;
40
  }
41
 
42
+ /* Card */
43
  .card {
44
+ background: rgba(255,255,255,0.05);
45
+ backdrop-filter: blur(10px);
46
+ border-radius: 16px;
47
+ padding: 18px;
48
+ box-shadow: 0 6px 20px rgba(0,0,0,0.25);
49
  }
50
 
51
+ /* Title fix */
52
+ h1 {
53
+ color: #ffffff !important;
54
+ text-align: center;
55
+ margin-bottom: 5px;
56
  }
57
 
58
+ h3 {
59
+ color: #cbd5f5;
60
+ text-align: center;
61
+ margin-top: 0;
62
+ }
63
+
64
+ /* Reduce input height */
65
+ textarea {
66
+ min-height: 70px !important;
67
+ border-radius: 10px !important;
68
+ }
69
+
70
+ /* Buttons */
71
  button {
72
+ border-radius: 10px !important;
73
+ padding: 8px 12px !important;
74
  font-weight: bold;
75
  }
76
+
77
+ /* Reduce spacing */
78
+ .gr-box {
79
+ padding: 5px !important;
80
+ }
81
  """
82
 
83
  with gr.Blocks(css=css) as demo:
 
86
  with gr.Column(elem_classes="card"):
87
 
88
  gr.Markdown(
89
+ "# 🧬 BiTransformer Cleavage Site Predictor\n"
90
+
91
  )
92
 
93
  seq_input = gr.Textbox(
94
  label="Protein Sequence",
95
+ placeholder="Paste sequence...",
96
+ lines=2
97
  )
98
 
99
+ predict_btn = gr.Button("πŸ” Predict")
100
 
101
  with gr.Row():
102
+ prob_output = gr.Textbox(label="Probability")
103
+ percent_output = gr.Textbox(label="Percentage")
104
 
105
+ label_output = gr.HTML(label="Result")
106
 
107
  confidence_bar = gr.Slider(
108
  minimum=0,
109
  maximum=100,
110
  step=0.1,
111
+ label="Confidence",
112
  interactive=False
113
  )
114