orhir commited on
Commit
6036218
·
verified ·
1 Parent(s): ee7caad

Update gradio_utils/utils.py

Browse files
Files changed (1) hide show
  1. gradio_utils/utils.py +29 -1
gradio_utils/utils.py CHANGED
@@ -15,7 +15,8 @@ from mmpose.core import wrap_fp16_model
15
  from mmpose.models import build_posenet
16
  from torchvision import transforms
17
  import matplotlib.patheffects as mpe
18
-
 
19
  from EdgeCape import TopDownGenerateTargetFewShot
20
  from demo import Resize_Pad
21
  from EdgeCape.models import *
@@ -209,6 +210,7 @@ def process(query_img, state,
209
  original_skeleton=state['skeleton'],
210
  img_alpha=1.0,
211
  )
 
212
  return out
213
 
214
 
@@ -394,3 +396,29 @@ def draw_points_on_image(image,
394
  )
395
 
396
  return Image.alpha_composite(image.convert("RGBA"), overlay_rgba).convert("RGB")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
15
  from mmpose.models import build_posenet
16
  from torchvision import transforms
17
  import matplotlib.patheffects as mpe
18
+ import pickle
19
+ from pprint import pformat as pf
20
  from EdgeCape import TopDownGenerateTargetFewShot
21
  from demo import Resize_Pad
22
  from EdgeCape.models import *
 
210
  original_skeleton=state['skeleton'],
211
  img_alpha=1.0,
212
  )
213
+ print(pf(pickle_trick(model)))
214
  return out
215
 
216
 
 
396
  )
397
 
398
  return Image.alpha_composite(image.convert("RGBA"), overlay_rgba).convert("RGB")
399
+
400
+ def pickle_trick(obj, max_depth=10):
401
+ output = {}
402
+
403
+ if max_depth <= 0:
404
+ return output
405
+
406
+ try:
407
+ pickle.dumps(obj)
408
+ except (pickle.PicklingError, TypeError) as e:
409
+ failing_children = []
410
+
411
+ if hasattr(obj, "__dict__"):
412
+ for k, v in obj.__dict__.items():
413
+ result = pickle_trick(v, max_depth=max_depth - 1)
414
+ if result:
415
+ failing_children.append(result)
416
+
417
+ output = {
418
+ "fail": obj,
419
+ "err": e,
420
+ "depth": max_depth,
421
+ "failing_children": failing_children
422
+ }
423
+
424
+ return output