dvruette commited on
Commit
385e90f
1 Parent(s): 351630d

add logging

Browse files
Files changed (1) hide show
  1. app.py +8 -1
app.py CHANGED
@@ -1,11 +1,14 @@
1
  import functools
2
  import random
 
3
 
4
  import gradio as gr
5
  import torch
6
 
7
  from fabric.generator import AttentionBasedGenerator
8
 
 
 
9
 
10
  #model_name = "dreamlike-art/dreamlike-photoreal-2.0"
11
  model_name = ""
@@ -97,7 +100,9 @@ def generate_fn(
97
  try:
98
  if seed < 0:
99
  seed = random.randint(1,9999999999999999) #16 digits is an arbitrary limit
100
- print("seed: ", seed)
 
 
101
 
102
  max_feedback_imgs = max(0, int(max_feedback_imgs))
103
  total_images = (len(liked) if liked else 0) + (len(disliked) if disliked else 0)
@@ -142,9 +147,11 @@ def generate_fn(
142
  except RuntimeError as err:
143
  if 'out of memory' in str(err):
144
  generator.reload()
 
145
  raise
146
  return [(img, f"Image {i+1}") for i, img in enumerate(images)], images, seed
147
  except Exception as err:
 
148
  raise gr.Error(str(err))
149
 
150
 
 
1
  import functools
2
  import random
3
+ import logging
4
 
5
  import gradio as gr
6
  import torch
7
 
8
  from fabric.generator import AttentionBasedGenerator
9
 
10
+ logger = logging.getLogger(__name__)
11
+
12
 
13
  #model_name = "dreamlike-art/dreamlike-photoreal-2.0"
14
  model_name = ""
 
100
  try:
101
  if seed < 0:
102
  seed = random.randint(1,9999999999999999) #16 digits is an arbitrary limit
103
+
104
+ logger.info(f"Generate images: {prompt=}, {neg_prompt=}, {len(liked)=}, {len(disliked)=}, {max_feedback_imgs=}, {batch_size=}, {seed=}")
105
+ logger.ingo(f"Params: {denoising_steps=}, {guidance_scale=}, {feedback_start=}, {feedback_end=}, {min_weight=}, {max_weight=}, {neg_scale=}")
106
 
107
  max_feedback_imgs = max(0, int(max_feedback_imgs))
108
  total_images = (len(liked) if liked else 0) + (len(disliked) if disliked else 0)
 
147
  except RuntimeError as err:
148
  if 'out of memory' in str(err):
149
  generator.reload()
150
+ logger.info(f"Ran out of memory trying to generate {batch_size=} images with {len(liked)=} and {len(disliked)=} feedback images.")
151
  raise
152
  return [(img, f"Image {i+1}") for i, img in enumerate(images)], images, seed
153
  except Exception as err:
154
+ logger.error(err)
155
  raise gr.Error(str(err))
156
 
157