Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -16,7 +16,7 @@ depth_model = DPTForDepthEstimation.from_pretrained("Intel/dpt-large")
|
|
16 |
def apply_gaussian_blur(image):
|
17 |
# Resize and preprocess the image
|
18 |
image = image.resize((512, 512)).convert("RGB")
|
19 |
-
inputs =
|
20 |
|
21 |
# Perform semantic segmentation using the model
|
22 |
with torch.no_grad():
|
@@ -30,6 +30,9 @@ def apply_gaussian_blur(image):
|
|
30 |
person_index = 12 # Assuming 12 is the 'person' class index
|
31 |
binary_mask = (segmentation == person_index).numpy().astype(np.uint8) * 255 # Convert to 0 and 255
|
32 |
|
|
|
|
|
|
|
33 |
# Convert the original image to a numpy array
|
34 |
image_np = np.array(image)
|
35 |
|
@@ -47,7 +50,6 @@ def apply_gaussian_blur(image):
|
|
47 |
final_image_pil = Image.fromarray(final_image)
|
48 |
|
49 |
return final_image_pil
|
50 |
-
# return image
|
51 |
|
52 |
def apply_lens_blur(image):
|
53 |
# Resize and preprocess the image
|
|
|
16 |
def apply_gaussian_blur(image):
|
17 |
# Resize and preprocess the image
|
18 |
image = image.resize((512, 512)).convert("RGB")
|
19 |
+
inputs = segmentation_processor(image, return_tensors="pt")
|
20 |
|
21 |
# Perform semantic segmentation using the model
|
22 |
with torch.no_grad():
|
|
|
30 |
person_index = 12 # Assuming 12 is the 'person' class index
|
31 |
binary_mask = (segmentation == person_index).numpy().astype(np.uint8) * 255 # Convert to 0 and 255
|
32 |
|
33 |
+
# Resize the mask to match the image size (512x512)
|
34 |
+
binary_mask = cv2.resize(binary_mask, (512, 512), interpolation=cv2.INTER_NEAREST)
|
35 |
+
|
36 |
# Convert the original image to a numpy array
|
37 |
image_np = np.array(image)
|
38 |
|
|
|
50 |
final_image_pil = Image.fromarray(final_image)
|
51 |
|
52 |
return final_image_pil
|
|
|
53 |
|
54 |
def apply_lens_blur(image):
|
55 |
# Resize and preprocess the image
|