Update interface.py
Browse files- interface.py +39 -0
interface.py
CHANGED
@@ -1,3 +1,42 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
def process_and_plot(
|
2 |
file,
|
3 |
biomass_eq1, biomass_eq2, biomass_eq3,
|
|
|
1 |
+
# interface.py
|
2 |
+
|
3 |
+
import numpy as np
|
4 |
+
import pandas as pd
|
5 |
+
import matplotlib.pyplot as plt
|
6 |
+
from scipy.optimize import curve_fit
|
7 |
+
from PIL import Image
|
8 |
+
import io
|
9 |
+
from sympy import symbols, lambdify, sympify, Function
|
10 |
+
|
11 |
+
from bioprocess_model import BioprocessModel
|
12 |
+
from decorators import gpu_decorator # Importar el decorador personalizado
|
13 |
+
|
14 |
+
def parse_bounds(bounds_str, num_params):
|
15 |
+
try:
|
16 |
+
# Reemplazar 'inf' por 'np.inf' si el usuario lo escribió así
|
17 |
+
bounds_str = bounds_str.replace('inf', 'np.inf')
|
18 |
+
# Evaluar la cadena de límites
|
19 |
+
bounds = eval(f"[{bounds_str}]")
|
20 |
+
if len(bounds) != num_params:
|
21 |
+
raise ValueError("Número de límites no coincide con el número de parámetros.")
|
22 |
+
lower_bounds = [b[0] for b in bounds]
|
23 |
+
upper_bounds = [b[1] for b in bounds]
|
24 |
+
return lower_bounds, upper_bounds
|
25 |
+
except Exception as e:
|
26 |
+
print(f"Error al parsear los límites: {e}. Usando límites por defecto.")
|
27 |
+
lower_bounds = [-np.inf] * num_params
|
28 |
+
upper_bounds = [np.inf] * num_params
|
29 |
+
return lower_bounds, upper_bounds
|
30 |
+
|
31 |
+
@gpu_decorator(duration=300)
|
32 |
+
def generate_analysis(prompt, max_length=1024, device=None):
|
33 |
+
# Implementación existente para generar análisis usando Hugging Face o similar
|
34 |
+
# Por ejemplo, podrías usar un modelo de lenguaje para generar texto
|
35 |
+
# Aquí se deja como placeholder
|
36 |
+
analysis = "Análisis generado por el modelo de lenguaje."
|
37 |
+
return analysis
|
38 |
+
|
39 |
+
@gpu_decorator(duration=600) # Ajusta la duración según tus necesidades
|
40 |
def process_and_plot(
|
41 |
file,
|
42 |
biomass_eq1, biomass_eq2, biomass_eq3,
|