Update app.py
Browse files
app.py
CHANGED
@@ -2,9 +2,9 @@ import pandas as pd
|
|
2 |
import gradio as gr
|
3 |
|
4 |
# Core conversion logic
|
5 |
-
def convert_schedule(
|
6 |
# Read the uploaded Excel file (first sheet) with first column as index
|
7 |
-
df = pd.read_excel(
|
8 |
|
9 |
if direction == "A to B":
|
10 |
# Models in rows β Texters as rows
|
@@ -30,17 +30,19 @@ def convert_schedule(file, direction):
|
|
30 |
return result
|
31 |
|
32 |
# Build Gradio interface
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
|
|
|
|
|
|
43 |
|
44 |
if __name__ == "__main__":
|
45 |
-
|
46 |
-
iface.launch(server_name="0.0.0.0", server_port=7860)
|
|
|
2 |
import gradio as gr
|
3 |
|
4 |
# Core conversion logic
|
5 |
+
def convert_schedule(file_path, direction):
|
6 |
# Read the uploaded Excel file (first sheet) with first column as index
|
7 |
+
df = pd.read_excel(file_path, index_col=0)
|
8 |
|
9 |
if direction == "A to B":
|
10 |
# Models in rows β Texters as rows
|
|
|
30 |
return result
|
31 |
|
32 |
# Build Gradio interface
|
33 |
+
def main():
|
34 |
+
iface = gr.Interface(
|
35 |
+
fn=convert_schedule,
|
36 |
+
inputs=[
|
37 |
+
gr.File(label="Upload Schedule (.xlsx)", file_count="single", type="filepath"),
|
38 |
+
gr.Radio(["A to B", "B to A"], label="Conversion Direction")
|
39 |
+
],
|
40 |
+
outputs=gr.Dataframe(label="Converted Schedule"),
|
41 |
+
title="Dynamic Schedule Converter",
|
42 |
+
description="Upload an Excel file in Format A or B and convert between models-as-rows β texters-as-rows."
|
43 |
+
)
|
44 |
+
# Listen on all interfaces for Hugging Face Spaces
|
45 |
+
iface.launch(server_name="0.0.0.0", server_port=7860)
|
46 |
|
47 |
if __name__ == "__main__":
|
48 |
+
main()
|
|