Download send.py from HyperHail/C: direct link, hf CLI and curl.
- Browser
- Download file 1.39 kB
-
https://huggingface.co/spaces/HyperHail/C/resolve/main/send.py
- Command line
-
hf download hf://spaces/HyperHail/C/send.py
-
curl -L -o send.py https://huggingface.co/spaces/HyperHail/C/resolve/main/send.py
1.39 kB
| 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)) | |