Spaces:
Sleeping
Sleeping
Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,51 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
import numpy as np
|
3 |
+
import matplotlib.pyplot as plt
|
4 |
+
|
5 |
+
def process_inputs(function_type, amplitude, frequency, text):
|
6 |
+
"""Procesa múltiples entradas"""
|
7 |
+
# Generar visualización matemática
|
8 |
+
x = np.linspace(0, 10, 500)
|
9 |
+
plt.figure(figsize=(10, 6))
|
10 |
+
plt.title(f"Función: {function_type}")
|
11 |
+
|
12 |
+
if function_type == "Senoidal":
|
13 |
+
y = amplitude * np.sin(frequency * x)
|
14 |
+
elif function_type == "Cosenoidal":
|
15 |
+
y = amplitude * np.cos(frequency * x)
|
16 |
+
elif function_type == "Exponencial":
|
17 |
+
y = amplitude * np.exp(-frequency * x)
|
18 |
+
|
19 |
+
plt.plot(x, y)
|
20 |
+
plt.grid(True)
|
21 |
+
plt.xlabel("Eje X")
|
22 |
+
plt.ylabel("Amplitud")
|
23 |
+
|
24 |
+
# Análisis de texto
|
25 |
+
text_analysis = {
|
26 |
+
"Longitud": len(text),
|
27 |
+
"Palabras": len(text.split()),
|
28 |
+
"Mayúsculas": sum(1 for c in text if c.isupper()),
|
29 |
+
"Minúsculas": sum(1 for c in text if c.islower())
|
30 |
+
}
|
31 |
+
|
32 |
+
return plt, text_analysis
|
33 |
+
|
34 |
+
# Crear interfaz de Gradio con la función especificada
|
35 |
+
demo = gr.Interface(
|
36 |
+
fn=process_inputs, # Añadido el argumento fn
|
37 |
+
title="Demo Interactiva Multifuncional",
|
38 |
+
description="Visualización matemática y análisis de texto",
|
39 |
+
inputs=[
|
40 |
+
gr.Dropdown(["Senoidal", "Cosenoidal", "Exponencial"], label="Tipo de Función"),
|
41 |
+
gr.Slider(minimum=0.1, maximum=5, value=1, label="Amplitud"),
|
42 |
+
gr.Slider(minimum=0.1, maximum=5, value=1, label="Frecuencia"),
|
43 |
+
gr.Textbox(label="Texto para Análisis")
|
44 |
+
],
|
45 |
+
outputs=[
|
46 |
+
gr.Plot(label="Visualización Matemática"),
|
47 |
+
gr.JSON(label="Análisis de Texto")
|
48 |
+
]
|
49 |
+
)
|
50 |
+
|
51 |
+
demo.launch()
|