Skip to content

Commit

Permalink
Flip image horizontal instead of pass through
Browse files Browse the repository at this point in the history
  • Loading branch information
guming-learning committed Dec 18, 2023
1 parent b060922 commit 36deae7
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 12 deletions.
2 changes: 1 addition & 1 deletion examples/flows/standard/describe-image/README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Describe image flow
A flow that take image input and uses OpenAI GPT-4V tool to describe it. We also added a pass_through node from input to output to demo PromptFlow's ability to output image in both node output and flow output.
A flow that take image input, flip it horizontally and uses OpenAI GPT-4V tool to describe it.

Tools used in this flow:
- `OpenAI GPT-4V` tool
Expand Down
14 changes: 14 additions & 0 deletions examples/flows/standard/describe-image/flip_image.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import io
from promptflow import tool
from promptflow.contracts.multimedia import Image
from PIL import Image as PIL_Image


@tool
def passthrough(input_image: Image) -> Image:
image_stream = io.BytesIO(input_image)
pil_image = PIL_Image.open(image_stream)
flipped_image = pil_image.transpose(PIL_Image.FLIP_LEFT_RIGHT)
buffer = io.BytesIO()
flipped_image.save(buffer, format="PNG")
return Image(buffer.getvalue(), mime_type="image/png")
8 changes: 4 additions & 4 deletions examples/flows/standard/describe-image/flow.dag.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ outputs:
reference: ${question_on_image.output}
output_image:
type: string
reference: ${passthrough.output}
reference: ${flip_image.output}
nodes:
- name: question_on_image
type: custom_llm
Expand All @@ -22,13 +22,13 @@ nodes:
inputs:
connection: openai_connection
question: ${inputs.question}
test_image: ${passthrough.output}
test_image: ${flip_image.output}
model: gpt-4-vision-preview
max_tokens: 200
- name: passthrough
- name: flip_image
type: python
source:
type: code
path: passthrough.py
path: flip_image.py
inputs:
input_image: ${inputs.input_image}
7 changes: 0 additions & 7 deletions examples/flows/standard/describe-image/passthrough.py

This file was deleted.

0 comments on commit 36deae7

Please sign in to comment.