Spaces:
Runtime error
Runtime error
Commit
·
90c26be
1
Parent(s):
c50efc8
Delete generate.py
Browse files- generate.py +0 -65
generate.py
DELETED
|
@@ -1,65 +0,0 @@
|
|
| 1 |
-
import httpx
|
| 2 |
-
|
| 3 |
-
async def generate(prompt, seed, model, nsfw, sampler, steps):
|
| 4 |
-
headers = {
|
| 5 |
-
'Accept': '*/*',
|
| 6 |
-
'Accept-Language': 'en-US,en;q=0.9,it;q=0.8',
|
| 7 |
-
'Connection': 'keep-alive',
|
| 8 |
-
'Content-Type': 'application/json',
|
| 9 |
-
'Origin': 'https://aqualxx.github.io',
|
| 10 |
-
'Referer': 'https://aqualxx.github.io/',
|
| 11 |
-
'Sec-Fetch-Dest': 'empty',
|
| 12 |
-
'Sec-Fetch-Mode': 'cors',
|
| 13 |
-
'Sec-Fetch-Site': 'cross-site',
|
| 14 |
-
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/111.0.0.0 Safari/537.36',
|
| 15 |
-
'apikey': '0000000000',
|
| 16 |
-
'sec-ch-ua': '"Google Chrome";v="111", "Not(A:Brand";v="8", "Chromium";v="111"',
|
| 17 |
-
'sec-ch-ua-mobile': '?0',
|
| 18 |
-
'sec-ch-ua-platform': '"Windows"',
|
| 19 |
-
}
|
| 20 |
-
|
| 21 |
-
json_data = {
|
| 22 |
-
'prompt': prompt,
|
| 23 |
-
'params': {
|
| 24 |
-
'steps': steps,
|
| 25 |
-
'n': 1,
|
| 26 |
-
'sampler_name': sampler,
|
| 27 |
-
'width': 576,
|
| 28 |
-
'height': 576,
|
| 29 |
-
'cfg_scale': 24,
|
| 30 |
-
'seed_variation': 1000,
|
| 31 |
-
'seed': seed,
|
| 32 |
-
'karras': True,
|
| 33 |
-
'denoising_strength': 1,
|
| 34 |
-
'tiling': False,
|
| 35 |
-
'hires_fix': False,
|
| 36 |
-
'clip_skip': 1,
|
| 37 |
-
'post_processing': [],
|
| 38 |
-
},
|
| 39 |
-
'nsfw': False,
|
| 40 |
-
'censor_nsfw': False,
|
| 41 |
-
'trusted_workers': False,
|
| 42 |
-
'models': [
|
| 43 |
-
model,
|
| 44 |
-
],
|
| 45 |
-
'shared': False,
|
| 46 |
-
'r2': True,
|
| 47 |
-
'jobId': '',
|
| 48 |
-
'index': 0,
|
| 49 |
-
'gathered': False,
|
| 50 |
-
'failed': False,
|
| 51 |
-
}
|
| 52 |
-
|
| 53 |
-
async with httpx.AsyncClient(timeout=300) as client:
|
| 54 |
-
response = await client.post('https://stablehorde.net/api/v2/generate/async', headers=headers, json=json_data)
|
| 55 |
-
image_id = response.json()["id"]
|
| 56 |
-
response = await client.get('https://stablehorde.net/api/v2/generate/check/'+image_id, headers=headers)
|
| 57 |
-
response = response.json()
|
| 58 |
-
while not response["finished"]:
|
| 59 |
-
response = await client.get('https://stablehorde.net/api/v2/generate/check/'+image_id, headers=headers)
|
| 60 |
-
response = response.json()
|
| 61 |
-
response = await client.get('https://stablehorde.net/api/v2/generate/status/'+image_id, headers=headers)
|
| 62 |
-
response = response.json()
|
| 63 |
-
image_url = response["generations"][0]["img"]
|
| 64 |
-
seed = response["generations"][0]["seed"]
|
| 65 |
-
return image_url, seed
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|