mirror of https://github.com/vladmandic/automatic
fix api info endpoint
parent
ea42bc5aa8
commit
537170fa2d
|
|
@ -5,7 +5,7 @@
|
|||
- EDM samplers for Playground require diffusers==0.27.0
|
||||
- StableCascade requires diffuers side-branch
|
||||
|
||||
## Update for 2024-02-26
|
||||
## Update for 2024-02-28
|
||||
|
||||
- [Playground v2.5](https://huggingface.co/playgroundai/playground-v2.5-1024px-aesthetic)
|
||||
- new model version from Playground: based on SDXL, but with some cool new concepts
|
||||
|
|
@ -39,6 +39,7 @@
|
|||
- fix extra networks refresh
|
||||
- fix sdp memory attention in backend original
|
||||
- fix autodetect sd21 models
|
||||
- fix api info endpoint
|
||||
- exception handler around vram memory stats gather
|
||||
- improve ZLUDA installer with `--use-zluda` cli param, thanks @lshqqytiger
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,62 @@
|
|||
#!/usr/bin/env python
|
||||
import os
|
||||
import io
|
||||
import time
|
||||
import base64
|
||||
import logging
|
||||
import argparse
|
||||
import requests
|
||||
import urllib3
|
||||
from PIL import Image
|
||||
|
||||
sd_url = os.environ.get('SDAPI_URL', "http://127.0.0.1:7860")
|
||||
sd_username = os.environ.get('SDAPI_USR', None)
|
||||
sd_password = os.environ.get('SDAPI_PWD', None)
|
||||
|
||||
logging.basicConfig(level = logging.INFO, format = '%(asctime)s %(levelname)s: %(message)s')
|
||||
log = logging.getLogger(__name__)
|
||||
urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)
|
||||
|
||||
|
||||
def auth():
|
||||
if sd_username is not None and sd_password is not None:
|
||||
return requests.auth.HTTPBasicAuth(sd_username, sd_password)
|
||||
return None
|
||||
|
||||
|
||||
def get(endpoint: str, dct: dict = None):
|
||||
req = requests.get(f'{sd_url}{endpoint}', json=dct, timeout=300, verify=False, auth=auth())
|
||||
if req.status_code != 200:
|
||||
return { 'error': req.status_code, 'reason': req.reason, 'url': req.url }
|
||||
else:
|
||||
return req.json()
|
||||
|
||||
|
||||
def post(endpoint: str, dct: dict = None):
|
||||
req = requests.post(f'{sd_url}{endpoint}', json = dct, timeout=300, verify=False, auth=auth())
|
||||
if req.status_code != 200:
|
||||
return { 'error': req.status_code, 'reason': req.reason, 'url': req.url }
|
||||
else:
|
||||
return req.json()
|
||||
|
||||
|
||||
def encode(fn):
|
||||
with open(fn, 'rb') as f:
|
||||
content = f.read()
|
||||
encoded = base64.b64encode(content).decode()
|
||||
return encoded
|
||||
|
||||
|
||||
def info(args): # pylint: disable=redefined-outer-name
|
||||
t0 = time.time()
|
||||
data = post('/sdapi/v1/png-info', { 'image': encode(args.input) })
|
||||
t1 = time.time()
|
||||
log.info(f'received: {data} time={t1-t0:.2f}')
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
parser = argparse.ArgumentParser(description = 'simple-info')
|
||||
parser.add_argument('--input', required=True, help='input image')
|
||||
args = parser.parse_args()
|
||||
log.info(f'info: {args}')
|
||||
info(args)
|
||||
|
|
@ -146,8 +146,6 @@ def post_pnginfo(req: models.ReqImageInfo):
|
|||
geninfo, items = images.read_info_from_image(image)
|
||||
if geninfo is None:
|
||||
geninfo = ""
|
||||
if items and items['parameters']:
|
||||
del items['parameters']
|
||||
params = generation_parameters_copypaste.parse_generation_parameters(geninfo)
|
||||
script_callbacks.infotext_pasted_callback(geninfo, params)
|
||||
return models.ResImageInfo(info=geninfo, items=items, parameters=params)
|
||||
|
|
|
|||
2
wiki
2
wiki
|
|
@ -1 +1 @@
|
|||
Subproject commit 46e7d15ebc47858179cc8ef8f7c3d2f14e2489a0
|
||||
Subproject commit 5c52cbb7301c3e008a9dfd76702f9321ae7b3a34
|
||||
Loading…
Reference in New Issue