C2MV commited on
Commit
f29d404
·
verified ·
1 Parent(s): 5170c42

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +69 -43
app.py CHANGED
@@ -91,14 +91,17 @@ def process_complete_pipeline(
91
  """Pipeline completo de procesamiento"""
92
  progress_updates = []
93
 
 
 
 
94
  # Paso 1: Procesar con BiotechU4
95
  progress_updates.append("🔄 Procesando datos biotecnológicos...")
96
  plot, df_data, status = process_biotech_data(
97
  file, models, component, use_de, maxfev, exp_names
98
  )
99
 
100
- if "Error" in status:
101
- return None, None, None, status, None, None
102
 
103
  progress_updates.append("✅ Análisis biotecnológico completado")
104
 
@@ -107,7 +110,7 @@ def process_complete_pipeline(
107
  csv_file = download_results_as_csv(df_data)
108
 
109
  if not csv_file:
110
- return plot, df_data, None, "Error al descargar resultados", None, status
111
 
112
  # Paso 3: Generar análisis con Claude
113
  progress_updates.append(f"🤖 Generando análisis con {claude_model}...")
@@ -125,8 +128,62 @@ def process_complete_pipeline(
125
 
126
  return plot, df_data, analysis, code, report_file, final_status
127
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
128
  # Interfaz de Gradio
129
- with gr.Blocks(theme=theme, title="🧬 BioTech Analysis & Report Generator") as demo:
130
  gr.Markdown(
131
  """
132
  # 🧬 BioTech Analysis & Report Generator
@@ -145,7 +202,7 @@ with gr.Blocks(theme=theme, title="🧬 BioTech Analysis & Report Generator") as
145
  file_input = gr.File(
146
  label="📁 Archivo de datos (CSV/Excel)",
147
  file_types=[".csv", ".xlsx", ".xls"],
148
- elem_classes="file-input"
149
  )
150
 
151
  with gr.Group():
@@ -155,8 +212,7 @@ with gr.Blocks(theme=theme, title="🧬 BioTech Analysis & Report Generator") as
155
  choices=['logistic', 'gompertz', 'moser', 'baranyi', 'monod',
156
  'contois', 'andrews', 'tessier', 'richards', 'stannard', 'huang'],
157
  value=['logistic', 'gompertz', 'moser', 'baranyi'],
158
- label="📊 Modelos a probar",
159
- elem_classes="models-input"
160
  )
161
 
162
  component_input = gr.Dropdown(
@@ -227,13 +283,14 @@ with gr.Blocks(theme=theme, title="🧬 BioTech Analysis & Report Generator") as
227
  process_btn = gr.Button(
228
  "🚀 Ejecutar Pipeline Completo",
229
  variant="primary",
230
- size="lg"
 
231
  )
232
 
233
  with gr.Column(scale=2):
234
  gr.Markdown("## 📈 Resultados")
235
 
236
- with gr.Tabs():
237
  with gr.TabItem("📊 Visualización"):
238
  plot_output = gr.Plot(label="Gráfico interactivo")
239
 
@@ -291,38 +348,7 @@ with gr.Blocks(theme=theme, title="🧬 BioTech Analysis & Report Generator") as
291
  ]
292
  )
293
 
294
- # Ejemplos
295
- gr.Examples(
296
- examples=[
297
- [
298
- "example_data.csv",
299
- ['logistic', 'gompertz'],
300
- 'all',
301
- False,
302
- 50000,
303
- "Crecimiento bacteriano",
304
- 'claude-3-7-sonnet-20250219',
305
- 'detailed',
306
- 'es',
307
- "Analizar el crecimiento bacteriano en diferentes condiciones de temperatura",
308
- 'PDF'
309
- ]
310
- ],
311
- inputs=[
312
- file_input,
313
- models_input,
314
- component_input,
315
- use_de_input,
316
- maxfev_input,
317
- exp_names_input,
318
- claude_model_input,
319
- detail_level_input,
320
- language_input,
321
- additional_specs_input,
322
- export_format_input
323
- ]
324
- )
325
-
326
  gr.Markdown(
327
  """
328
  ---
@@ -343,6 +369,6 @@ with gr.Blocks(theme=theme, title="🧬 BioTech Analysis & Report Generator") as
343
  if __name__ == "__main__":
344
  demo.launch(
345
  share=True,
346
- show_error=True,
347
- favicon_path="🧬"
348
  )
 
91
  """Pipeline completo de procesamiento"""
92
  progress_updates = []
93
 
94
+ if not file:
95
+ return None, None, None, None, None, "❌ Por favor, sube un archivo para procesar"
96
+
97
  # Paso 1: Procesar con BiotechU4
98
  progress_updates.append("🔄 Procesando datos biotecnológicos...")
99
  plot, df_data, status = process_biotech_data(
100
  file, models, component, use_de, maxfev, exp_names
101
  )
102
 
103
+ if plot is None or "Error" in str(status):
104
+ return None, None, None, None, None, status
105
 
106
  progress_updates.append("✅ Análisis biotecnológico completado")
107
 
 
110
  csv_file = download_results_as_csv(df_data)
111
 
112
  if not csv_file:
113
+ return plot, df_data, None, None, None, "Error al descargar resultados"
114
 
115
  # Paso 3: Generar análisis con Claude
116
  progress_updates.append(f"🤖 Generando análisis con {claude_model}...")
 
128
 
129
  return plot, df_data, analysis, code, report_file, final_status
130
 
131
+ # CSS personalizado
132
+ custom_css = """
133
+ .container {
134
+ max-width: 1400px;
135
+ margin: auto;
136
+ }
137
+
138
+ .file-upload {
139
+ border: 2px dashed #3b82f6;
140
+ border-radius: 12px;
141
+ padding: 20px;
142
+ text-align: center;
143
+ transition: all 0.3s ease;
144
+ }
145
+
146
+ .file-upload:hover {
147
+ border-color: #2563eb;
148
+ background-color: #eff6ff;
149
+ }
150
+
151
+ button.primary {
152
+ background: linear-gradient(135deg, #3b82f6 0%, #8b5cf6 100%);
153
+ border: none;
154
+ color: white;
155
+ font-weight: bold;
156
+ transition: all 0.3s ease;
157
+ }
158
+
159
+ button.primary:hover {
160
+ transform: translateY(-2px);
161
+ box-shadow: 0 10px 20px rgba(59, 130, 246, 0.3);
162
+ }
163
+
164
+ .tabs {
165
+ border-radius: 12px;
166
+ overflow: hidden;
167
+ }
168
+
169
+ .tab-nav {
170
+ background-color: #f3f4f6;
171
+ padding: 5px;
172
+ }
173
+
174
+ .tab-nav button {
175
+ border-radius: 8px;
176
+ margin: 0 2px;
177
+ }
178
+
179
+ .tab-nav button.selected {
180
+ background-color: white;
181
+ box-shadow: 0 2px 4px rgba(0,0,0,0.1);
182
+ }
183
+ """
184
+
185
  # Interfaz de Gradio
186
+ with gr.Blocks(theme=theme, title="BioTech Analysis & Report Generator", css=custom_css) as demo:
187
  gr.Markdown(
188
  """
189
  # 🧬 BioTech Analysis & Report Generator
 
202
  file_input = gr.File(
203
  label="📁 Archivo de datos (CSV/Excel)",
204
  file_types=[".csv", ".xlsx", ".xls"],
205
+ elem_classes=["file-upload"]
206
  )
207
 
208
  with gr.Group():
 
212
  choices=['logistic', 'gompertz', 'moser', 'baranyi', 'monod',
213
  'contois', 'andrews', 'tessier', 'richards', 'stannard', 'huang'],
214
  value=['logistic', 'gompertz', 'moser', 'baranyi'],
215
+ label="📊 Modelos a probar"
 
216
  )
217
 
218
  component_input = gr.Dropdown(
 
283
  process_btn = gr.Button(
284
  "🚀 Ejecutar Pipeline Completo",
285
  variant="primary",
286
+ size="lg",
287
+ elem_classes=["primary"]
288
  )
289
 
290
  with gr.Column(scale=2):
291
  gr.Markdown("## 📈 Resultados")
292
 
293
+ with gr.Tabs(elem_classes=["tabs"]):
294
  with gr.TabItem("📊 Visualización"):
295
  plot_output = gr.Plot(label="Gráfico interactivo")
296
 
 
348
  ]
349
  )
350
 
351
+ # Footer
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
352
  gr.Markdown(
353
  """
354
  ---
 
369
  if __name__ == "__main__":
370
  demo.launch(
371
  share=True,
372
+ show_error=True
373
+ # Removido favicon_path que causaba el error
374
  )