Skip to content

Instantly share code, notes, and snippets.

@badbye
Created July 14, 2019 09:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save badbye/ae7ab5db8984a4e81fcd3001c455cc1f to your computer and use it in GitHub Desktop.
Save badbye/ae7ab5db8984a4e81fcd3001c455cc1f to your computer and use it in GitHub Desktop.
Example of customized model
# encoding: utf8
import gradio
import re
import numpy as np
# A very simplistic function that capitalizes each letter in the given string
def big(x):
if re.match('^[a-zA-Z]+$', x):
return np.array([0.8, 0.2])
return np.array([0.2, 0.8])
output = gradio.outputs.Label(label_names=('英文字符', 'Non-English'), num_top_classes=2)
io = gradio.Interface(inputs="textbox", outputs=output, model=big, model_type='pyfunc')
io.launch()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment