From 26f9ccebbb8257d3359651750963607d933686a2 Mon Sep 17 00:00:00 2001 From: Siddharth Kumar Sah Date: Fri, 14 Jul 2023 13:54:42 +0800 Subject: [PATCH] Delete notebook directory --- notebook/getting_started.ipynb | 50 ---------------------------------- 1 file changed, 50 deletions(-) delete mode 100644 notebook/getting_started.ipynb diff --git a/notebook/getting_started.ipynb b/notebook/getting_started.ipynb deleted file mode 100644 index c865bab..0000000 --- a/notebook/getting_started.ipynb +++ /dev/null @@ -1,50 +0,0 @@ -# Start the timer -import time -start_time = time.time() - -import numpy as np -import matplotlib.pyplot as plt -import requests -from PIL import Image -from io import BytesIO -from lang_sam import LangSAM - -model = LangSAM() -image_url = "https://static01.nyt.com/images/2020/09/08/well/physed-cycle-walk/physed-cycle-walk-videoSixteenByNineJumbo1600-v2.jpg" -response = requests.get(image_url) -image_pil = Image.open(BytesIO(response.content)).convert("RGB") -text_prompt = "bicycle" - -masks, boxes, phrases, logits = model.predict(image_pil, text_prompt) - -# Convert masks to numpy arrays -masks_np = [mask.squeeze().cpu().numpy() for mask in masks] - -# Visualize the masks -if len(masks_np) > 1: - fig, axes = plt.subplots(1, len(masks_np), figsize=(12, 4)) - for i, mask in enumerate(masks_np): - axes[i].imshow(mask, cmap='gray') - axes[i].set_title('Mask {}'.format(i+1)) - axes[i].axis('off') -else: - fig, ax = plt.subplots(figsize=(6, 4)) - ax.imshow(masks_np[0], cmap='gray') - ax.set_title('Mask') - ax.axis('off') - -# Save the mask as an image in the current working directory -mask_path = 'image_mask.png' -mask_image = Image.fromarray((masks_np[0] * 255).astype(np.uint8)) -mask_image.save(mask_path) - -plt.show() - -# Print other variables -print("Boxes:", boxes) -print("Phrases:", phrases) -print("Logits:", logits) - -# Calculate the elapsed time -elapsed_time = time.time() - start_time -print("Elapsed Time:", elapsed_time, "seconds")