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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 3 |
|
| 4 |
-
def sepia(input_img):
|
| 5 |
-
sepia_filter = np.array([
|
| 6 |
-
[0.393, 0.769, 0.189],
|
| 7 |
-
[0.349, 0.686, 0.168],
|
| 8 |
-
[0.272, 0.534, 0.131]
|
| 9 |
-
])
|
| 10 |
-
sepia_img = input_img.dot(sepia_filter.T)
|
| 11 |
-
sepia_img /= sepia_img.max()
|
| 12 |
-
return sepia_img
|
| 13 |
-
|
| 14 |
-
demo = gr.Interface(sepia, gr.Image(), "image")
|
| 15 |
if __name__ == "__main__":
|
| 16 |
demo.launch()
|
|
|
|
| 1 |
+
import os
|
| 2 |
+
import openai
|
| 3 |
import gradio as gr
|
| 4 |
+
import numpy as np
|
| 5 |
+
import torch
|
| 6 |
+
from PIL import Image
|
| 7 |
+
import matplotlib.pyplot as plt
|
| 8 |
+
import importlib.util
|
| 9 |
+
from transformers import pipeline
|
| 10 |
+
import requests
|
| 11 |
+
|
| 12 |
+
# Set your OpenAI API key (ensure the environment variable is set or replace with your key)
|
| 13 |
+
openai.api_key = os.getenv("OPENAI_API_KEY", "your-openai-api-key-here")
|
| 14 |
+
|
| 15 |
+
def install_sam2_if_needed():
|
| 16 |
+
"""
|
| 17 |
+
Check if SAM2 is installed, and install it if needed.
|
| 18 |
+
"""
|
| 19 |
+
if importlib.util.find_spec("sam2") is not None:
|
| 20 |
+
print("SAM2 is already installed.")
|
| 21 |
+
return
|
| 22 |
+
|
| 23 |
+
try:
|
| 24 |
+
import pip
|
| 25 |
+
print("Installing SAM2 from GitHub...")
|
| 26 |
+
pip.main(['install', 'git+https://github.com/facebookresearch/sam2.git'])
|
| 27 |
+
print("SAM2 installed successfully.")
|
| 28 |
+
except Exception as e:
|
| 29 |
+
print(f"Error installing SAM2: {e}")
|
| 30 |
+
print("You may need to manually install SAM2: !pip install git+https://github.com/facebookresearch/sam2.git")
|
| 31 |
+
raise
|
| 32 |
+
|
| 33 |
+
def detect_objects_owlv2(text_query, image, threshold=0.1):
|
| 34 |
+
"""
|
| 35 |
+
Detect objects in an image using OWLv2 model.
|
| 36 |
+
|
| 37 |
+
Args:
|
| 38 |
+
text_query (str): Text description of objects to detect
|
| 39 |
+
image (PIL.Image or numpy.ndarray): Input image
|
| 40 |
+
threshold (float): Detection threshold
|
| 41 |
+
|
| 42 |
+
Returns:
|
| 43 |
+
list: List of detections with bbox, label, and score
|
| 44 |
+
"""
|
| 45 |
+
# Initialize the OWL-ViT model
|
| 46 |
+
detector = pipeline(model="google/owlv2-base-patch16-ensemble", task="zero-shot-object-detection")
|
| 47 |
+
|
| 48 |
+
# Convert numpy array to PIL Image if needed
|
| 49 |
+
if isinstance(image, np.ndarray):
|
| 50 |
+
image = Image.fromarray(image)
|
| 51 |
+
|
| 52 |
+
# Run detection
|
| 53 |
+
predictions = detector(image, candidate_labels=[text_query])
|
| 54 |
+
|
| 55 |
+
# Filter by threshold and format results
|
| 56 |
+
detections = []
|
| 57 |
+
for pred in predictions:
|
| 58 |
+
if pred['score'] >= threshold:
|
| 59 |
+
bbox = pred['box']
|
| 60 |
+
# Normalize bbox coordinates (OWL-ViT returns absolute coordinates)
|
| 61 |
+
width, height = image.size
|
| 62 |
+
normalized_bbox = [
|
| 63 |
+
bbox['xmin'] / width,
|
| 64 |
+
bbox['ymin'] / height,
|
| 65 |
+
bbox['xmax'] / width,
|
| 66 |
+
bbox['ymax'] / height
|
| 67 |
+
]
|
| 68 |
+
|
| 69 |
+
detection = {
|
| 70 |
+
'label': pred['label'],
|
| 71 |
+
'bbox': normalized_bbox,
|
| 72 |
+
'score': pred['score']
|
| 73 |
+
}
|
| 74 |
+
detections.append(detection)
|
| 75 |
+
|
| 76 |
+
return detections
|
| 77 |
+
|
| 78 |
+
def generate_masks_from_detections(detections, image, model_name="facebook/sam2-hiera-large"):
|
| 79 |
+
"""
|
| 80 |
+
Generate segmentation masks for objects detected by OWLv2 using SAM2 from Hugging Face.
|
| 81 |
+
|
| 82 |
+
Args:
|
| 83 |
+
detections (list): List of detections [{'label': str, 'bbox': [x1, y1, x2, y2], 'score': float}, ...]
|
| 84 |
+
image (PIL.Image.Image or str): The image or path to the image to analyze
|
| 85 |
+
model_name (str): Hugging Face model name for SAM2.
|
| 86 |
+
|
| 87 |
+
Returns:
|
| 88 |
+
list: List of detections with added 'mask' arrays.
|
| 89 |
+
"""
|
| 90 |
+
install_sam2_if_needed()
|
| 91 |
+
from sam2.sam2_image_predictor import SAM2ImagePredictor
|
| 92 |
+
|
| 93 |
+
# Load image
|
| 94 |
+
if isinstance(image, str):
|
| 95 |
+
image = Image.open(image)
|
| 96 |
+
elif isinstance(image, np.ndarray):
|
| 97 |
+
image = Image.fromarray(image)
|
| 98 |
+
|
| 99 |
+
image_np = np.array(image.convert("RGB"))
|
| 100 |
+
H, W = image_np.shape[:2]
|
| 101 |
+
|
| 102 |
+
device = "cuda" if torch.cuda.is_available() else "cpu"
|
| 103 |
+
print(f"Using device: {device}")
|
| 104 |
+
print(f"Loading SAM2 model from Hugging Face: {model_name}")
|
| 105 |
+
predictor = SAM2ImagePredictor.from_pretrained(model_name)
|
| 106 |
+
predictor.model.to(device)
|
| 107 |
+
|
| 108 |
+
# Convert normalized bboxes to pixels
|
| 109 |
+
input_boxes = []
|
| 110 |
+
for det in detections:
|
| 111 |
+
x1, y1, x2, y2 = det['bbox']
|
| 112 |
+
input_boxes.append([int(x1 * W), int(y1 * H), int(x2 * W), int(y2 * H)])
|
| 113 |
+
input_boxes = np.array(input_boxes)
|
| 114 |
+
|
| 115 |
+
print(f"Processing image and predicting masks for {len(input_boxes)} boxes...")
|
| 116 |
+
with torch.inference_mode():
|
| 117 |
+
predictor.set_image(image_np)
|
| 118 |
+
if device == "cuda":
|
| 119 |
+
with torch.autocast("cuda", dtype=torch.bfloat16):
|
| 120 |
+
masks, scores, _ = predictor.predict(
|
| 121 |
+
point_coords=None, point_labels=None,
|
| 122 |
+
box=input_boxes, multimask_output=False
|
| 123 |
+
)
|
| 124 |
+
else:
|
| 125 |
+
masks, scores, _ = predictor.predict(
|
| 126 |
+
point_coords=None, point_labels=None,
|
| 127 |
+
box=input_boxes, multimask_output=False
|
| 128 |
+
)
|
| 129 |
+
|
| 130 |
+
# Attach masks to detections, handling both (1,H,W) and (H,W) outputs
|
| 131 |
+
results = []
|
| 132 |
+
for i, det in enumerate(detections):
|
| 133 |
+
raw = masks[i]
|
| 134 |
+
if raw.ndim == 3:
|
| 135 |
+
mask = raw[0]
|
| 136 |
+
else:
|
| 137 |
+
mask = raw
|
| 138 |
+
mask = mask.astype(np.uint8)
|
| 139 |
+
|
| 140 |
+
new_det = det.copy()
|
| 141 |
+
new_det['mask'] = mask
|
| 142 |
+
results.append(new_det)
|
| 143 |
+
|
| 144 |
+
print(f"Successfully generated {len(results)} masks.")
|
| 145 |
+
return results
|
| 146 |
+
|
| 147 |
+
def overlay_detections_on_image(image, detections_with_masks, show_masks=True, show_boxes=True, show_labels=True):
|
| 148 |
+
"""
|
| 149 |
+
Overlay detections (boxes and/or masks) on the image and return as numpy array.
|
| 150 |
+
|
| 151 |
+
Args:
|
| 152 |
+
image: Input image (PIL.Image or numpy array)
|
| 153 |
+
detections_with_masks: List of detections with masks
|
| 154 |
+
show_masks: Whether to show segmentation masks
|
| 155 |
+
show_boxes: Whether to show bounding boxes
|
| 156 |
+
show_labels: Whether to show labels
|
| 157 |
+
|
| 158 |
+
Returns:
|
| 159 |
+
numpy.ndarray: Image with overlaid detections
|
| 160 |
+
"""
|
| 161 |
+
# Convert to PIL Image if needed
|
| 162 |
+
if isinstance(image, np.ndarray):
|
| 163 |
+
image = Image.fromarray(image)
|
| 164 |
+
|
| 165 |
+
image_np = np.array(image.convert("RGB"))
|
| 166 |
+
height, width = image_np.shape[:2]
|
| 167 |
+
|
| 168 |
+
# Create figure without displaying
|
| 169 |
+
fig, ax = plt.subplots(1, 1, figsize=(12, 8))
|
| 170 |
+
ax.imshow(image_np)
|
| 171 |
+
|
| 172 |
+
# Define colors for different instances
|
| 173 |
+
colors = plt.cm.tab10(np.linspace(0, 1, 10))
|
| 174 |
+
|
| 175 |
+
# Plot each detection
|
| 176 |
+
for i, detection in enumerate(detections_with_masks):
|
| 177 |
+
bbox = detection['bbox']
|
| 178 |
+
label = detection['label']
|
| 179 |
+
score = detection['score']
|
| 180 |
+
|
| 181 |
+
# Convert normalized bbox to pixel coordinates
|
| 182 |
+
x1, y1, x2, y2 = bbox
|
| 183 |
+
x1_px, y1_px = int(x1 * width), int(y1 * height)
|
| 184 |
+
x2_px, y2_px = int(x2 * width), int(y2 * height)
|
| 185 |
+
|
| 186 |
+
# Color for this instance
|
| 187 |
+
color = colors[i % len(colors)]
|
| 188 |
+
|
| 189 |
+
# Display mask if available and requested
|
| 190 |
+
if show_masks and 'mask' in detection:
|
| 191 |
+
mask = detection['mask']
|
| 192 |
+
mask_color = np.zeros((height, width, 4), dtype=np.float32)
|
| 193 |
+
mask_color[mask > 0] = [color[0], color[1], color[2], 0.5]
|
| 194 |
+
ax.imshow(mask_color)
|
| 195 |
+
|
| 196 |
+
# Draw bounding box if requested
|
| 197 |
+
if show_boxes:
|
| 198 |
+
rect = plt.Rectangle((x1_px, y1_px), x2_px - x1_px, y2_px - y1_px,
|
| 199 |
+
fill=False, edgecolor=color, linewidth=2)
|
| 200 |
+
ax.add_patch(rect)
|
| 201 |
+
|
| 202 |
+
# Add label and score if requested
|
| 203 |
+
if show_labels:
|
| 204 |
+
ax.text(x1_px, y1_px - 5, f"{label}: {score:.2f}",
|
| 205 |
+
color='white', bbox=dict(facecolor=color, alpha=0.8), fontsize=10)
|
| 206 |
+
|
| 207 |
+
ax.axis('off')
|
| 208 |
+
|
| 209 |
+
# Convert plot to numpy array
|
| 210 |
+
fig.canvas.draw()
|
| 211 |
+
result_array = np.frombuffer(fig.canvas.tostring_rgb(), dtype=np.uint8)
|
| 212 |
+
result_array = result_array.reshape(fig.canvas.get_width_height()[::-1] + (3,))
|
| 213 |
+
|
| 214 |
+
plt.close(fig) # Important: close the figure to free memory
|
| 215 |
+
|
| 216 |
+
return result_array
|
| 217 |
+
|
| 218 |
+
def get_single_prompt(user_input):
|
| 219 |
+
"""
|
| 220 |
+
Uses OpenAI to rephrase the user's chatter into a single, concise prompt for object detection.
|
| 221 |
+
The generated prompt will not include any question marks.
|
| 222 |
+
"""
|
| 223 |
+
if not user_input.strip():
|
| 224 |
+
user_input = "Detect objects in the image"
|
| 225 |
+
|
| 226 |
+
prompt_instruction = (
|
| 227 |
+
f"Based on the following user input, generate a single, concise prompt for object detection. "
|
| 228 |
+
f"Do not include any question marks in the output. "
|
| 229 |
+
f"User input: \"{user_input}\""
|
| 230 |
+
)
|
| 231 |
+
|
| 232 |
+
response = openai.chat.completions.create(
|
| 233 |
+
model="gpt-4o", # adjust model name if needed
|
| 234 |
+
messages=[{"role": "user", "content": prompt_instruction}],
|
| 235 |
+
temperature=0.3,
|
| 236 |
+
max_tokens=50,
|
| 237 |
+
)
|
| 238 |
+
|
| 239 |
+
generated_prompt = response.choices[0].message.content.strip()
|
| 240 |
+
# Ensure no question marks remain
|
| 241 |
+
generated_prompt = generated_prompt.replace("?", "")
|
| 242 |
+
return generated_prompt
|
| 243 |
+
|
| 244 |
+
def is_count_query(user_input):
|
| 245 |
+
"""
|
| 246 |
+
Check if the user's input indicates a counting request.
|
| 247 |
+
Looks for common keywords such as "count", "how many", "number of", etc.
|
| 248 |
+
"""
|
| 249 |
+
keywords = ["count", "how many", "number of", "total", "get me a count"]
|
| 250 |
+
for kw in keywords:
|
| 251 |
+
if kw.lower() in user_input.lower():
|
| 252 |
+
return True
|
| 253 |
+
return False
|
| 254 |
+
|
| 255 |
+
def process_question_and_detect(user_input, image, threshold, use_sam):
|
| 256 |
+
"""
|
| 257 |
+
1. Uses OpenAI to generate a single, concise prompt (without question marks) from the user's input.
|
| 258 |
+
2. Feeds that prompt to the custom detection function.
|
| 259 |
+
3. Optionally generates segmentation masks using SAM2.
|
| 260 |
+
4. Overlays the detection results on the image.
|
| 261 |
+
5. If the user's input implies a counting request, it also returns the count of detected objects.
|
| 262 |
+
"""
|
| 263 |
+
if image is None:
|
| 264 |
+
return None, "Please upload an image."
|
| 265 |
+
|
| 266 |
+
try:
|
| 267 |
+
# Generate the concise prompt from the user's input
|
| 268 |
+
generated_prompt = get_single_prompt(user_input)
|
| 269 |
+
|
| 270 |
+
# Run object detection using the generated prompt
|
| 271 |
+
detections = detect_objects_owlv2(generated_prompt, image, threshold=threshold)
|
| 272 |
+
|
| 273 |
+
# Generate masks if SAM is enabled
|
| 274 |
+
if use_sam and len(detections) > 0:
|
| 275 |
+
try:
|
| 276 |
+
detections_with_masks = generate_masks_from_detections(detections, image)
|
| 277 |
+
except Exception as e:
|
| 278 |
+
print(f"SAM2 failed, using detections without masks: {e}")
|
| 279 |
+
detections_with_masks = detections
|
| 280 |
+
else:
|
| 281 |
+
detections_with_masks = detections
|
| 282 |
+
|
| 283 |
+
# Overlay results on the image
|
| 284 |
+
viz = overlay_detections_on_image(image, detections_with_masks,
|
| 285 |
+
show_masks=use_sam,
|
| 286 |
+
show_boxes=True,
|
| 287 |
+
show_labels=True)
|
| 288 |
+
|
| 289 |
+
# If the user's input implies a counting request, include the count
|
| 290 |
+
count_text = ""
|
| 291 |
+
if is_count_query(user_input):
|
| 292 |
+
count = len(detections)
|
| 293 |
+
count_text = f"Detected {count} objects."
|
| 294 |
+
|
| 295 |
+
output_text = f"Generated prompt: {generated_prompt}\n{count_text}"
|
| 296 |
+
if len(detections) == 0:
|
| 297 |
+
output_text += f"\nNo objects detected with threshold {threshold}. Try lowering the threshold."
|
| 298 |
+
|
| 299 |
+
print(output_text)
|
| 300 |
+
return viz, output_text
|
| 301 |
+
|
| 302 |
+
except Exception as e:
|
| 303 |
+
error_msg = f"Error during detection: {str(e)}"
|
| 304 |
+
print(error_msg)
|
| 305 |
+
return image, error_msg
|
| 306 |
+
|
| 307 |
+
# Gradio interface
|
| 308 |
+
with gr.Blocks() as demo:
|
| 309 |
+
gr.Markdown("# Custom Object Detection and Counting App")
|
| 310 |
+
gr.Markdown(
|
| 311 |
+
"""
|
| 312 |
+
Enter your input (for example:
|
| 313 |
+
- "What is the number of fruit in my image?"
|
| 314 |
+
- "How many bicycles can you see?"
|
| 315 |
+
- "Get me a count of my bottles")
|
| 316 |
+
and upload an image.
|
| 317 |
+
The app uses OpenAI to generate a single, concise prompt for object detection (without question marks),
|
| 318 |
+
then runs the detection using OWL-ViT. Optionally, SAM2 can generate precise segmentation masks.
|
| 319 |
+
"""
|
| 320 |
+
)
|
| 321 |
+
|
| 322 |
+
with gr.Row():
|
| 323 |
+
with gr.Column():
|
| 324 |
+
user_input = gr.Textbox(label="Enter your input", placeholder="Type your input here...")
|
| 325 |
+
image_input = gr.Image(label="Upload Image", type="numpy")
|
| 326 |
+
|
| 327 |
+
with gr.Row():
|
| 328 |
+
threshold_slider = gr.Slider(
|
| 329 |
+
minimum=0.01,
|
| 330 |
+
maximum=1.0,
|
| 331 |
+
value=0.1,
|
| 332 |
+
step=0.01,
|
| 333 |
+
label="Detection Threshold",
|
| 334 |
+
info="Lower values detect more objects but may include false positives"
|
| 335 |
+
)
|
| 336 |
+
use_sam_checkbox = gr.Checkbox(
|
| 337 |
+
label="Use SAM2 for Segmentation",
|
| 338 |
+
value=False,
|
| 339 |
+
info="Enable to generate precise segmentation masks (requires additional computation)"
|
| 340 |
+
)
|
| 341 |
+
|
| 342 |
+
submit_btn = gr.Button("Detect and Count")
|
| 343 |
+
|
| 344 |
+
with gr.Column():
|
| 345 |
+
output_image = gr.Image(label="Detection Result")
|
| 346 |
+
output_text = gr.Textbox(label="Output Details", lines=3)
|
| 347 |
+
|
| 348 |
+
submit_btn.click(
|
| 349 |
+
fn=process_question_and_detect,
|
| 350 |
+
inputs=[user_input, image_input, threshold_slider, use_sam_checkbox],
|
| 351 |
+
outputs=[output_image, output_text]
|
| 352 |
+
)
|
| 353 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 354 |
if __name__ == "__main__":
|
| 355 |
demo.launch()
|