import gradio as gr from threading import Thread import time import anvil.server from registration import register,get_register,func_reg from library import get_file,get_files anvil.server.connect('55MH4EBKM22EP4E6D5T6CVSL-VGO5X4SM6JEXGJVT') register(get_file) register(get_files) # with gr.Blocks() as block: # textbox = gr.inputs.Textbox(label='Function Register') # button = gr.Button(value="Show Function Calls") # button.click(get_register,inputs=None,outputs=[textbox]) # block.launch() import json import ast def my_inference_function(name): # print(ast.literal_eval(name)['name']) return "Input Data: " + name + ", stay tuned for ML models from this API" gradio_interface = gr.Interface( fn=my_inference_function, inputs="text", outputs="text", title="REST API with Gradio and Huggingface Spaces", description='''Inputs should be json of test item e.g., as a dictionary; output right now is just returning the input; later label will be returned. This is how to call the API from Python: import requests response = requests.post("https://gmshroff-gmserver.hf.space/run/predict", json={ "data": [ "\", ]}).json() data = response["data"]) ''') gradio_interface.launch() # anvil.server.wait_forever()