import os import gradio as gr from datasets import Dataset from huggingface_hub import HfApi, HfFolder # Get the Hugging Face token from the environment variable hf_token = os.getenv("HF_TOKEN") def upload_to_huggingface(file): # Load the CSV file into a Hugging Face Dataset dataset = Dataset.from_csv(file.name) # Authenticate using the Hugging Face token api = HfApi() api.upload_file( path_or_fileobj=file.name, path_in_repo="advertising.csv", repo_id="wvsu-dti-aidev-team/advertising_sales_regression", repo_type="dataset", token=hf_token ) return "Dataset uploaded successfully!" # Create a Gradio interface iface = gr.Interface( fn=upload_to_huggingface, inputs=gr.File(label="Upload CSV File"), outputs="text", title="Upload Dataset to Hugging Face", description="Upload the advertising.csv dataset to the Hugging Face Hub repository wvsu-dti-aidev-team/advertising_sales_regression." ) # Launch the Gradio app iface.launch()