Spaces:
Runtime error
Runtime error
Commit ·
a75ebd2
1
Parent(s): 272536e
return empty figure
Browse files
app.py
CHANGED
|
@@ -61,8 +61,22 @@ class BinPacking:
|
|
| 61 |
return self
|
| 62 |
|
| 63 |
def visualize(self):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 64 |
if self.pgrp == None:
|
| 65 |
-
return
|
| 66 |
|
| 67 |
_, thresh = cv2.threshold(self.imgray, 127, 255, 0)
|
| 68 |
contours, _ = cv2.findContours(thresh, cv2.RETR_TREE, cv2.CHAIN_APPROX_SIMPLE)
|
|
@@ -74,7 +88,6 @@ class BinPacking:
|
|
| 74 |
transformedPoints.append([None,None])
|
| 75 |
transformedPoints.append([None,None])
|
| 76 |
|
| 77 |
-
fig = go.Figure()
|
| 78 |
fig.add_trace(go.Scatter(
|
| 79 |
x=[0, self.width, self.width, 0, 0],
|
| 80 |
y=[0, 0, self.height, self.height, 0],
|
|
@@ -88,19 +101,6 @@ class BinPacking:
|
|
| 88 |
mode="lines",
|
| 89 |
textposition="bottom right",
|
| 90 |
))
|
| 91 |
-
fig.update_layout(
|
| 92 |
-
autosize=False,
|
| 93 |
-
width=500,
|
| 94 |
-
height=500,
|
| 95 |
-
margin=dict(
|
| 96 |
-
l=50,
|
| 97 |
-
r=50,
|
| 98 |
-
b=100,
|
| 99 |
-
t=100,
|
| 100 |
-
pad=4
|
| 101 |
-
),
|
| 102 |
-
paper_bgcolor="LightSteelBlue",
|
| 103 |
-
)
|
| 104 |
return fig
|
| 105 |
|
| 106 |
|
|
@@ -137,7 +137,6 @@ if __name__ == "__main__":
|
|
| 137 |
|
| 138 |
with gr.Column():
|
| 139 |
plot_output = gr.Plot()
|
| 140 |
-
total = gr.Number(label="Total")
|
| 141 |
text = gr.Text()
|
| 142 |
|
| 143 |
fit.click(fn=process, inputs=[width, height, scale, image], outputs=[plot_output, text])
|
|
|
|
| 61 |
return self
|
| 62 |
|
| 63 |
def visualize(self):
|
| 64 |
+
fig = go.Figure()
|
| 65 |
+
fig.update_layout(
|
| 66 |
+
autosize=False,
|
| 67 |
+
width=500,
|
| 68 |
+
height=500,
|
| 69 |
+
margin=dict(
|
| 70 |
+
l=50,
|
| 71 |
+
r=50,
|
| 72 |
+
b=100,
|
| 73 |
+
t=100,
|
| 74 |
+
pad=4
|
| 75 |
+
),
|
| 76 |
+
paper_bgcolor="LightSteelBlue",
|
| 77 |
+
)
|
| 78 |
if self.pgrp == None:
|
| 79 |
+
return fig
|
| 80 |
|
| 81 |
_, thresh = cv2.threshold(self.imgray, 127, 255, 0)
|
| 82 |
contours, _ = cv2.findContours(thresh, cv2.RETR_TREE, cv2.CHAIN_APPROX_SIMPLE)
|
|
|
|
| 88 |
transformedPoints.append([None,None])
|
| 89 |
transformedPoints.append([None,None])
|
| 90 |
|
|
|
|
| 91 |
fig.add_trace(go.Scatter(
|
| 92 |
x=[0, self.width, self.width, 0, 0],
|
| 93 |
y=[0, 0, self.height, self.height, 0],
|
|
|
|
| 101 |
mode="lines",
|
| 102 |
textposition="bottom right",
|
| 103 |
))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 104 |
return fig
|
| 105 |
|
| 106 |
|
|
|
|
| 137 |
|
| 138 |
with gr.Column():
|
| 139 |
plot_output = gr.Plot()
|
|
|
|
| 140 |
text = gr.Text()
|
| 141 |
|
| 142 |
fit.click(fn=process, inputs=[width, height, scale, image], outputs=[plot_output, text])
|