Spaces:
Paused
Paused
Update app_lora1.py
Browse files- app_lora1.py +15 -7
app_lora1.py
CHANGED
|
@@ -100,17 +100,25 @@ def register_pipeline_feature(pipe, text: str):
|
|
| 100 |
# =========================================================
|
| 101 |
def log_pipe_calls(obj, obj_name="pipe"):
|
| 102 |
for attr_name in dir(obj):
|
|
|
|
|
|
|
| 103 |
attr = getattr(obj, attr_name)
|
| 104 |
-
|
| 105 |
-
|
| 106 |
-
|
| 107 |
-
|
| 108 |
-
|
| 109 |
-
|
| 110 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 111 |
return obj
|
| 112 |
|
| 113 |
|
|
|
|
| 114 |
# =========================================================
|
| 115 |
# DOWNLOAD SCRIPTS
|
| 116 |
# =========================================================
|
|
|
|
| 100 |
# =========================================================
|
| 101 |
def log_pipe_calls(obj, obj_name="pipe"):
|
| 102 |
for attr_name in dir(obj):
|
| 103 |
+
if attr_name.startswith("_"):
|
| 104 |
+
continue
|
| 105 |
attr = getattr(obj, attr_name)
|
| 106 |
+
|
| 107 |
+
# Skip non-callables or torch modules
|
| 108 |
+
if not callable(attr) or isinstance(attr, torch.nn.Module):
|
| 109 |
+
continue
|
| 110 |
+
|
| 111 |
+
def make_wrapper(f, name):
|
| 112 |
+
def wrapper(*args, **kwargs):
|
| 113 |
+
log(f"• {obj_name}.{name} called with args={args}, kwargs={kwargs}")
|
| 114 |
+
return f(*args, **kwargs)
|
| 115 |
+
return wrapper
|
| 116 |
+
|
| 117 |
+
setattr(obj, attr_name, make_wrapper(attr, attr_name))
|
| 118 |
return obj
|
| 119 |
|
| 120 |
|
| 121 |
+
|
| 122 |
# =========================================================
|
| 123 |
# DOWNLOAD SCRIPTS
|
| 124 |
# =========================================================
|