import numpy import gradio from huggingface_hub import from_pretrained_keras S = 5 N = 1000 D = 3 F = 64 G = 32 analysis_network = from_pretrained_keras("cmudrc/wave-energy-analysis") synthesis_network = from_pretrained_keras("cmudrc/wave-energy-synthesis") with gradio.Blocks() as demo: geometry = gradio.Textbox(label="geometry") spectrum = gradio.Textbox(label="spectrum") analyze_it = gradio.Button("Analyze") synthesize_it = gradio.Button("Synthesize") analyze_it.click(fn=lambda x: analysis_network.predict(numpy.fromstring(x, dtype=float)).tostring(), inputs=[geometry], outputs=[spectrum], api_name="analyze") synthesize_it.click(fn=lambda x: synthesis_network.predict(numpy.fromstring(x, dtype=int)).tostring(), inputs=[spectrum], outputs=[geometry], api_name="synthesize") demo.launch()