itsyogesh commited on
Commit
e10b294
·
verified ·
1 Parent(s): aa6fbd2

Fix not working issues

Browse files
Files changed (1) hide show
  1. app.py +10 -9
app.py CHANGED
@@ -173,19 +173,20 @@ def inference(image):
173
  image_tensor, orig_size = load_image(image_path, hypar)
174
  mask = predict(net, image_tensor, orig_size, hypar, device)
175
 
176
- cropped_mask = crop_to_signature(mask)
177
- processed_mask = smooth_and_denoise(cropped_mask)
178
 
179
- # Convert processed mask to PIL image
180
  pil_mask = Image.fromarray(processed_mask).convert('L')
181
  im_rgb = Image.open(image).convert("RGB")
 
182
 
183
- # Crop im_rgb and im_dark to match the size of pil_mask
184
- im_rgba = im_rgb.crop((0, 0, pil_mask.width, pil_mask.height))
185
- im_dark = Image.new('RGB', (pil_mask.width, pil_mask.height), (0, 0, 0))
186
-
187
- im_rgba.putalpha(pil_mask)
188
- im_dark.putalpha(pil_mask)
189
 
190
  return [im_rgba, pil_mask, im_dark]
191
 
 
173
  image_tensor, orig_size = load_image(image_path, hypar)
174
  mask = predict(net, image_tensor, orig_size, hypar, device)
175
 
176
+ # Process the mask without cropping
177
+ processed_mask = smooth_and_denoise(mask)
178
 
179
+ # Convert processed mask to PIL image and resize to match original image
180
  pil_mask = Image.fromarray(processed_mask).convert('L')
181
  im_rgb = Image.open(image).convert("RGB")
182
+ pil_mask_resized = pil_mask.resize(im_rgb.size, Image.ANTIALIAS)
183
 
184
+ im_dark = Image.new('RGB', im_rgb.size, (0, 0, 0))
185
+
186
+ # Apply resized mask to images
187
+ im_rgba = im_rgb.copy()
188
+ im_rgba.putalpha(pil_mask_resized)
189
+ im_dark.putalpha(pil_mask_resized)
190
 
191
  return [im_rgba, pil_mask, im_dark]
192