File size: 953 Bytes
513a1f2
3410966
513a1f2
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3410966
513a1f2
 
3410966
 
 
513a1f2
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
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)