alrichardbollans commited on
Commit
4527a8b
·
1 Parent(s): 5001cc3

Add example logo and make fixes for tabbing accesibility

Browse files
Files changed (2) hide show
  1. app.py +62 -23
  2. styles.css +55 -2
app.py CHANGED
@@ -29,27 +29,11 @@ from python_utils import load_model, apply_nms
29
  app_dir = Path(__file__).parent
30
 
31
  protocol_url = 'https://pgomba.github.io/orchid_protocol/'
 
32
 
33
  # Load the prediction model
34
  predictor = load_model()
35
  main_app = ui.page_fluid(
36
- ui.div(
37
- ui.row(
38
- ui.column(6,
39
- ui.panel_title(ui.div("Orchid TZ Viability Analyzer", class_="navbar-title"))
40
- ),
41
- ),
42
- class_="nav-bar"
43
- ),
44
-
45
- ui.div(
46
- ui.p(
47
- "The protocol is here:", ui.a("Image Taking Protocol", href=protocol_url, target="_blank"), " "
48
- "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed euismod, nunc ut laoreet placerat, urna purus rhoncus nisi, "
49
- "vel facilisis magna sem sed tellus."
50
- ),
51
- class_="body-bar"
52
- ),
53
 
54
  ui.div(
55
  ui.layout_sidebar(
@@ -57,9 +41,12 @@ main_app = ui.page_fluid(
57
  ui.input_file("upload", "Upload Images",
58
  multiple=True,
59
  accept=[".png", ".jpg", ".jpeg"]),
 
60
  ui.input_slider("threshold", "Threshold for Discarding Overlapping Segmentations"
61
  " (ADD a more descriptive label, and explain in text above).", 0, 1.0, 0.8),
62
- ui.tags.style("""
 
 
63
  .irs.irs--shiny .irs-single { /* square with number */
64
  background-color: #357abd;
65
  font-size: 1rem;
@@ -77,10 +64,37 @@ main_app = ui.page_fluid(
77
  .irs-handle.single { /* circle */
78
  background-color: #357abd;
79
  }
80
-
81
- """
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
82
  ),
83
- ui.input_action_button("analyze", "Analyze", class_="btn-success"),
84
  # ui.input_switch("mask", "Mask", False),
85
  ui.column(4, ui.download_button("download", "Download Results", class_="btn-success")),
86
  width=300
@@ -95,6 +109,26 @@ main_app = ui.page_fluid(
95
 
96
  app_ui = ui.page_fluid(
97
  ui.include_css("styles.css"),
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
98
  main_app,
99
  # ui.page_navbar(
100
  # ui.nav_panel("A", main_app),
@@ -176,10 +210,15 @@ def server(input, output, session: Session):
176
  img = {"src": "assets/abg.png"}
177
  return img
178
 
 
 
 
 
 
179
  analysis_results = reactive.Value([])
180
 
181
  @reactive.Effect
182
- @reactive.event(input.analyze)
183
  async def process_images():
184
  files = input.upload()
185
  if not files:
@@ -226,7 +265,7 @@ def server(input, output, session: Session):
226
  def results_container():
227
  results = analysis_results.get()
228
  if not results:
229
- return ui.div("No results yet. Upload images and click 'Analyze'.",
230
  class_="text-muted")
231
 
232
  ui_output = []
 
29
  app_dir = Path(__file__).parent
30
 
31
  protocol_url = 'https://pgomba.github.io/orchid_protocol/'
32
+ discussion_url = 'https://huggingface.co/spaces/TZProject/TZSeedApp/discussions'
33
 
34
  # Load the prediction model
35
  predictor = load_model()
36
  main_app = ui.page_fluid(
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
37
 
38
  ui.div(
39
  ui.layout_sidebar(
 
41
  ui.input_file("upload", "Upload Images",
42
  multiple=True,
43
  accept=[".png", ".jpg", ".jpeg"]),
44
+
45
  ui.input_slider("threshold", "Threshold for Discarding Overlapping Segmentations"
46
  " (ADD a more descriptive label, and explain in text above).", 0, 1.0, 0.8),
47
+
48
+
49
+ ui.tags.style("""
50
  .irs.irs--shiny .irs-single { /* square with number */
51
  background-color: #357abd;
52
  font-size: 1rem;
 
64
  .irs-handle.single { /* circle */
65
  background-color: #357abd;
66
  }
67
+ .irs-handle.single:hover { /* circle */
68
+ background-color: #2c3e50;
69
+ }
70
+
71
+ # .irs-handle.single:focus { /* circle */
72
+ # outline: 5px solid #ffab00 !important; /* Highly visible gold/orange outline */
73
+ # outline-offset: 0px;
74
+ # box-shadow: 0 0 0 6px rgba(255, 171, 0, 0.25); /* Soft glow for extra contrast */
75
+ # z-index: 2;
76
+ # transition: outline-color 0.2s, box-shadow 0.2s;
77
+ # }
78
+ #
79
+ # .irs-handle.single:focus-visible { /* circle */
80
+ # outline: 5px solid #ffab00 !important; /* Highly visible gold/orange outline */
81
+ # outline-offset: 0px;
82
+ # box-shadow: 0 0 0 6px rgba(255, 171, 0, 0.25); /* Soft glow for extra contrast */
83
+ # z-index: 2;
84
+ # transition: outline-color 0.2s, box-shadow 0.2s;
85
+ # }
86
+ #
87
+ # .irs-handle.single:focus-within { /* circle */
88
+ # outline: 5px solid #ffab00 !important; /* Highly visible gold/orange outline */
89
+ # outline-offset: 0px;
90
+ # box-shadow: 0 0 0 6px rgba(255, 171, 0, 0.25); /* Soft glow for extra contrast */
91
+ # z-index: 2;
92
+ # transition: outline-color 0.2s, box-shadow 0.2s;
93
+ # }
94
+
95
+ """ # Style need adding here for slider for some reason
96
  ),
97
+ ui.input_action_button("analyse", "Analyse", class_="btn-success"),
98
  # ui.input_switch("mask", "Mask", False),
99
  ui.column(4, ui.download_button("download", "Download Results", class_="btn-success")),
100
  width=300
 
109
 
110
  app_ui = ui.page_fluid(
111
  ui.include_css("styles.css"),
112
+ ui.div(
113
+ ui.row(
114
+ ui.column(5,
115
+ ui.panel_title(ui.div("OrchAid", ui.output_image("logo_image", inline=True, width='100px'), class_="navbar-title"))
116
+ )
117
+ ),
118
+ class_="nav-bar"
119
+ ),
120
+
121
+ ui.div(
122
+ ui.p(
123
+ "The protocol for taking images compatible with this model is available on ",
124
+ ui.a("GitHub", href=protocol_url, target="_blank"),
125
+ ". The protocol is available in English, Indonesian, Thai, French, Spanish, Portuguese, Arabic, Mandarin, Malagasy and Japanese.",
126
+ " If you have any feedback on the app, please start a discussion on ", ui.a("the HuggingFace space", href=protocol_url, target="_blank"),
127
+ ". Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed euismod, nunc ut laoreet placerat, urna purus rhoncus nisi, "
128
+ "vel facilisis magna sem sed tellus."
129
+ ),
130
+ class_="body-bar"
131
+ ),
132
  main_app,
133
  # ui.page_navbar(
134
  # ui.nav_panel("A", main_app),
 
210
  img = {"src": "assets/abg.png"}
211
  return img
212
 
213
+ @render.image
214
+ def logo_image():
215
+ img = {"src": "assets/example_logo.png", "height": "100px", "width": "100px"}
216
+ return img
217
+
218
  analysis_results = reactive.Value([])
219
 
220
  @reactive.Effect
221
+ @reactive.event(input.analyse)
222
  async def process_images():
223
  files = input.upload()
224
  if not files:
 
265
  def results_container():
266
  results = analysis_results.get()
267
  if not results:
268
+ return ui.div("No results yet. Upload images and click 'Analyse'.",
269
  class_="text-muted")
270
 
271
  ui_output = []
styles.css CHANGED
@@ -5,8 +5,8 @@ body {
5
  background-color: white;
6
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
7
  }
8
- /* Image display styling */
9
- img {
10
  border-radius: 10px;
11
  object-fit: cover;
12
  max-height: 300px;
@@ -98,6 +98,9 @@ position: sticky;
98
  background-color: #2c3e50 !important;
99
  }
100
 
 
 
 
101
  /* Image cards styling */
102
  .card {
103
  background: white;
@@ -123,6 +126,56 @@ position: sticky;
123
  border-left: 4px solid #4a90e2;
124
  }
125
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
126
  /* Responsive design */
127
  @media (max-width: 768px) {
128
  .col-md-4 {
 
5
  background-color: white;
6
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
7
  }
8
+ /* Image display styling for footer images */
9
+ .footer img {
10
  border-radius: 10px;
11
  object-fit: cover;
12
  max-height: 300px;
 
98
  background-color: #2c3e50 !important;
99
  }
100
 
101
+
102
+
103
+
104
  /* Image cards styling */
105
  .card {
106
  background: white;
 
126
  border-left: 4px solid #4a90e2;
127
  }
128
 
129
+ /* Focus styling */
130
+ /* High contrast focus ring for buttons */
131
+ button:focus,
132
+ .btn:focus,
133
+ .btn-default:focus,
134
+ .btn-file:focus,
135
+ .form-control:focus,
136
+ .irs-line:focus,
137
+ .btn-success:focus,
138
+ input[type="button"]:focus,
139
+ input[type="submit"]:focus {
140
+ outline: 5px solid #ffab00 !important; /* Highly visible gold/orange outline */
141
+ outline-offset: 1px;
142
+ box-shadow: 0 0 0 6px rgba(255, 171, 0, 0.25); /* Soft glow for extra contrast */
143
+ z-index: 2;
144
+ transition: outline-color 0.2s, box-shadow 0.2s;
145
+ }
146
+
147
+ /* Optionally, use :focus-visible for modern browsers only */
148
+ button:focus-visible,
149
+ .btn:focus-visible,
150
+ .btn-default:focus-visible,
151
+ .btn-file:focus-visible,
152
+ .btn-success:focus-visible,
153
+ .form-control:focus-visible,
154
+ .irs-line:focus-visible,
155
+ input[type="button"]:focus-visible,
156
+ input[type="submit"]:focus-visible {
157
+ outline: 5px solid #ffab00 !important;
158
+ outline-offset: 1px;
159
+ box-shadow: 0 0 0 6px rgba(255, 171, 0, 0.25);
160
+ z-index: 2;
161
+ }
162
+
163
+ button:focus-within,
164
+ .btn:focus-within,
165
+ .btn-default:focus-within,
166
+ .btn-file:focus-within,
167
+ .btn-success:focus-within,
168
+ .form-control:focus-within,
169
+ .irs-line:focus-within,
170
+ input[type="button"]:focus-within,
171
+ input[type="submit"]:focus-within {
172
+ outline: 5px solid #ffab00 !important;
173
+ outline-offset: 1px;
174
+ box-shadow: 0 0 0 6px rgba(255, 171, 0, 0.25);
175
+ z-index: 2;
176
+ }
177
+
178
+
179
  /* Responsive design */
180
  @media (max-width: 768px) {
181
  .col-md-4 {