|
import os |
|
import gradio as gr |
|
from datasets import Dataset |
|
from huggingface_hub import HfApi, HfFolder |
|
|
|
|
|
hf_token = os.getenv("HF_TOKEN") |
|
|
|
def upload_to_huggingface(file): |
|
|
|
dataset = Dataset.from_csv(file.name) |
|
|
|
|
|
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!" |
|
|
|
|
|
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." |
|
) |
|
|
|
|
|
iface.launch() |