-
Notifications
You must be signed in to change notification settings - Fork 11
/
stablediff.py
59 lines (52 loc) · 1.89 KB
/
stablediff.py
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
import requests
import json
def get_ai_image(base64_image_string):
headers = {
"Connection": "keep-alive",
"phone_gid": "2862114434",
"Accept": "application/json, text/plain, */*",
"User-Agent": "Mozilla/5.0 (Linux; Android 7.1.2; SM-G955N Build/NRD90M.G955NKSU1AQDC; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/92.0.4515.131 Mobile Safari/537.36 com.meitu.myxj/11270(android7.1.2)/lang:ru/isDeviceSupport64Bit:false MTWebView/4.8.5",
"Content-Type": "application/json;charset=UTF-8",
"Origin": "https://titan-h5.meitu.com",
"X-Requested-With": "com.meitu.meiyancamera",
"Sec-Fetch-Site": "same-site",
"Sec-Fetch-Mode": "cors",
"Sec-Fetch-Dest": "empty",
"Referer": "https://titan-h5.meitu.com/",
"Accept-Language": "ru-RU,ru;q=0.9,en-US;q=0.8,en;q=0.7",
}
params = {
"api_key": "237d6363213c4751ba1775aba648517d",
"api_secret": "b7b1c5865a83461ea5865da3ecc7c03d",
}
json_data = {
"parameter": {
"rsp_media_type": "url",
"strength": 0.45,
"guidance_scale": 7.5,
"prng_seed": "-1",
"num_inference_steps": "50",
"extra_prompt": "",
"extra_negative_prompt": "",
"random_generation": "False",
"type": "1",
"type_generation": "True",
"sensitive_words": "white_kimono",
},
"extra": {},
"media_info_list": [
{
"media_data": base64_image_string,
"media_profiles": {
"media_data_type": "jpg",
},
},
],
}
response = requests.post(
"https://openapi.mtlab.meitu.com/v1/stable_diffusion_anime",
params=params,
headers=headers,
json=json_data,
)
return json.loads(response.content)