Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -98,9 +98,15 @@ def predict(radio, dict, word_mask, prompt=""):
|
|
98 |
init_image = dict['image'].convert('RGB').resize((imgRes, imgRes))
|
99 |
filename = f"{uuid.uuid4()}.png"
|
100 |
plt.imsave(filename,torch.sigmoid(preds[0][0]))
|
101 |
-
|
|
|
|
|
|
|
|
|
|
|
102 |
#if ret == True:
|
103 |
-
gray_image = cv2.cvtColor(
|
|
|
104 |
(thresh, bw_image) = cv2.threshold(gray_image, 100, 255, cv2.THRESH_BINARY)
|
105 |
cv2.cvtColor(bw_image, cv2.COLOR_BGR2RGB)
|
106 |
mask = Image.fromarray(np.uint8(bw_image)).convert('RGB')
|
@@ -128,10 +134,13 @@ def predict(radio, dict, word_mask, prompt=""):
|
|
128 |
init_image = dict['image'].convert('RGB').resize((imgRes, imgRes))
|
129 |
filename = f"{uuid.uuid4()}.png"
|
130 |
plt.imsave(filename,torch.sigmoid(preds[0][0]))
|
131 |
-
img2 = cv2.imread(filename)
|
|
|
|
|
|
|
132 |
|
133 |
#if ret == True:
|
134 |
-
gray_image = cv2.cvtColor(
|
135 |
(thresh, bw_image) = cv2.threshold(gray_image, 100, 255, cv2.THRESH_BINARY)
|
136 |
cv2.cvtColor(bw_image, cv2.COLOR_BGR2RGB)
|
137 |
mask = Image.fromarray(np.uint8(bw_image)).convert('RGB')
|
|
|
98 |
init_image = dict['image'].convert('RGB').resize((imgRes, imgRes))
|
99 |
filename = f"{uuid.uuid4()}.png"
|
100 |
plt.imsave(filename,torch.sigmoid(preds[0][0]))
|
101 |
+
|
102 |
+
img = cv2.imread(filename, cv2.IMREAD_GRAYSCALE)
|
103 |
+
img = Image.fromarray(img)
|
104 |
+
|
105 |
+
#img2 = cv2.imread(filename)
|
106 |
+
|
107 |
#if ret == True:
|
108 |
+
gray_image = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
|
109 |
+
|
110 |
(thresh, bw_image) = cv2.threshold(gray_image, 100, 255, cv2.THRESH_BINARY)
|
111 |
cv2.cvtColor(bw_image, cv2.COLOR_BGR2RGB)
|
112 |
mask = Image.fromarray(np.uint8(bw_image)).convert('RGB')
|
|
|
134 |
init_image = dict['image'].convert('RGB').resize((imgRes, imgRes))
|
135 |
filename = f"{uuid.uuid4()}.png"
|
136 |
plt.imsave(filename,torch.sigmoid(preds[0][0]))
|
137 |
+
#img2 = cv2.imread(filename)
|
138 |
+
|
139 |
+
img = cv2.imread(filename, cv2.IMREAD_GRAYSCALE)
|
140 |
+
img = Image.fromarray(img)
|
141 |
|
142 |
#if ret == True:
|
143 |
+
gray_image = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
|
144 |
(thresh, bw_image) = cv2.threshold(gray_image, 100, 255, cv2.THRESH_BINARY)
|
145 |
cv2.cvtColor(bw_image, cv2.COLOR_BGR2RGB)
|
146 |
mask = Image.fromarray(np.uint8(bw_image)).convert('RGB')
|