Spaces:
Runtime error
Runtime error
Commit
·
b4a5884
1
Parent(s):
8577d29
fix slider
Browse files
app.py
CHANGED
|
@@ -112,14 +112,6 @@ def process(width:int, height:int, scale:float, image: np.ndarray):
|
|
| 112 |
figure = packer.visualize()
|
| 113 |
return [figure, packer.total]
|
| 114 |
|
| 115 |
-
def update_scale(width:int, height:int, image: np.ndarray):
|
| 116 |
-
global maxScale
|
| 117 |
-
|
| 118 |
-
widthImage, heightImage = image.shape[:2]
|
| 119 |
-
maxScale = int((width/widthImage + height/heightImage)/2)
|
| 120 |
-
return
|
| 121 |
-
|
| 122 |
-
maxScale = 10
|
| 123 |
if __name__ == "__main__":
|
| 124 |
with gr.Blocks() as demo:
|
| 125 |
gr.Markdown(
|
|
@@ -129,6 +121,7 @@ if __name__ == "__main__":
|
|
| 129 |
"""
|
| 130 |
)
|
| 131 |
|
|
|
|
| 132 |
with gr.Row():
|
| 133 |
with gr.Column():
|
| 134 |
image = gr.Image(image_mode="RGBA")
|
|
@@ -141,8 +134,14 @@ if __name__ == "__main__":
|
|
| 141 |
with gr.Column():
|
| 142 |
plot_output = gr.Plot()
|
| 143 |
total = gr.Number(label="Total")
|
| 144 |
-
|
| 145 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 146 |
|
| 147 |
|
| 148 |
demo.launch()
|
|
|
|
| 112 |
figure = packer.visualize()
|
| 113 |
return [figure, packer.total]
|
| 114 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 115 |
if __name__ == "__main__":
|
| 116 |
with gr.Blocks() as demo:
|
| 117 |
gr.Markdown(
|
|
|
|
| 121 |
"""
|
| 122 |
)
|
| 123 |
|
| 124 |
+
maxScale = gr.State(value=1.0)
|
| 125 |
with gr.Row():
|
| 126 |
with gr.Column():
|
| 127 |
image = gr.Image(image_mode="RGBA")
|
|
|
|
| 134 |
with gr.Column():
|
| 135 |
plot_output = gr.Plot()
|
| 136 |
total = gr.Number(label="Total")
|
| 137 |
+
|
| 138 |
+
def update_scale(width:int, height:int, image: np.ndarray):
|
| 139 |
+
|
| 140 |
+
widthImage, heightImage = image.shape[:2]
|
| 141 |
+
maxScale = int((width/widthImage + height/heightImage)/2)
|
| 142 |
+
return maxScale
|
| 143 |
+
image.change(fn=update_scale, inputs=[width, height, image], outputs=maxScale)
|
| 144 |
+
fit.click(fn=process, inputs=[width, height, scale, maxScale, image], outputs=[plot_output, total])
|
| 145 |
|
| 146 |
|
| 147 |
demo.launch()
|