freemt commited on
Commit
090f331
·
1 Parent(s): 7e6c0d6
Files changed (1) hide show
  1. app.py +11 -5
app.py CHANGED
@@ -23,20 +23,26 @@ def cmat2aset(
23
  np.ndarray, List[Tuple[Union[int, str], Union[int, str], Union[float, str]]]
24
  ]:
25
  """Set up gradio api for cmataset."""
 
 
 
 
 
 
26
  try:
27
  # cmat[cmat==""] = 0
28
- cmat = np.where(cmat == "", cmat) # type: ignore
29
  cmat = np.array(cmat, dtype=float)
30
  except Exception as exc:
31
  logger.exception(exc)
32
- return np.array([[str(exc)]])
33
 
34
  logger.debug("cmat[:3, :3]: %s", cmat[:3, :3])
35
  try:
36
- return c2a(cmat, eps, min_samples)
37
  except Exception as exc:
38
  logger.exception(exc)
39
- raise
40
 
41
 
42
  inputs = [
@@ -57,7 +63,7 @@ inputs = [
57
  iface = gr.Interface(
58
  fn=cmat2aset,
59
  inputs=inputs,
60
- outputs="dataframe",
61
  allow_flagging="never",
62
  title="radio-cmat2aset",
63
  )
 
23
  np.ndarray, List[Tuple[Union[int, str], Union[int, str], Union[float, str]]]
24
  ]:
25
  """Set up gradio api for cmataset."""
26
+ try:
27
+ cmat = np.array(cmat, dtype=str)
28
+ except Exception as exc:
29
+ logger.exception(exc)
30
+ return None, str(exc)
31
+
32
  try:
33
  # cmat[cmat==""] = 0
34
+ cmat = np.where(cmat == "", 0, cmat) # type: ignore
35
  cmat = np.array(cmat, dtype=float)
36
  except Exception as exc:
37
  logger.exception(exc)
38
+ return None, str(exc)
39
 
40
  logger.debug("cmat[:3, :3]: %s", cmat[:3, :3])
41
  try:
42
+ return c2a(cmat, eps, min_samples), ""
43
  except Exception as exc:
44
  logger.exception(exc)
45
+ return None, str(exc)
46
 
47
 
48
  inputs = [
 
63
  iface = gr.Interface(
64
  fn=cmat2aset,
65
  inputs=inputs,
66
+ outputs=["dataframe", "text"],
67
  allow_flagging="never",
68
  title="radio-cmat2aset",
69
  )