Araeynn commited on
Commit
807378e
1 Parent(s): 5c879f1

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +17 -6
app.py CHANGED
@@ -10,6 +10,7 @@ import time
10
  import discord.utils
11
  from discord.ext import tasks
12
  from PIL import Image
 
13
  import streamlit as st
14
  from huggingface_hub import AsyncInferenceClient, login
15
  import time
@@ -427,7 +428,10 @@ async def on_message(message):
427
  context = f.read()
428
  with open(f"{guild_name}.guild", "r") as f:
429
  o = f.read()
430
- if str(message.channel.id) in o.split("\n") or guild_name == "Direct":
 
 
 
431
  async with msgchannel.typing():
432
  context += f"GPT4 Correct Assistant:"
433
  load = random.choice(
@@ -462,11 +466,18 @@ async def on_message(message):
462
  if imgp != "":
463
  np = """lowres, text, error, cropped, worst quality, low quality, jpeg artifacts, ugly, duplicate, morbid, mutilated, out of frame, extra fingers, mutated hands, poorly drawn hands, poorly drawn face, mutation, deformed, blurry, dehydrated, bad anatomy, bad proportions, extra limbs, cloned face, disfigured, gross proportions, malformed limbs, missing arms, missing legs, extra arms, extra legs, fused fingers, too many fingers, long neck, username, watermark, signature"""
464
  st = time.time()
465
- # image, m = (await SD.text_to_image(imgp, negative_prompt=np), "Stable Diffusion 2-1")
466
- # image, m = (await SDXL.text_to_image(imgp, negative_prompt=np, num_inference_steps=8), "stable-diffusion-xl-base-1.0")
467
- image, m = (await SDXLT.text_to_image(imgp, negative_prompt=np, num_inference_steps=1, guidance_scale=0.0), "sdxl-turbo")
468
- # image, m = (await SDT.text_to_image(imgp, negative_prompt=np, num_inference_steps=1, guidance_scale=0.0), "sd-turbo")
469
- # image, m = (await PT.text_to_image(imgp, negative_prompt=np), "Proteus v0.2")
 
 
 
 
 
 
 
470
  image.save("image.png")
471
  file = discord.File("image.png", filename="image.png", description=imgp)
472
  embed.set_image(url="attachment://image.png")
 
10
  import discord.utils
11
  from discord.ext import tasks
12
  from PIL import Image
13
+ import requests
14
  import streamlit as st
15
  from huggingface_hub import AsyncInferenceClient, login
16
  import time
 
428
  context = f.read()
429
  with open(f"{guild_name}.guild", "r") as f:
430
  o = f.read()
431
+ info = requests.get("https://raw.githubusercontent.com/aryananumula/lr/main/info.json")
432
+ bannedUsers = json.loads(info)["bannedUsers"]
433
+ imageModel = json.loads(info)["imageModel"]
434
+ if str(message.channel.id) in o.split("\n") or guild_name == "Direct" or message.author.id not in bannedUsers:
435
  async with msgchannel.typing():
436
  context += f"GPT4 Correct Assistant:"
437
  load = random.choice(
 
466
  if imgp != "":
467
  np = """lowres, text, error, cropped, worst quality, low quality, jpeg artifacts, ugly, duplicate, morbid, mutilated, out of frame, extra fingers, mutated hands, poorly drawn hands, poorly drawn face, mutation, deformed, blurry, dehydrated, bad anatomy, bad proportions, extra limbs, cloned face, disfigured, gross proportions, malformed limbs, missing arms, missing legs, extra arms, extra legs, fused fingers, too many fingers, long neck, username, watermark, signature"""
468
  st = time.time()
469
+ if imageModel == "Stable Diffusion 2-1":
470
+ image, m = (await SD.text_to_image(imgp, negative_prompt=np), "Stable Diffusion 2-1")
471
+ elif imageModel == "stable-diffusion-xl-base-1.0":
472
+ image, m = (await SDXL.text_to_image(imgp, negative_prompt=np, num_inference_steps=8), "stable-diffusion-xl-base-1.0")
473
+ elif imageModel == "sdxl-turbo":
474
+ image, m = (await SDXLT.text_to_image(imgp, negative_prompt=np, num_inference_steps=1, guidance_scale=0.0), "sdxl-turbo")
475
+ elif imageModel == "sd-turbo":
476
+ image, m = (await SDT.text_to_image(imgp, negative_prompt=np, num_inference_steps=1, guidance_scale=0.0), "sd-turbo")
477
+ elif imageModel == "Proteus v0.2":
478
+ image, m = (await PT.text_to_image(imgp, negative_prompt=np), "Proteus v0.2")
479
+ else:
480
+ raise NotImplementedError(f"Model {imageModel} not found. Report this to @araeyn if this keeps happening.")
481
  image.save("image.png")
482
  file = discord.File("image.png", filename="image.png", description=imgp)
483
  embed.set_image(url="attachment://image.png")