Update interface.py
Browse files- interface.py +4 -7
interface.py
CHANGED
@@ -40,7 +40,7 @@ def parse_bounds(bounds_str, num_params):
|
|
40 |
upper_bounds = [np.inf] * num_params
|
41 |
return lower_bounds, upper_bounds
|
42 |
|
43 |
-
def generate_analysis(prompt, max_length=
|
44 |
"""
|
45 |
Genera un análisis utilizando el modelo Yi-Coder-9B-Chat.
|
46 |
"""
|
@@ -51,7 +51,7 @@ def generate_analysis(prompt, max_length=1024):
|
|
51 |
with torch.no_grad():
|
52 |
outputs = model.generate(
|
53 |
**inputs,
|
54 |
-
max_new_tokens=max_length,
|
55 |
eos_token_id=tokenizer.eos_token_id,
|
56 |
pad_token_id=tokenizer.eos_token_id
|
57 |
)
|
@@ -62,7 +62,7 @@ def generate_analysis(prompt, max_length=1024):
|
|
62 |
print(f"Error al generar el análisis con Yi-Coder: {e}. Usando análisis por defecto.")
|
63 |
return "Análisis generado por el modelo de lenguaje."
|
64 |
|
65 |
-
@gpu_decorator(duration=
|
66 |
def process_and_plot(
|
67 |
file,
|
68 |
biomass_eq1, biomass_eq2, biomass_eq3,
|
@@ -141,7 +141,6 @@ def process_and_plot(
|
|
141 |
bounds=(lower_bounds, upper_bounds)
|
142 |
)
|
143 |
biomass_results.append({
|
144 |
-
# 'model': main_model, # Eliminado para evitar problemas de serialización
|
145 |
'y_pred': y_pred.tolist(), # Convertir a lista para serialización
|
146 |
'equation': equation,
|
147 |
'params': main_model.params['biomass']
|
@@ -169,7 +168,6 @@ def process_and_plot(
|
|
169 |
bounds=(lower_bounds, upper_bounds)
|
170 |
)
|
171 |
substrate_results.append({
|
172 |
-
# 'model': main_model, # Eliminado para evitar problemas de serialización
|
173 |
'y_pred': y_pred.tolist(), # Convertir a lista para serialización
|
174 |
'equation': equation,
|
175 |
'params': main_model.params['substrate']
|
@@ -197,7 +195,6 @@ def process_and_plot(
|
|
197 |
bounds=(lower_bounds, upper_bounds)
|
198 |
)
|
199 |
product_results.append({
|
200 |
-
# 'model': main_model, # Eliminado para evitar problemas de serialización
|
201 |
'y_pred': y_pred.tolist(), # Convertir a lista para serialización
|
202 |
'equation': equation,
|
203 |
'params': main_model.params['product']
|
@@ -257,6 +254,6 @@ Analiza los siguientes resultados experimentales y proporciona un veredicto sobr
|
|
257 |
"""
|
258 |
|
259 |
# Generar el análisis utilizando Yi-Coder
|
260 |
-
analysis = generate_analysis(prompt, max_length=
|
261 |
|
262 |
return image, analysis
|
|
|
40 |
upper_bounds = [np.inf] * num_params
|
41 |
return lower_bounds, upper_bounds
|
42 |
|
43 |
+
def generate_analysis(prompt, max_length=100): # Reducido a 100
|
44 |
"""
|
45 |
Genera un análisis utilizando el modelo Yi-Coder-9B-Chat.
|
46 |
"""
|
|
|
51 |
with torch.no_grad():
|
52 |
outputs = model.generate(
|
53 |
**inputs,
|
54 |
+
max_new_tokens=max_length, # Limitar la generación a 100 tokens
|
55 |
eos_token_id=tokenizer.eos_token_id,
|
56 |
pad_token_id=tokenizer.eos_token_id
|
57 |
)
|
|
|
62 |
print(f"Error al generar el análisis con Yi-Coder: {e}. Usando análisis por defecto.")
|
63 |
return "Análisis generado por el modelo de lenguaje."
|
64 |
|
65 |
+
@gpu_decorator(duration=100) # Reducido de 600 a 100 segundos
|
66 |
def process_and_plot(
|
67 |
file,
|
68 |
biomass_eq1, biomass_eq2, biomass_eq3,
|
|
|
141 |
bounds=(lower_bounds, upper_bounds)
|
142 |
)
|
143 |
biomass_results.append({
|
|
|
144 |
'y_pred': y_pred.tolist(), # Convertir a lista para serialización
|
145 |
'equation': equation,
|
146 |
'params': main_model.params['biomass']
|
|
|
168 |
bounds=(lower_bounds, upper_bounds)
|
169 |
)
|
170 |
substrate_results.append({
|
|
|
171 |
'y_pred': y_pred.tolist(), # Convertir a lista para serialización
|
172 |
'equation': equation,
|
173 |
'params': main_model.params['substrate']
|
|
|
195 |
bounds=(lower_bounds, upper_bounds)
|
196 |
)
|
197 |
product_results.append({
|
|
|
198 |
'y_pred': y_pred.tolist(), # Convertir a lista para serialización
|
199 |
'equation': equation,
|
200 |
'params': main_model.params['product']
|
|
|
254 |
"""
|
255 |
|
256 |
# Generar el análisis utilizando Yi-Coder
|
257 |
+
analysis = generate_analysis(prompt, max_length=100) # Reducido a 100
|
258 |
|
259 |
return image, analysis
|