Spaces:
Build error
Build error
Update app.py
Browse files
app.py
CHANGED
|
@@ -2,24 +2,26 @@ import gradio as gr
|
|
| 2 |
import numpy as np
|
| 3 |
import matplotlib.pyplot as plt
|
| 4 |
|
| 5 |
-
def
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
|
|
|
|
|
|
| 14 |
|
| 15 |
iface = gr.Interface(
|
| 16 |
-
fn=
|
| 17 |
inputs=[
|
| 18 |
-
gr.ColorPicker(label="
|
| 19 |
-
gr.Slider(0, 10, 1, label="
|
| 20 |
-
gr.Slider(0, 10, 1, label="
|
| 21 |
-
gr.Slider(0, 10, 1, label="
|
| 22 |
-
gr.Slider(0, 10, 1, label="
|
| 23 |
],
|
| 24 |
outputs="plot",
|
| 25 |
live=True
|
|
|
|
| 2 |
import numpy as np
|
| 3 |
import matplotlib.pyplot as plt
|
| 4 |
|
| 5 |
+
def draw_rectangles(colors, xs, ys, widths, heights):
|
| 6 |
+
figs = []
|
| 7 |
+
for color, x, y, width, height in zip(colors, xs, ys, widths, heights):
|
| 8 |
+
fig, ax = plt.subplots()
|
| 9 |
+
rect = plt.Rectangle((x, y), width, height, color=color)
|
| 10 |
+
ax.add_patch(rect)
|
| 11 |
+
ax.set_xlim(0, 10)
|
| 12 |
+
ax.set_ylim(0, 10)
|
| 13 |
+
plt.axis('off')
|
| 14 |
+
figs.append(fig)
|
| 15 |
+
return figs
|
| 16 |
|
| 17 |
iface = gr.Interface(
|
| 18 |
+
fn=draw_rectangles,
|
| 19 |
inputs=[
|
| 20 |
+
gr.ColorPicker(label="Colores de los Rect谩ngulos", type="text", default=["blue", "red"]),
|
| 21 |
+
gr.Slider(0, 10, 1, label="Posiciones X", default=[3, 6]),
|
| 22 |
+
gr.Slider(0, 10, 1, label="Posiciones Y", default=[3, 4]),
|
| 23 |
+
gr.Slider(0, 10, 1, label="Anchos", default=[2, 3]),
|
| 24 |
+
gr.Slider(0, 10, 1, label="Altos", default=[3, 2])
|
| 25 |
],
|
| 26 |
outputs="plot",
|
| 27 |
live=True
|