Skip to content

change: Visually displays the output image provided. #90

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

mustafawiped
Copy link

Imported the matplotlib library to visualize the output images:

import matplotlib.pyplot as plt
Added a new function called show_output_image:
def show_output_image(output_image): Displays the given output image visually. plt.imshow(output_image) plt.axis('off') plt.show()
Modified the test_img2img test case to use parameterization with different sample sizes and step counts:
``
@pytest.mark.parametrize("sampler_enum", Sampler)
@pytest.mark.parametrize("num_samples", [1, 3, 5]) # New parameter: Different sample sizes
@pytest.mark.parametrize("num_steps", [5, 10, 15]) # New parameter: Different step counts
def test_img2img(self, pipeline: SamplingPipeline, sampler_enum, num_samples, num_steps):
output = pipeline.image_to_image(
params=SamplingParams(sampler=sampler_enum.value, steps=num_steps),
image=self.create_init_image(pipeline.specs.height, pipeline.specs.width),
prompt="A professional photograph of an astronaut riding a pig",
negative_prompt="",
samples=num_samples,
)
assert output is not None

# Show the output images visually
for i in range(num_samples):
    show_output_image(output[i])

``
The rest of the class and test cases remain the same as in the previous explanation.

With these changes, we have added visualization capabilities to display the output images produced by the model during the test_img2img test. The test now covers different sample sizes and step counts, allowing us to evaluate the model's performance with varying parameters.

@akx
Copy link
Contributor

akx commented Jul 31, 2023

These tests are run by the CI pipeline; it'd be super weird if they opened windows to show images. If #79 gets merged, you might want that instead.

@mqhc2020
Copy link

Can be written into image files as below (in tests/inference/test_inference.py):

+        NUM_SAMPLES = 1
+        sample = sample.cpu() * 255
+        for i in range(0, NUM_SAMPLES):
+            _sample = sample[i]
+            _sample = np.transpose(_sample.numpy().astype(np.uint8), (1, 2, 0))
+            img = Image.fromarray(_sample)
+            img.save(os.path.join('output', 'output_{}_{}_{}.png'.format(sampler_enum.value, 'ii' if use_init_image else 'ti', i)))

Though all the output images are corrupted. I'm totally lost about it... https://imgur.com/a/vXwKsnI

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants