import gradio as gr import numpy as np import pandas as pd import matplotlib.pyplot as plt def plt_contour(path): path=path.strip(' ') path=path.replace('\\','/') data=pd.read_csv(str(path),skiprows=8,usecols=range(1,2002),header=None) x=np.linspace(0,800,2001) y=np.linspace(0,6,3001) X,Y=np.meshgrid(x,y) cl=plt.contour(X,Y,data,[1800]).collections[0].get_paths() dn=cl[0].vertices dn=pd.DataFrame(dn) dn.to_excel('file.xlsx') return 'file.xlsx' demo=gr.Interface( fn=plt_contour, inputs=[ # gr.Textbox() ], # "numpy", # outputs=["text"], outputs=[ #gr.Plot(label='画图'), gr.File(label='文件') ] # allow_flagging = "manual", # examples=[ # [30,5.98,1, "HighScore", [["Zr", 1, 91, 135.6], ["O", 2, 16, 11.63]]], # [1,3.97,1, "临界角全反射模型", [["Al",2, 27,50.33], ["O",3, 16, 11.63]]], # ], # title = title, # description = description, # article = article ) demo.launch()