C
File size: 1,390 Bytes
2040978
 
 
 
89180ab
 
b76416f
32d3c44
89180ab
 
 
2040978
 
 
b76416f
2040978
b76416f
2040978
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
89180ab
2040978
 
 
 
 
 
 
 
 
 
 
 
 
ae3e7a3
2040978
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
import json
import urllib.parse
import urllib.request

BASE_URL = "https://q6-c.hf.space"
PASSWORD = "haip"
TYPE = "checkpoint+sampler+scheduler"
GENERATION = "g4"
POSITIVE = open('positive.txt', 'r').read()
NEGATIVE = open('neg.txt', 'r').read()
SAMPLER = ""
MODEL_1 = 52
MODEL_2 = 50

if TYPE in ("checkpoint", "checkpoint+sampler+scheduler"):
    body = {
        "type": TYPE,
        "positive": POSITIVE,
        "negative": NEGATIVE,
    }

if TYPE == "sampler":
    body = {
        "type": "sampler",
        "model_1": MODEL_1,
        "model_2": MODEL_2,
        "positive": POSITIVE,
        "negative": NEGATIVE,
    }

if TYPE == "scheduler":
    body = {
        "type": "scheduler",
        "model_1": MODEL_1,
        "model_2": MODEL_2,
        "sampler": SAMPLER,
        "positive": POSITIVE,
        "negative": NEGATIVE,
    }

if TYPE == "sampler+scheduler":
    body = {
        "type": "sampler+scheduler",
        "model_1": MODEL_1,
        "model_2": MODEL_2,
        "positive": POSITIVE,
        "negative": NEGATIVE,
    }

body["generation"] = GENERATION
query = urllib.parse.urlencode({"p": PASSWORD})
request = urllib.request.Request(
    f"{BASE_URL}/start?{query}",
    data=json.dumps(body).encode(),
    headers={"Content-Type": "application/json"},
    method="POST",
)
with urllib.request.urlopen(request) as response:
    print(json.load(response))