Spaces:
Sleeping
Sleeping
import os | |
import gradio as gr | |
from Oracle.deepfundingoracle import prepare_dataset, train_predict_weight, create_submission_csv | |
# Gradio-only deployment entrypoint for Hugging Face Spaces | |
def analyze_file(upload): | |
# upload is a file-like object with .name | |
df = prepare_dataset(upload.name) | |
df = train_predict_weight(df) | |
csv_path = create_submission_csv(df, "submission.csv") | |
preview = df.head().to_csv(index=False) | |
return preview, csv_path | |
iface = gr.Interface( | |
fn=analyze_file, | |
inputs=gr.File(label="Upload CSV", type="file"), | |
outputs=[ | |
gr.Textbox(label="Preview of Results"), | |
gr.Textbox(label="Download CSV Path") | |
], | |
title="DeepFunding Oracle", | |
description="Upload a CSV of repo-parent relationships; returns base and final weight predictions as CSV." | |
) | |
if __name__ == "__main__": | |
port = int(os.environ.get("PORT", 7860)) | |
iface.launch(server_name="0.0.0.0", server_port=port) |