rydlrKE commited on
Commit
540ad5a
·
1 Parent(s): 389a1da

Fix generate notification: reuse persistent notification and properly transition to error state

Browse files
kimodo/demo/ui.py CHANGED
@@ -3155,15 +3155,18 @@ def create_gui(
3155
  gui_save_example_button.disabled = False
3156
  gui_save_motion_button.disabled = False
3157
  gui_download_button.disabled = False
3158
- try:
3159
- event_client.add_notification(
3160
- title="Generation failed!",
3161
- body=f"Error: {str(e)}",
3162
- auto_close_seconds=5.0,
3163
- color="red",
3164
- )
3165
- except Exception:
3166
- pass
 
 
 
3167
  demo.check_cuda_health()
3168
 
3169
  #
 
3155
  gui_save_example_button.disabled = False
3156
  gui_save_motion_button.disabled = False
3157
  gui_download_button.disabled = False
3158
+
3159
+ # Reuse the same persistent notification so it does not get stuck loading.
3160
+ try:
3161
+ generating_notif.title = "Generation failed!"
3162
+ generating_notif.body = f"Error: {str(e)}"
3163
+ generating_notif.loading = False
3164
+ generating_notif.with_close_button = True
3165
+ generating_notif.auto_close_seconds = 6.0
3166
+ generating_notif.color = "red"
3167
+ except Exception:
3168
+ pass
3169
+
3170
  demo.check_cuda_health()
3171
 
3172
  #
kimodo/model/text_encoder_api.py CHANGED
@@ -43,6 +43,25 @@ class TextEncoderAPI:
43
  self.dtype = dtype
44
  return self
45
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
46
  def __call__(self, texts):
47
  """Encode text prompts into tensors.
48
 
@@ -66,7 +85,7 @@ class TextEncoderAPI:
66
  filename=filename,
67
  api_name="/DemoWrapper",
68
  ).result(timeout=300)
69
- path = result[0]["value"]
70
  tensor = np.load(path)
71
  length = tensor.shape[0]
72
 
 
43
  self.dtype = dtype
44
  return self
45
 
46
+ def _extract_result_path(self, result):
47
+ """Extract npy path from heterogeneous gradio_client responses."""
48
+ candidates = []
49
+ if isinstance(result, (list, tuple)):
50
+ candidates = list(result)
51
+ elif result is not None:
52
+ candidates = [result]
53
+
54
+ for item in candidates:
55
+ if isinstance(item, str) and item:
56
+ return item
57
+ if isinstance(item, dict):
58
+ for key in ("value", "path", "name"):
59
+ value = item.get(key)
60
+ if isinstance(value, str) and value:
61
+ return value
62
+
63
+ raise RuntimeError(f"Text encoder API returned unexpected payload: {type(result).__name__}")
64
+
65
  def __call__(self, texts):
66
  """Encode text prompts into tensors.
67
 
 
85
  filename=filename,
86
  api_name="/DemoWrapper",
87
  ).result(timeout=300)
88
+ path = self._extract_result_path(result)
89
  tensor = np.load(path)
90
  length = tensor.shape[0]
91