stable-diffusion-webui

Форк
0
/
test_txt2img.py 
89 строк · 3.1 Кб
1

2
import pytest
3
import requests
4

5

6
@pytest.fixture()
7
def url_txt2img(base_url):
8
    return f"{base_url}/sdapi/v1/txt2img"
9

10

11
@pytest.fixture()
12
def simple_txt2img_request():
13
    return {
14
        "batch_size": 1,
15
        "cfg_scale": 7,
16
        "denoising_strength": 0,
17
        "enable_hr": False,
18
        "eta": 0,
19
        "firstphase_height": 0,
20
        "firstphase_width": 0,
21
        "height": 64,
22
        "n_iter": 1,
23
        "negative_prompt": "",
24
        "prompt": "example prompt",
25
        "restore_faces": False,
26
        "s_churn": 0,
27
        "s_noise": 1,
28
        "s_tmax": 0,
29
        "s_tmin": 0,
30
        "sampler_index": "Euler a",
31
        "seed": -1,
32
        "seed_resize_from_h": -1,
33
        "seed_resize_from_w": -1,
34
        "steps": 3,
35
        "styles": [],
36
        "subseed": -1,
37
        "subseed_strength": 0,
38
        "tiling": False,
39
        "width": 64,
40
    }
41

42

43
def test_txt2img_simple_performed(url_txt2img, simple_txt2img_request):
44
    assert requests.post(url_txt2img, json=simple_txt2img_request).status_code == 200
45

46

47
def test_txt2img_with_negative_prompt_performed(url_txt2img, simple_txt2img_request):
48
    simple_txt2img_request["negative_prompt"] = "example negative prompt"
49
    assert requests.post(url_txt2img, json=simple_txt2img_request).status_code == 200
50

51

52
def test_txt2img_with_complex_prompt_performed(url_txt2img, simple_txt2img_request):
53
    simple_txt2img_request["prompt"] = "((emphasis)), (emphasis1:1.1), [to:1], [from::2], [from:to:0.3], [alt|alt1]"
54
    assert requests.post(url_txt2img, json=simple_txt2img_request).status_code == 200
55

56

57
def test_txt2img_not_square_image_performed(url_txt2img, simple_txt2img_request):
58
    simple_txt2img_request["height"] = 128
59
    assert requests.post(url_txt2img, json=simple_txt2img_request).status_code == 200
60

61

62
def test_txt2img_with_hrfix_performed(url_txt2img, simple_txt2img_request):
63
    simple_txt2img_request["enable_hr"] = True
64
    assert requests.post(url_txt2img, json=simple_txt2img_request).status_code == 200
65

66

67
def test_txt2img_with_tiling_performed(url_txt2img, simple_txt2img_request):
68
    simple_txt2img_request["tiling"] = True
69
    assert requests.post(url_txt2img, json=simple_txt2img_request).status_code == 200
70

71

72
def test_txt2img_with_restore_faces_performed(url_txt2img, simple_txt2img_request):
73
    simple_txt2img_request["restore_faces"] = True
74
    assert requests.post(url_txt2img, json=simple_txt2img_request).status_code == 200
75

76

77
@pytest.mark.parametrize("sampler", ["PLMS", "DDIM", "UniPC"])
78
def test_txt2img_with_vanilla_sampler_performed(url_txt2img, simple_txt2img_request, sampler):
79
    simple_txt2img_request["sampler_index"] = sampler
80
    assert requests.post(url_txt2img, json=simple_txt2img_request).status_code == 200
81

82

83
def test_txt2img_multiple_batches_performed(url_txt2img, simple_txt2img_request):
84
    simple_txt2img_request["n_iter"] = 2
85
    assert requests.post(url_txt2img, json=simple_txt2img_request).status_code == 200
86

87

88
def test_txt2img_batch_performed(url_txt2img, simple_txt2img_request):
89
    simple_txt2img_request["batch_size"] = 2
90
    assert requests.post(url_txt2img, json=simple_txt2img_request).status_code == 200
91

Использование cookies

Мы используем файлы cookie в соответствии с Политикой конфиденциальности и Политикой использования cookies.

Нажимая кнопку «Принимаю», Вы даете АО «СберТех» согласие на обработку Ваших персональных данных в целях совершенствования нашего веб-сайта и Сервиса GitVerse, а также повышения удобства их использования.

Запретить использование cookies Вы можете самостоятельно в настройках Вашего браузера.