@@ -69,18 +69,17 @@ def image_object_embedding_flow(
6969 )
7070 img_embeddings = data_scope .add_collector ()
7171 with data_scope ["images" ].row () as img :
72- caption_ds = img ["content" ] .transform (
72+ img ["caption" ] = flow_builder .transform (
7373 cocoindex .functions .ExtractByLlm (
74- llm_spec = cocoindex .llm .LlmSpec (
75- api_type = cocoindex .LlmApiType .OLLAMA ,
76- model = "llama3.1" ,
74+ llm_spec = cocoindex .LlmSpec (
75+ api_type = cocoindex .LlmApiType .GEMINI , model = "gemini-2.0-flash"
7776 ),
78- # Replace by this spec below, to use OpenAI API model instead of ollama
77+ # Replace by this spec below, to use OpenAI API model instead of gemini
7978 # llm_spec=cocoindex.LlmSpec(
8079 # api_type=cocoindex.LlmApiType.OPENAI, model="gpt-4o"),
81- # Replace by this spec below, to use Gemini API model
82- # llm_spec=cocoindex.LlmSpec(
83- # api_type=cocoindex.LlmApiType.GEMINI , model="gemini-2.0-flash "),
80+ # Replace by this spec below, to use Ollama API model
81+ # llm_spec=cocoindex.llm. LlmSpec(
82+ # api_type=cocoindex.LlmApiType.OLLAMA , model="llama3.1 "),
8483 # Replace by this spec below, to use Anthropic API model
8584 # llm_spec=cocoindex.LlmSpec(
8685 # api_type=cocoindex.LlmApiType.ANTHROPIC, model="claude-3-5-sonnet-latest"),
@@ -91,14 +90,15 @@ def image_object_embedding_flow(
9190 "Mention what each animal is doing."
9291 ),
9392 output_type = str ,
94- )
93+ ),
94+ image = img ["content" ],
9595 )
96- embedding_ds = img ["content" ].transform (embed_image )
96+ img [ "embedding" ] = img ["content" ].transform (embed_image )
9797 img_embeddings .collect (
9898 id = cocoindex .GeneratedField .UUID ,
9999 filename = img ["filename" ],
100- caption = caption_ds ,
101- embedding = embedding_ds ,
100+ caption = img [ "caption" ] ,
101+ embedding = img [ "embedding" ] ,
102102 )
103103
104104 img_embeddings .export (
0 commit comments