forked from open-mmlab/mmagic
-
Notifications
You must be signed in to change notification settings - Fork 0
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
Showing
4 changed files
with
69 additions
and
9 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
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
40 changes: 40 additions & 0 deletions
40
tests/test_apis/test_inferencers/test_diffusers_pipeline_inferencer.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,40 @@ | ||
# Copyright (c) OpenMMLab. All rights reserved. | ||
import pytest | ||
import platform | ||
from mmengine.utils import digit_version | ||
from mmengine.utils.dl_utils import TORCH_VERSION | ||
|
||
from mmagic.apis.inferencers.diffusers_pipeline_inferencer import \ | ||
DiffusersPipelineInferencer | ||
from mmagic.utils import register_all_modules | ||
|
||
register_all_modules() | ||
|
||
|
||
@pytest.mark.skipif( | ||
'win' in platform.system().lower() | ||
or digit_version(TORCH_VERSION) <= digit_version('1.8.1'), | ||
reason='skip on windows due to limited RAM' | ||
'and get_submodule requires torch >= 1.9.0') | ||
def test_diffusers_pipeline_inferencer(): | ||
cfg = dict( | ||
model=dict( | ||
type='DiffusionPipeline', | ||
from_pretrained='runwayml/stable-diffusion-v1-5')) | ||
|
||
inferencer_instance = DiffusersPipelineInferencer(cfg, None) | ||
text_prompts = 'Japanese anime style, girl' | ||
negative_prompt = 'bad face, bad hands' | ||
result = inferencer_instance( | ||
text=text_prompts, | ||
negative_prompt=negative_prompt, | ||
height=128, | ||
width=128) | ||
assert result[1][0].size == (128, 128) | ||
|
||
|
||
def teardown_module(): | ||
import gc | ||
gc.collect() | ||
globals().clear() | ||
locals().clear() |