radames commited on
Commit
f9856f3
1 Parent(s): 0fdb6cd
stablediffusion-infinity/app.py CHANGED
@@ -25,6 +25,7 @@ import sqlite3
25
  import requests
26
  import shortuuid
27
  import re
 
28
 
29
  AWS_ACCESS_KEY_ID = os.getenv('AWS_ACCESS_KEY_ID')
30
  AWS_SECRET_KEY = os.getenv('AWS_SECRET_KEY')
@@ -53,7 +54,6 @@ if not DB_PATH.exists():
53
  def get_db():
54
  db = sqlite3.connect(DB_PATH, check_same_thread=False)
55
  db.row_factory = sqlite3.Row
56
- print("Connected to database")
57
  try:
58
  yield db
59
  except Exception:
@@ -182,7 +182,7 @@ async def run_outpaint(
182
  image_url = {}
183
 
184
  if not is_nsfw:
185
- print("not nsfw, uploading")
186
  image_url = await upload_file(image, prompt_text, room_id, image_key)
187
 
188
  params = {
@@ -274,7 +274,7 @@ def get_room_count(room_id: str, jwtToken: str = ''):
274
 
275
 
276
  @ app.on_event("startup")
277
- @ repeat_every(seconds=60)
278
  async def sync_rooms():
279
  print("Syncing rooms")
280
  try:
@@ -338,15 +338,15 @@ async def upload_file(image: Image.Image, prompt: str, room_id: str, image_key:
338
  image.save(temp_file, format="JPEG")
339
  temp_file.seek(0)
340
  id = shortuuid.uuid()
 
341
  prompt_slug = slugify(prompt)
342
- filename = f"{id}-{image_key}-{prompt_slug}.jpg"
343
  s3.upload_fileobj(Fileobj=temp_file, Bucket=AWS_S3_BUCKET_NAME, Key=f"{room_id}/" +
344
  filename, ExtraArgs={"ContentType": "image/jpeg", "CacheControl": "max-age=31536000"})
345
  temp_file.close()
346
 
347
  out = {"url": f'https://d26smi9133w0oo.cloudfront.net/{room_id}/{filename}',
348
  "filename": filename}
349
- print(out)
350
  return out
351
 
352
 
 
25
  import requests
26
  import shortuuid
27
  import re
28
+ import time
29
 
30
  AWS_ACCESS_KEY_ID = os.getenv('AWS_ACCESS_KEY_ID')
31
  AWS_SECRET_KEY = os.getenv('AWS_SECRET_KEY')
 
54
  def get_db():
55
  db = sqlite3.connect(DB_PATH, check_same_thread=False)
56
  db.row_factory = sqlite3.Row
 
57
  try:
58
  yield db
59
  except Exception:
 
182
  image_url = {}
183
 
184
  if not is_nsfw:
185
+ # print("not nsfw, uploading")
186
  image_url = await upload_file(image, prompt_text, room_id, image_key)
187
 
188
  params = {
 
274
 
275
 
276
  @ app.on_event("startup")
277
+ @ repeat_every(seconds=120)
278
  async def sync_rooms():
279
  print("Syncing rooms")
280
  try:
 
338
  image.save(temp_file, format="JPEG")
339
  temp_file.seek(0)
340
  id = shortuuid.uuid()
341
+ date = int(time.time())
342
  prompt_slug = slugify(prompt)
343
+ filename = f"{date}-{id}-{image_key}-{prompt_slug}.jpg"
344
  s3.upload_fileobj(Fileobj=temp_file, Bucket=AWS_S3_BUCKET_NAME, Key=f"{room_id}/" +
345
  filename, ExtraArgs={"ContentType": "image/jpeg", "CacheControl": "max-age=31536000"})
346
  temp_file.close()
347
 
348
  out = {"url": f'https://d26smi9133w0oo.cloudfront.net/{room_id}/{filename}',
349
  "filename": filename}
 
350
  return out
351
 
352
 
stablediffusion-infinity/mask.png CHANGED