* Add cookbook for blurring faces with hosted api * fix: correct Colab URL and spelling errors * fix: strip outputs and remove GPU section * fix: improve code quality and notebook structure * fix: align HTML card and prose style --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: jirka <6035284+Borda@users.noreply.github.com> Co-authored-by: claude[bot] <209825114+claude[bot]@users.noreply.github.com>
7.1 KiB
Vendored
7.1 KiB
Vendored
In [ ]:
!pip3 install -q supervision inference tqdm "Pillow<12"In [ ]:
import supervision as sv
video = sv.download_assets(sv.VideoAssets.GROCERY_STORE)
# Seek directly to frame 800 using the start parameter (O(1) seek)
frame = next(sv.get_video_frames_generator(video, start=800))
sv.plot_image(frame)In [ ]:
import os
from inference_sdk import InferenceHTTPClient
try:
from google.colab import userdata
ROBOFLOW_API_KEY = userdata.get("ROBOFLOW_API_KEY") or ""
except ImportError:
ROBOFLOW_API_KEY = os.environ.get("ROBOFLOW_API_KEY", "")
assert ROBOFLOW_API_KEY, "Set ROBOFLOW_API_KEY in Colab secrets or as env var"
client = InferenceHTTPClient(
api_url="https://detect.roboflow.com",
api_key=ROBOFLOW_API_KEY
)
results = client.infer(frame, model_id="face-detection-mik1i/18")
print(f"Detected {len(results['predictions'])} face(s)")
print(results)In [ ]:
blur = sv.BlurAnnotator(kernel_size=100)
detections = sv.Detections.from_inference(results)
annotated_frame = blur.annotate(scene=frame.copy(), detections=detections)
sv.plot_image(annotated_frame)