-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Remove abstract component test (#510)
Removing abstract component test and update image caption component test. Resolves #367
- Loading branch information
Showing
4 changed files
with
33 additions
and
68 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
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 @@ | ||
pytest==7.4.2 |
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 |
---|---|---|
@@ -1,27 +1,31 @@ | ||
import pandas as pd | ||
import requests | ||
from caption_images.src.main import CaptionImagesComponent | ||
from fondant.abstract_component_test import AbstractComponentTest | ||
|
||
from src.main import CaptionImagesComponent | ||
|
||
class TestCaptionImagesComponent(AbstractComponentTest): | ||
def create_component(self): | ||
return CaptionImagesComponent( | ||
|
||
def test_image_caption_component(): | ||
image_urls = [ | ||
"https://cdn.pixabay.com/photo/2023/06/29/09/52/angkor-thom-8096092_1280.jpg", | ||
"https://cdn.pixabay.com/photo/2023/07/19/18/56/japanese-beetle-8137606_1280.png", | ||
] | ||
input_dataframe = pd.DataFrame( | ||
{"images": {"data": [requests.get(url).content for url in image_urls]}}) | ||
|
||
expected_output_dataframe = pd.DataFrame( | ||
data={("captions", "text"): {0: "a motorcycle", 1: "a beetle"}}, | ||
) | ||
|
||
component = CaptionImagesComponent( | ||
model_id="Salesforce/blip-image-captioning-base", | ||
batch_size=4, | ||
max_new_tokens=2, | ||
) | ||
|
||
def create_input_data(self): | ||
image_urls = [ | ||
"https://cdn.pixabay.com/photo/2023/06/29/09/52/angkor-thom-8096092_1280.jpg", | ||
"https://cdn.pixabay.com/photo/2023/07/19/18/56/japanese-beetle-8137606_1280.png", | ||
] | ||
return pd.DataFrame( | ||
{"images": {"data": [requests.get(url).content for url in image_urls]}}, | ||
) | ||
output_dataframe = component.transform(input_dataframe) | ||
|
||
def create_output_data(self): | ||
return pd.DataFrame( | ||
data={("captions", "text"): {0: "a motorcycle", 1: "a beetle"}}, | ||
) | ||
pd.testing.assert_frame_equal( | ||
left=expected_output_dataframe, | ||
right=output_dataframe, | ||
check_dtype=False, | ||
) |
This file was deleted.
Oops, something went wrong.