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
|