Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -10,12 +10,6 @@ import os
|
|
10 |
|
11 |
|
12 |
|
13 |
-
# Empty the images folder before starting
|
14 |
-
for path in os.listdir('images'):
|
15 |
-
os.remove(path)
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
# Define global constants
|
20 |
MAX_WIDTH = 700
|
21 |
|
@@ -69,10 +63,10 @@ if scale:
|
|
69 |
scale_np = cv2.imdecode(scale_np, 1)
|
70 |
|
71 |
# Save image if it isn't already saved
|
72 |
-
if not os.path.exists(
|
73 |
-
with open(
|
74 |
f.write(scale.getbuffer())
|
75 |
-
scale_pil = Image.open(
|
76 |
|
77 |
# Remove file when done
|
78 |
os.remove(os.path.join("images/", scale.name))
|
@@ -123,10 +117,10 @@ if image:
|
|
123 |
image_np = cv2.imdecode(image_np, 1)
|
124 |
|
125 |
# Save image if it isn't already saved
|
126 |
-
if not os.path.exists(
|
127 |
-
with open(
|
128 |
f.write(image.getbuffer())
|
129 |
-
image_pil = Image.open(
|
130 |
|
131 |
# Remove file when done
|
132 |
os.remove(os.path.join("images/", image.name))
|
|
|
10 |
|
11 |
|
12 |
|
|
|
|
|
|
|
|
|
|
|
|
|
13 |
# Define global constants
|
14 |
MAX_WIDTH = 700
|
15 |
|
|
|
63 |
scale_np = cv2.imdecode(scale_np, 1)
|
64 |
|
65 |
# Save image if it isn't already saved
|
66 |
+
if not os.path.exists(scale.name):
|
67 |
+
with open(scale.name, "wb") as f:
|
68 |
f.write(scale.getbuffer())
|
69 |
+
scale_pil = Image.open(scale.name)
|
70 |
|
71 |
# Remove file when done
|
72 |
os.remove(os.path.join("images/", scale.name))
|
|
|
117 |
image_np = cv2.imdecode(image_np, 1)
|
118 |
|
119 |
# Save image if it isn't already saved
|
120 |
+
if not os.path.exists(image.name):
|
121 |
+
with open(image.name, "wb") as f:
|
122 |
f.write(image.getbuffer())
|
123 |
+
image_pil = Image.open(image.name)
|
124 |
|
125 |
# Remove file when done
|
126 |
os.remove(os.path.join("images/", image.name))
|