gradio-cmat / app.py
freemt
Update first try
f2dd44e
raw
history blame
1.08 kB
"""Bootstrap."""
# pylint: disable=invalid-name
import numpy as np
import gradio as gr
from model_pool import load_model_s
from logzero import logger
from gradio_cmat import gradio_cmat
model_s = load_model_s()
def fn(text1: str, text2: str) -> np.ndarray:
"""Define."""
list1 = [elm.strip() for elm in text1.splitlines() if elm.strip()]
list2 = [elm.strip() for elm in text2.splitlines() if elm.strip()]
try:
res = gradio_cmat(list1, list2)
except Exception as e:
logger.error("gradio_cmat error: %s", e)
raise
return res
# _ = """
try:
interface = gr.Interface.load(
fn,
[
gr.inputs.Textbox(
lines=3, default="The quick brown fox jumped over the lazy dogs."
),
gr.inputs.Textbox(lines=3, default="The fast brown fox jumps over lazy dogs."),
],
"numpy",
description="Gen corralation matrix",
)
except Exception as e:
logger.exception("")
logger.error("gr.Interface.load(%s): %s", "fn", e)
raise
interface.launch()