mirror of
https://github.com/vladmandic/automatic
synced 2026-09-19 09:14:35 +02:00
enable pylint
This commit is contained in:
@@ -1,2 +1,3 @@
|
||||
# See https://pylint.pycqa.org/en/latest/user_guide/messages/message_control.html
|
||||
[MESSAGES CONTROL]
|
||||
enable=C,R,W,E,I
|
||||
|
||||
+11
-2
@@ -2,18 +2,21 @@
|
||||
"""
|
||||
sd api txt2img benchmark
|
||||
"""
|
||||
import time
|
||||
import json
|
||||
import asyncio
|
||||
import base64
|
||||
import io
|
||||
import json
|
||||
import os
|
||||
import sys
|
||||
import time
|
||||
|
||||
from PIL import Image
|
||||
|
||||
sys.path.append(os.path.join(os.path.dirname(__file__), 'modules'))
|
||||
import modules.sdapi as sdapi
|
||||
from modules.util import Map, log
|
||||
|
||||
|
||||
options = Map({
|
||||
'restore_faces': False,
|
||||
'prompt': 'photo of two dice on a table',
|
||||
@@ -28,10 +31,12 @@ options = Map({
|
||||
'height': 512
|
||||
})
|
||||
|
||||
|
||||
# batch = [1, 1, 2, 4, 8, 12, 16, 24, 32, 48, 64, 96, 128]
|
||||
batch = [1, 1, 2, 4, 8, 12, 16]
|
||||
oom = 0
|
||||
|
||||
|
||||
async def txt2img():
|
||||
t0 = time.perf_counter()
|
||||
data = {}
|
||||
@@ -52,6 +57,7 @@ async def txt2img():
|
||||
t1 = time.perf_counter()
|
||||
return t1 - t0
|
||||
|
||||
|
||||
def memstats():
|
||||
mem = sdapi.getsync('/sdapi/v1/memory')
|
||||
cpu = mem.get('ram', 'unavailable')
|
||||
@@ -68,9 +74,11 @@ def memstats():
|
||||
gpu.pop('events')
|
||||
return cpu, gpu
|
||||
|
||||
|
||||
def gb(val: float):
|
||||
return round(val / 1024 / 1024 / 1024, 2)
|
||||
|
||||
|
||||
async def main():
|
||||
log.info({ 'benchmark': { 'batch-sizes': batch } })
|
||||
sdapi.quiet = True
|
||||
@@ -111,6 +119,7 @@ async def main():
|
||||
log.info({ 'benchmark': 'ended with oom so you should probably restart your automatic server now' })
|
||||
await sdapi.close()
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
try:
|
||||
asyncio.run(main())
|
||||
|
||||
@@ -8,6 +8,7 @@ import subprocess
|
||||
import pathlib
|
||||
import argparse
|
||||
import filetype
|
||||
|
||||
from util import log, Map
|
||||
|
||||
|
||||
|
||||
@@ -13,6 +13,7 @@ import filetype
|
||||
from PIL import Image, ImageDraw, ImageFont
|
||||
from util import log
|
||||
|
||||
|
||||
params = None
|
||||
|
||||
|
||||
|
||||
@@ -6,12 +6,16 @@ model from: <https://huggingface.co/FredZhang7/distilgpt2-stable-diffusion-v2>
|
||||
|
||||
import logging
|
||||
import argparse
|
||||
|
||||
from transformers import GPT2Tokenizer, GPT2LMHeadModel
|
||||
|
||||
from util import log
|
||||
|
||||
|
||||
tokenizer = None
|
||||
model = None
|
||||
|
||||
|
||||
def prompt(text: str, temp: float = 0.9, top: int = 8, penalty: float = 1.2, alpha: float = 0.6, num: int = 5, length: int = 80):
|
||||
global tokenizer, model # pylint: disable=global-statement
|
||||
if tokenizer is None:
|
||||
|
||||
@@ -8,8 +8,10 @@ import base64
|
||||
import sys
|
||||
import os
|
||||
import asyncio
|
||||
|
||||
import filetype
|
||||
from PIL import Image
|
||||
|
||||
from util import log, Map
|
||||
import sdapi as sdapi
|
||||
|
||||
|
||||
@@ -6,12 +6,15 @@ import sys
|
||||
import json
|
||||
import pathlib
|
||||
import logging
|
||||
|
||||
import torch
|
||||
import numpy as np
|
||||
from PIL import Image, ImageFont, ImageDraw
|
||||
from matplotlib import pyplot as plt
|
||||
|
||||
from util import log, Map
|
||||
|
||||
|
||||
def settings(logdir: str, name: str):
|
||||
filename = os.path.join(logdir, name, 'settings.json')
|
||||
with open(filename, 'r', encoding='utf-8') as f:
|
||||
|
||||
@@ -5,14 +5,17 @@ auto-generate learn-rate
|
||||
import io
|
||||
import math
|
||||
import logging
|
||||
|
||||
import numpy as np
|
||||
from PIL import Image, ImageFont, ImageDraw
|
||||
from matplotlib import pyplot as plt
|
||||
|
||||
from util import log, Map
|
||||
|
||||
|
||||
loss_types = ['linear', 'log', 'linalg', 'power']
|
||||
|
||||
|
||||
def gen_steps(steps, step):
|
||||
return [x for x in range(1, steps + step) if x % step == 0]
|
||||
|
||||
|
||||
@@ -8,9 +8,11 @@ import io
|
||||
import shutil
|
||||
import base64
|
||||
import pathlib
|
||||
|
||||
import numpy as np
|
||||
import mediapipe as mp
|
||||
from PIL import Image, ImageOps
|
||||
|
||||
from util import log, Map
|
||||
from sdapi import postsync
|
||||
|
||||
|
||||
@@ -5,9 +5,12 @@ use microsoft promptist to beautify prompt
|
||||
"""
|
||||
|
||||
import sys
|
||||
|
||||
from transformers import AutoModelForCausalLM, AutoTokenizer
|
||||
|
||||
from util import log
|
||||
|
||||
|
||||
def load_prompter():
|
||||
model = AutoModelForCausalLM.from_pretrained("microsoft/Promptist") # pylint: disable=redefined-outer-name
|
||||
tokenizer = AutoTokenizer.from_pretrained("gpt2") # pylint: disable=redefined-outer-name
|
||||
|
||||
@@ -4,21 +4,22 @@ helper methods that creates HTTP session with managed connection pool
|
||||
provides async HTTP get/post methods and several helper methods
|
||||
"""
|
||||
|
||||
import aiohttp
|
||||
import asyncio
|
||||
import logging
|
||||
import requests
|
||||
import sys
|
||||
|
||||
import aiohttp
|
||||
import requests
|
||||
from util import Map, log
|
||||
|
||||
|
||||
sd_url = "http://127.0.0.1:7860" # automatic1111 api url root
|
||||
use_session = True
|
||||
timeout = aiohttp.ClientTimeout(total = None, sock_connect = 10, sock_read = None) # default value is 5 minutes, we need longer for training
|
||||
|
||||
sess = None
|
||||
quiet = False
|
||||
|
||||
|
||||
async def result(req):
|
||||
if req.status != 200:
|
||||
if not quiet:
|
||||
|
||||
@@ -5,9 +5,11 @@ generic helper methods
|
||||
|
||||
import logging
|
||||
|
||||
|
||||
logging.basicConfig(level = logging.INFO, format = '%(asctime)s %(levelname)s: %(message)s')
|
||||
log = logging.getLogger("sd")
|
||||
|
||||
|
||||
class Map(dict):
|
||||
def __init__(self, *args, **kwargs):
|
||||
super(Map, self).__init__(*args, **kwargs)
|
||||
@@ -45,5 +47,6 @@ class Map(dict):
|
||||
super(Map, self).__delitem__(key)
|
||||
del self.__dict__[key]
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
pass
|
||||
|
||||
@@ -12,6 +12,7 @@ Only difference are some calculations in `ldm/models/diffusion/ddpm.py` and by t
|
||||
|
||||
import os
|
||||
import sys
|
||||
|
||||
import torch
|
||||
|
||||
def signature(model):
|
||||
|
||||
+4
-4
@@ -16,10 +16,10 @@ import logging
|
||||
import math
|
||||
import os
|
||||
import sys
|
||||
import pathlib
|
||||
import time
|
||||
import json
|
||||
from pathlib import Path
|
||||
from pathlib import Path, PurePath
|
||||
|
||||
import filetype
|
||||
from PIL import Image
|
||||
|
||||
@@ -383,7 +383,7 @@ async def main():
|
||||
log.setLevel(logging.DEBUG)
|
||||
log.debug({ 'debug': True })
|
||||
log.debug({ 'args': params.__dict__ })
|
||||
home = pathlib.Path(sys.argv[0]).parent
|
||||
home = Path(sys.argv[0]).parent
|
||||
global args # pylint: disable=global-statement
|
||||
if os.path.isfile(params.config):
|
||||
try:
|
||||
@@ -453,7 +453,7 @@ async def main():
|
||||
else:
|
||||
args.train_embedding.template_filename = 'unknown_filewords.txt'
|
||||
if params.name == 'auto':
|
||||
params.name = pathlib.PurePath(params.src).name
|
||||
params.name = PurePath(params.src).name
|
||||
log.info({ 'training name': params.name })
|
||||
if params.dst == "/tmp":
|
||||
params.dst = os.path.join("/tmp/train", params.name)
|
||||
|
||||
+2
-1
@@ -161,5 +161,6 @@
|
||||
"inspiration_rows_num": 4,
|
||||
"inspiration_cols_num": 6,
|
||||
"live_preview_refresh_period": 1000,
|
||||
"show_progressbar": true
|
||||
"show_progressbar": true,
|
||||
"show_warnings": false
|
||||
}
|
||||
Reference in New Issue
Block a user