Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -130,11 +130,11 @@ def predict(radio, dict, word_mask, prompt=""):
|
|
| 130 |
plt.imsave(filename,torch.sigmoid(preds[0][0]))
|
| 131 |
img2 = cv2.imread(filename)
|
| 132 |
#if ret == True:
|
| 133 |
-
|
| 134 |
-
|
| 135 |
-
|
| 136 |
-
|
| 137 |
-
|
| 138 |
else:
|
| 139 |
img = transform(dict["image"]).unsqueeze(0)
|
| 140 |
|
|
@@ -161,11 +161,12 @@ def predict(radio, dict, word_mask, prompt=""):
|
|
| 161 |
img2 = cv2.imread(filename)
|
| 162 |
|
| 163 |
#if ret == True:
|
| 164 |
-
|
| 165 |
-
|
| 166 |
-
|
| 167 |
-
|
| 168 |
-
|
|
|
|
| 169 |
with autocast(device): #"cuda"
|
| 170 |
images = pipe(prompt = prompt, init_image=init_image, mask_image=mask, strength=0.8)["sample"]
|
| 171 |
return images[0]
|
|
|
|
| 130 |
plt.imsave(filename,torch.sigmoid(preds[0][0]))
|
| 131 |
img2 = cv2.imread(filename)
|
| 132 |
#if ret == True:
|
| 133 |
+
gray_image = cv2.cvtColor(img2, cv2.COLOR_BGR2GRAY)
|
| 134 |
+
(thresh, bw_image) = cv2.threshold(gray_image, 100, 255, cv2.THRESH_BINARY)
|
| 135 |
+
cv2.cvtColor(bw_image, cv2.COLOR_BGR2RGB)
|
| 136 |
+
mask = Image.fromarray(np.uint8(bw_image)).convert('RGB')
|
| 137 |
+
os.remove(filename)
|
| 138 |
else:
|
| 139 |
img = transform(dict["image"]).unsqueeze(0)
|
| 140 |
|
|
|
|
| 161 |
img2 = cv2.imread(filename)
|
| 162 |
|
| 163 |
#if ret == True:
|
| 164 |
+
gray_image = cv2.cvtColor(img2, cv2.COLOR_BGR2GRAY)
|
| 165 |
+
(thresh, bw_image) = cv2.threshold(gray_image, 100, 255, cv2.THRESH_BINARY)
|
| 166 |
+
cv2.cvtColor(bw_image, cv2.COLOR_BGR2RGB)
|
| 167 |
+
mask = Image.fromarray(np.uint8(bw_image)).convert('RGB')
|
| 168 |
+
os.remove(filename)
|
| 169 |
+
|
| 170 |
with autocast(device): #"cuda"
|
| 171 |
images = pipe(prompt = prompt, init_image=init_image, mask_image=mask, strength=0.8)["sample"]
|
| 172 |
return images[0]
|