AI-assisted Notebook generation#
We can also use bia-bob
to generate entire Jupyter notebooks in a single shot if we can describe our task in detail enough.
Therefore, it might be necessary to use bioimage-analyst’s terminology.
When using bia-bob to prompt LLMs, the prompts you enter including existing variable names etc. are sent to the LLM provider. Do not submit any sensitive, secret or private information. Also check bia-bob’s code recommendations before executing them. LLMs make mistakes.
First, we configure bia-bob:
from dotenv import load_dotenv
load_dotenv()
import os
from bia_bob import bob
bob.initialize(endpoint='https://chat-ai.academiccloud.de/v1', model='openai-gpt-oss-120b', api_key=os.environ.get('KISSKI_API_KEY'))
#bob.initialize(endpoint='https://llm.scads.ai/v1', model='openai/gpt-oss-120b', api_key=os.environ.get('SCADSAI_API_KEY'))
When formulating a complex task to bia-bob
, go step-by-step, make bullet points and try to provide as many details as you can. Keep in mind: Bob cannot see what you see. It only knows about some python functions for image analysis and the text you write to it.
%%bob generate a jupyter notebook that
* loads data/blobs.tif
* segments the bright blobs using thresholding and connected component labeling
* measures the area of the objects
* prints out the average area
A notebook has been saved as blob_segmentation_and_area_analysis_1.ipynb.
Exercise#
Ask Bob to measure area and perimeter of the objects and plot them against each other.