1.0.1 Fixed Minor Bug
Co-authored-by: tmddn3070 <tmddn3070@gmail.com>
This commit is contained in:
parent
63682127cd
commit
76fef5e6ca
@ -11,10 +11,8 @@ from fastapi.security import APIKeyHeader, APIKeyQuery
|
||||
dotenv.load_dotenv(dotenv.find_dotenv())
|
||||
api_key_header = APIKeyHeader(name="x-api-key", auto_error=False)
|
||||
|
||||
API_KEYS = os.getenv("API_KEYS") # list
|
||||
print(API_KEYS)
|
||||
API_KEY_LIST = map(str, API_KEYS.split("|"))
|
||||
print(API_KEY_LIST)
|
||||
API_KEYS = os.getenv("API_KEYS")
|
||||
API_KEYS = list(map(str, API_KEYS.split(",")))
|
||||
def get_api_key(
|
||||
api_key_header: str = Security(api_key_header)):
|
||||
if api_key_header in API_KEYS:
|
||||
|
@ -58,7 +58,7 @@ class SD15_Generation:
|
||||
"height": res[1],
|
||||
"cfg_scale": round(cfg_scale, 1),
|
||||
"steps": steps,
|
||||
"sampler_index": "DPM++ 2M Karras",
|
||||
"sampler_index": "DPM++ 2M",
|
||||
"refiner_checkpoint": "smooREFINERV2R10_half",
|
||||
"refiner_switch_at": 0.45,
|
||||
"alwayson_scripts": {
|
||||
@ -85,11 +85,11 @@ class SD15_Generation:
|
||||
if not nsfw:
|
||||
positive = profanity.censor(positive, " ")
|
||||
payload = await self._before_process(positive, negative, res, is_afterprocess, style, seed, steps, cfg_scale)
|
||||
url = random.choice(map(str, self.url.split("|")))
|
||||
url = random.choice(list(map(str, self.url.split(","))))
|
||||
response = await self.aiohttp_session.post(url + "/sdapi/v1/txt2img", json=payload, timeout=300)
|
||||
if response.status != 200:
|
||||
sentry_sdk.capture_message(f"Image generation API ERROR returned {response.status} text: {await response.text()}")
|
||||
Logging.error(f"Image generation API ERROR returned {response.status} text: {await response.text()}")
|
||||
Logging().error(f"Image generation API ERROR returned {response.status} text: {await response.text()}")
|
||||
#return {"status": -1, "message": await response.text(), "image": None, "rating": None, "tags": None, "nsfw": None}
|
||||
return ImageGenerate_OUTPUT(status=-1, message=await response.text(), image=None, rating=None, tags=None, nsfw=None)
|
||||
else:
|
||||
|
@ -19,7 +19,6 @@ translator = Translator()
|
||||
class SDXL_Generation:
|
||||
def __init__(self):
|
||||
self.url = os.getenv("SDXL_SERVERS")
|
||||
print(self.url)
|
||||
self.aiohttp_session = aiohttp.ClientSession()
|
||||
|
||||
@staticmethod
|
||||
@ -97,10 +96,7 @@ class SDXL_Generation:
|
||||
if not nsfw:
|
||||
positive = profanity.censor(positive, " ")
|
||||
payload = await self._before_process(positive, negative, sampler, res, is_afterprocess, style, seed, steps, cfg_scale)
|
||||
if self.url.find("|"):
|
||||
url = self.url.replace(",", "")
|
||||
else:
|
||||
url = random.choice(self.url.split("|")).replace(",", "")
|
||||
url = random.choice(list(map(str, self.url.split(","))))
|
||||
response = await self.aiohttp_session.post(url + "/sdapi/v1/txt2img", json=payload, timeout=300)
|
||||
if response.status != 200:
|
||||
sentry_sdk.capture_message(f"Image generation API ERROR returned {response.status} text: {await response.text()}")
|
||||
|
@ -17,7 +17,7 @@ app = FastAPI(
|
||||
#app = SentryMiddleware(app)
|
||||
#app = LoggingMiddleware(app)
|
||||
|
||||
|
||||
#
|
||||
@app.get("/")
|
||||
async def root():
|
||||
return {"message": "Hello World"}
|
||||
|
Loading…
Reference in New Issue
Block a user