Skip to content

Commit 1cc9b93

Browse files
jacquesfeng123zhchaoxing
authored andcommitted
easier debug
- change config.json - cleanup api.py log
1 parent b34e11e commit 1cc9b93

File tree

2 files changed

+53
-3
lines changed

2 files changed

+53
-3
lines changed

config.json

+10-1
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,14 @@
1212
"control_net_skip_img2img_processing": false,
1313
"control_net_only_mid_control": false,
1414
"control_net_sync_field_args": false,
15-
"CLIP_stop_at_last_layers": 2
15+
"CLIP_stop_at_last_layers": 2,
16+
"show_progressbar": false,
17+
"live_previews_enable": false,
18+
"show_progress_grid": false,
19+
"show_progress_in_title": false,
20+
"do_not_show_images": true,
21+
"return_grid": false,
22+
"show_progress_every_n_steps": 30,
23+
"show_progress_type": "Approx cheap",
24+
"upcast_attn": false
1625
}

modules/api/api.py

+43-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import base64
22
import io
33
import time
4+
import copy
45
import datetime
56
import uvicorn
67
import gradio as gr
@@ -739,10 +740,50 @@ def post_invocations(self, b64images, quality):
739740
return images
740741
else:
741742
return b64images
743+
744+
def print_content(self, req: InvocationsRequest):
745+
try:
746+
new_req = copy.deepcopy(req)
747+
if req.img2img_payload != None:
748+
new_req.img2img_payload.init_images=['a total of ' + str(len(new_req.img2img_payload.init_images)) + ' images were sent as base 64']
749+
print(new_req)
750+
except Exception as e:
751+
print("printing method did not work, bypassing...error:", e)
752+
753+
def truncate_content(self, value, limit=200):
754+
if isinstance(value, str): # Only truncate if the value is a string
755+
if len(value) > limit:
756+
return value[:limit] + '...'
757+
return value
758+
759+
def req_logging(self, obj, indent=0):
760+
if "__dict__" in dir(obj): # if value is an object, dive into it
761+
items = obj.__dict__.items()
762+
elif isinstance(obj, dict): # if value is a dictionary, get items
763+
items = obj.items()
764+
elif isinstance(obj, list): # if value is a list, enumerate items
765+
items = enumerate(obj)
766+
else: # if value is not an object or dict or list, just print it
767+
print(" " * indent + f"{self.truncate_content(obj)}")
768+
return
769+
770+
for attr, value in items:
771+
if value is None or value == {} or value == []:
772+
continue
773+
if isinstance(value, (list, dict)) or "__dict__" in dir(value):
774+
print(" " * indent + f"{attr}:")
775+
self.req_logging(value, indent + 1)
776+
else:
777+
print(" " * indent + f"{attr}: {self.truncate_content(value)}")
778+
742779

743780
def invocations(self, req: InvocationsRequest):
744-
print('-------invocation------')
745-
print(req)
781+
print('----------------------------invocation---------------------------')
782+
# self.print_nested_dictionary(req, 50) # this is where debug happens
783+
try:
784+
self.req_logging(req)
785+
except Exception as e:
786+
print("console Log ran into issue: ",e)
746787

747788
try:
748789
if req.vae != None:

0 commit comments

Comments
 (0)