mirror of
https://github.com/vladmandic/automatic
synced 2026-09-20 01:31:13 +02:00
refactor html-info and do some linting cleanups
This commit is contained in:
+1
-7
@@ -57,6 +57,7 @@ def grid(data):
|
||||
log.info({ 'grid': { 'name': f, 'size': image.size, 'images': len(data.image) } })
|
||||
image.save(f, 'JPEG', exif = exif(data.info, None, 'grid'), optimize = True, quality = 70)
|
||||
return image
|
||||
return data.image
|
||||
|
||||
|
||||
def exif(info, i = None, op = 'generate'):
|
||||
@@ -370,10 +371,3 @@ if __name__ == '__main__':
|
||||
log.info({ 'sampler performance': avg })
|
||||
log.info({ 'stats' : stats })
|
||||
asyncio.run(close())
|
||||
'''
|
||||
except Exception as e:
|
||||
log.info({ 'sampler performance': avg })
|
||||
log.info({ 'stats': stats })
|
||||
log.critical({ 'exception': e })
|
||||
exit()
|
||||
'''
|
||||
|
||||
+1
-1
@@ -14,7 +14,7 @@ from rich import print # pylint: disable=redefined-builtin
|
||||
class Exif: # pylint: disable=single-string-used-for-slots
|
||||
__slots__ = ('__dict__') # pylint: disable=superfluous-parens
|
||||
def __init__(self, image = None):
|
||||
super(Exif, self).__setattr__('exif', Image.Exif())
|
||||
super(Exif, self).__setattr__('exif', Image.Exif()) # pylint: disable=super-with-arguments
|
||||
self.pnginfo = PngImagePlugin.PngInfo()
|
||||
self.tags = {**dict(ExifTags.TAGS.items()), **dict(ExifTags.GPSTAGS.items())}
|
||||
self.ids = {**{v: k for k, v in ExifTags.TAGS.items()}, **{v: k for k, v in ExifTags.GPSTAGS.items()}}
|
||||
|
||||
@@ -18,6 +18,7 @@ from PIL import Image
|
||||
from util import log
|
||||
grid = importlib.import_module('image-grid').grid
|
||||
|
||||
|
||||
def color_to_df(param):
|
||||
colors_pre_list = str(param).replace('([(','').split(', (')[0:-1]
|
||||
df_rgb = [i.split('), ')[0] + ')' for i in colors_pre_list]
|
||||
@@ -87,7 +88,6 @@ def palette(img, params, output):
|
||||
log.info({ 'palette created': output })
|
||||
|
||||
plt.close()
|
||||
return
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
||||
@@ -7,6 +7,7 @@ import xmltodict
|
||||
from rich import print # pylint: disable=redefined-builtin
|
||||
from util import log, Map
|
||||
|
||||
|
||||
def get_nvidia_smi(output='dict'):
|
||||
smi = shutil.which('nvidia-smi')
|
||||
if smi is None:
|
||||
@@ -26,6 +27,8 @@ def get_nvidia_smi(output='dict'):
|
||||
return d
|
||||
elif output == 'json':
|
||||
return json.dumps(d, indent=4)
|
||||
return None
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
res = get_nvidia_smi(output='dict')
|
||||
|
||||
+1
-1
@@ -20,7 +20,7 @@ all_images = []
|
||||
all_images_by_type = {}
|
||||
|
||||
|
||||
class Result(object):
|
||||
class Result():
|
||||
def __init__(self, typ: str, fn: str, tag: str = None, requested: list = []): # noqa: B006
|
||||
self.type = typ
|
||||
self.input = fn
|
||||
|
||||
+4
-4
@@ -62,7 +62,7 @@ async def result(req):
|
||||
return Map({ 'error': req.status, 'reason': req.reason, 'url': req.url })
|
||||
else:
|
||||
json = await req.json()
|
||||
if type(json) == list:
|
||||
if isinstance(json, list):
|
||||
res = json
|
||||
elif json is None:
|
||||
res = {}
|
||||
@@ -79,7 +79,7 @@ def resultsync(req: requests.Response):
|
||||
return Map({ 'error': req.status_code, 'reason': req.reason, 'url': req.url })
|
||||
else:
|
||||
json = req.json()
|
||||
if type(json) == list:
|
||||
if isinstance(json, list):
|
||||
res = json
|
||||
elif json is None:
|
||||
res = {}
|
||||
@@ -169,8 +169,8 @@ def progresssync():
|
||||
|
||||
def get_log():
|
||||
res = getsync('/sdapi/v1/log')
|
||||
for l in res:
|
||||
log.debug(l)
|
||||
for line in res:
|
||||
log.debug(line)
|
||||
return res
|
||||
|
||||
|
||||
|
||||
@@ -86,7 +86,6 @@ if __name__ == '__main__':
|
||||
# print stats
|
||||
print(json.dumps(results, indent = 4))
|
||||
|
||||
|
||||
"""
|
||||
Reference: <https://github.com/pytorch/pytorch/blob/4f4b62e4a255708e928445b6502139d5962974fa/docs/source/dynamo/get-started.rst>
|
||||
Training & Inference backends:
|
||||
|
||||
+4
-4
@@ -71,9 +71,9 @@ def get_memory():
|
||||
|
||||
|
||||
class Map(dict): # pylint: disable=C0205
|
||||
__slots__ = ('__dict__') # pylint: disable=C0325
|
||||
__slots__ = ('__dict__') # pylint: disable=superfluous-parens
|
||||
def __init__(self, *args, **kwargs):
|
||||
super(Map, self).__init__(*args, **kwargs)
|
||||
super(Map, self).__init__(*args, **kwargs) # pylint: disable=super-with-arguments
|
||||
for arg in args:
|
||||
if isinstance(arg, dict):
|
||||
for k, v in arg.items():
|
||||
@@ -100,12 +100,12 @@ class Map(dict): # pylint: disable=C0205
|
||||
def __setattr__(self, key, value):
|
||||
self.__setitem__(key, value)
|
||||
def __setitem__(self, key, value):
|
||||
super(Map, self).__setitem__(key, value)
|
||||
super(Map, self).__setitem__(key, value) # pylint: disable=super-with-arguments
|
||||
self.__dict__.update({key: value})
|
||||
def __delattr__(self, item):
|
||||
self.__delitem__(item)
|
||||
def __delitem__(self, key):
|
||||
super(Map, self).__delitem__(key)
|
||||
super(Map, self).__delitem__(key) # pylint: disable=super-with-arguments
|
||||
del self.__dict__[key]
|
||||
|
||||
|
||||
|
||||
@@ -32,7 +32,7 @@ def extract(src: str, dst: str, rate: float = 0.015, fps: float = 0, start = 0,
|
||||
images = []
|
||||
if not os.path.isfile(src) or not filetype.is_video(src):
|
||||
log.error({ 'extract': 'input is not movie file' })
|
||||
return
|
||||
return 0
|
||||
dst = dst if dst.endswith('/') else dst + '/'
|
||||
|
||||
video = probe(src)
|
||||
|
||||
Reference in New Issue
Block a user