alimotahharynia commited on
Commit
4cd8ad5
1 Parent(s): 5ef1414

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +14 -77
app.py CHANGED
@@ -4,6 +4,7 @@ import torch
4
  import logging
5
  import tempfile
6
  import gradio as gr
 
7
  from datasets import load_dataset
8
  from transformers import AutoTokenizer, GPT2LMHeadModel
9
 
@@ -185,93 +186,30 @@ if __name__ == "__main__":
185
 
186
  generator = SMILESGenerator(model, tokenizer, uniprot_to_sequence)
187
 
188
- with gr.Blocks(theme=gr.themes.Soft(primary_hue="indigo", secondary_hue="teal")) as iface:
189
- custom_css = """
190
- html, body {
191
- background-color: #ffffff !important; /* White background */
192
- color: #333333 !important; /* Dark text color for better contrast */
193
- font-family: 'Roboto', sans-serif !important;
194
- }
195
-
196
  #app-title {
 
197
  text-align: center;
198
- font-size: 36px;
199
- font-weight: 700;
200
- color: #333333 !important; /* Dark title for white background */
201
  margin-bottom: 20px;
202
  }
203
-
204
  #description {
205
  font-size: 18px;
206
- margin-bottom: 40px;
207
  text-align: center;
208
- color: #555555 !important; /* Slightly darker text for description */
209
- }
210
-
211
- .gr-button {
212
- padding: 12px 24px;
213
- font-weight: bold;
214
- background-color: #0066cc !important; /* Muted blue button */
215
- color: white !important;
216
- border-radius: 8px;
217
- border: none;
218
- box-shadow: 0 4px 6px rgba(0, 0, 0, 0.15);
219
- transition: all 0.3s ease;
220
- }
221
-
222
- .gr-button:hover {
223
- background-color: #005cbf !important; /* Darker blue on hover */
224
- transform: translateY(-2px);
225
- box-shadow: 0 6px 10px rgba(0, 0, 0, 0.2);
226
- }
227
-
228
- .gr-input:focus {
229
- border-color: #0066cc !important;
230
- box-shadow: 0 0 8px rgba(0, 102, 204, 0.3) !important;
231
- }
232
-
233
- .gr-output {
234
- height: 120px;
235
- overflow-y: auto;
236
- color: #333333 !important;
237
- padding: 15px;
238
- border-radius: 10px;
239
- border: 2px solid #28a745; /* Green border for file section */
240
- box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
241
- }
242
-
243
- .error-message {
244
- background-color: #f8d7da !important;
245
- border-color: #f5c6cb !important;
246
- color: #721c24 !important;
247
- padding: 15px;
248
- border-radius: 8px;
249
- }
250
-
251
- .success-message {
252
- background-color: #d4edda !important;
253
- border-color: #c3e6cb !important;
254
- color: #155724 !important;
255
- padding: 15px;
256
- border-radius: 8px;
257
- }
258
-
259
- .gr-row {
260
  margin-bottom: 20px;
261
  }
262
-
263
- .file-output {
264
  height: 90px;
265
- overflow-y: auto;
266
- color: #333333 !important;
267
- padding: 15px;
268
- border-radius: 10px;
269
- border: 2px solid #28a745; /* Green border for file section */
270
- box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
271
  }
 
 
 
 
 
272
 
273
- """
274
- iface.css = custom_css
275
  gr.Markdown("## GPT-2 Drug Generator", elem_id="app-title")
276
  gr.Markdown(
277
  "Generate **drug-like SMILES structures** from protein sequences or UniProt IDs. "
@@ -302,11 +240,10 @@ if __name__ == "__main__":
302
  output = gr.JSON(label="Generated SMILES")
303
  file_output = gr.File(
304
  label="Download Results as JSON",
305
- elem_classes=["file-output"]
306
  )
307
 
308
  generate_button = gr.Button("Generate SMILES", elem_id="generate-button")
309
-
310
  generate_button.click(
311
  generate_smiles_gradio,
312
  inputs=[sequence_input, uniprot_id_input, num_generated_slider],
 
4
  import logging
5
  import tempfile
6
  import gradio as gr
7
+ from gradio.themes import Soft
8
  from datasets import load_dataset
9
  from transformers import AutoTokenizer, GPT2LMHeadModel
10
 
 
186
 
187
  generator = SMILESGenerator(model, tokenizer, uniprot_to_sequence)
188
 
189
+ # Apply Gradio theme
190
+ theme = Soft(primary_hue="indigo", secondary_hue="teal")
191
+
192
+ css = """
 
 
 
 
193
  #app-title {
194
+ font-size: 24px;
195
  text-align: center;
 
 
 
196
  margin-bottom: 20px;
197
  }
 
198
  #description {
199
  font-size: 18px;
 
200
  text-align: center;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
201
  margin-bottom: 20px;
202
  }
203
+ #file-output {
 
204
  height: 90px;
 
 
 
 
 
 
205
  }
206
+ #generate-button {
207
+ height: 40px;
208
+ color: #333333 !important;
209
+ }
210
+ """
211
 
212
+ with gr.Blocks(theme=theme, css=css) as iface:
 
213
  gr.Markdown("## GPT-2 Drug Generator", elem_id="app-title")
214
  gr.Markdown(
215
  "Generate **drug-like SMILES structures** from protein sequences or UniProt IDs. "
 
240
  output = gr.JSON(label="Generated SMILES")
241
  file_output = gr.File(
242
  label="Download Results as JSON",
243
+ elem_id=["file-output"]
244
  )
245
 
246
  generate_button = gr.Button("Generate SMILES", elem_id="generate-button")
 
247
  generate_button.click(
248
  generate_smiles_gradio,
249
  inputs=[sequence_input, uniprot_id_input, num_generated_slider],