-
Notifications
You must be signed in to change notification settings - Fork 899
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Min Shi
committed
Apr 2, 2024
1 parent
8b0b4ef
commit 830297e
Showing
10 changed files
with
132 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
17 changes: 17 additions & 0 deletions
17
...romptflow/tests/test_configs/flows/eval_flow_with_image_resume_random_fail/count_image.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
from typing import List | ||
from promptflow import tool | ||
from promptflow.contracts.multimedia import Image | ||
|
||
|
||
@tool | ||
def aggregate(images: List[Image]): | ||
from promptflow import log_metric | ||
image_count = 0 | ||
for image in images: | ||
if not isinstance(image, Image): | ||
print(f"Invalid image: {image}") | ||
else: | ||
image_count += 1 | ||
log_metric(key="image_count", value=image_count) | ||
|
||
return image_count |
9 changes: 9 additions & 0 deletions
9
src/promptflow/tests/test_configs/flows/eval_flow_with_image_resume_random_fail/data.jsonl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
{"input_image": {"data:image/jpg;path": "logo.gif"}} | ||
{"input_image": {"data:image/png;path": "logo.jpg"}} | ||
{"input_image": {"data:image/png;path": "logo.png"}} | ||
{"input_image": {"data:image/jpg;path": "logo.gif"}} | ||
{"input_image": {"data:image/png;path": "logo.jpg"}} | ||
{"input_image": {"data:image/png;path": "logo.png"}} | ||
{"input_image": {"data:image/jpg;path": "logo.gif"}} | ||
{"input_image": {"data:image/png;path": "logo.jpg"}} | ||
{"input_image": {"data:image/png;path": "logo.png"}} |
18 changes: 18 additions & 0 deletions
18
...promptflow/tests/test_configs/flows/eval_flow_with_image_resume_random_fail/flip_image.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import io | ||
import random | ||
from pathlib import Path | ||
from promptflow import tool | ||
from promptflow.contracts.multimedia import Image | ||
from PIL import Image as PIL_Image | ||
|
||
|
||
@tool | ||
def passthrough(input_image: Image) -> Image: | ||
if random.random() < 0.5: | ||
raise ValueError("Random failure") | ||
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") |
25 changes: 25 additions & 0 deletions
25
...promptflow/tests/test_configs/flows/eval_flow_with_image_resume_random_fail/flow.dag.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
$schema: https://azuremlschemas.azureedge.net/promptflow/latest/Flow.schema.json | ||
inputs: | ||
input_image: | ||
type: image | ||
default: https://developer.microsoft.com/_devcom/images/logo-ms-social.png | ||
outputs: | ||
output_image: | ||
type: string | ||
reference: ${flip_image.output} | ||
nodes: | ||
- name: flip_image | ||
type: python | ||
source: | ||
type: code | ||
path: flip_image.py | ||
inputs: | ||
input_image: ${inputs.input_image} | ||
- name: count_image | ||
type: python | ||
source: | ||
type: code | ||
path: count_image.py | ||
inputs: | ||
images: ${flip_image.output} | ||
aggregation: true |
Binary file added
BIN
+73 KB
...tflow/tests/test_configs/flows/eval_flow_with_image_resume_random_fail/logo.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+137 KB
...tflow/tests/test_configs/flows/eval_flow_with_image_resume_random_fail/logo.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+38.5 KB
...tflow/tests/test_configs/flows/eval_flow_with_image_resume_random_fail/logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
7 changes: 7 additions & 0 deletions
7
...tests/test_configs/flows/eval_flow_with_image_resume_random_fail/question_on_image.jinja2
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
# system: | ||
As an AI assistant, your task involves interpreting images and responding to questions about the image. | ||
Remember to provide accurate answers based on the information present in the image. | ||
|
||
# user: | ||
{{question}} | ||
![image]({{test_image}}) |
2 changes: 2 additions & 0 deletions
2
...mptflow/tests/test_configs/flows/eval_flow_with_image_resume_random_fail/requirements.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
promptflow | ||
promptflow-tools |