import gradio as gr import pandas as pd import matplotlib.pyplot as plt import plotly.express as px def analyze_file(file): # خواندن فایل CSV df = pd.read_csv(file.name) # انجام تحلیل‌ها summary_stats = df.describe() # ایجاد نمودارها fig, ax = plt.subplots() df.plot(kind='line', x='date', y='growth', ax=ax) plt.title("Growth over Time") plt.xlabel("Date") plt.ylabel("Growth") # ذخیره نمودار plot_file = "plot.png" plt.savefig(plot_file) # ایجاد نمودار تعاملی با Plotly fig2 = px.line(df, x='date', y='growth', title='Growth over Time') return summary_stats.to_html(), plot_file, fig2 # ایجاد رابط کاربری با Gradio iface = gr.Interface( fn=analyze_file, inputs=gr.inputs.File(label="Upload CSV File"), outputs=[ gr.outputs.HTML(label="Summary Statistics"), gr.outputs.Image(label="Growth Chart"), gr.outputs.Plot(label="Interactive Growth Chart") ], title="Sugarcane Growth Analyzer", description="Upload a CSV file containing sugarcane growth data to analyze and visualize it." ) # اجرای برنامه iface.launch() # برای استقرار در هاگینگ فیس، از این کد در یک فایل پایتون استفاده کنید و سپس آن را در هاگینگ فیس آپلود کنید.