Spaces:
Runtime error
Runtime error
File size: 1,155 Bytes
ed4da02 3b3dc37 ed4da02 3b3dc37 ed4da02 3b3dc37 ed4da02 3b3dc37 ed4da02 3b3dc37 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 52 53 54 55 56 57 58 59 |
"""Set up gradio api for cmataset."""
# pylint: disable=invalid-name
from typing import List, Tuple, Union
import gradio as gr
import logzero
import numpy as np
from cmat2aset import cmat2aset as c2a
from logzero import logger
logzero.level(10)
logdebug("gradio version: %s", gr.__version__)
# 3.0.19
def cmat2aset(
cmat: Union[np.ndarray, List[List[float]]],
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."""
logger.debug("cma[:3, :3]", np.array(cmat)[:3, :3])
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,
)
|