File size: 1,000 Bytes
ed4da02
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
ddc967b
ed4da02
 
 
 
 
ddc967b
ed4da02
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
"""Set up gradio api for cmataset."""
# pylint: disable=invalid-name
from typing import List, Tuple, Union

import gradio as gr
import numpy as np
from cmat2aset import cmat2aset as c2a
from logzero import logger


def cmat2aset(
    cmat: Union[np.ndarray, List[List]],
    eps: float = 10,
    min_samples: int = 6,
) -> Union[
    np.ndarray, List[Tuple[Union[int, str], Union[int, str], Union[float, str]]]
]:
    """Set up gradio api for cmataset."""
    try:
        return c2a(cmat, eps, min_samples)
    except Exception as exc:
        logger.exception(exc)
        raise


inputs = [
    "numpy",
    gr.inputs.Slider(
        minimum=1,
        maximum=20,
        step=0.1,
        default=10,
    ),
    gr.inputs.Slider(
        minimum=1,
        maximum=20,
        step=1,
        default=6,
    ),
]
iface = gr.Interface(
    fn=cmat2aset,
    inputs=inputs,
    outputs="dataframe",
    allow_flagging="never",
    title="radio-cmat2aset",
)
iface.launch(
    enable_queue=True,
)