kreemyyyy commited on
Commit
e22be08
Β·
verified Β·
1 Parent(s): 826a51f

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +16 -14
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(file, direction):
6
  # Read the uploaded Excel file (first sheet) with first column as index
7
- df = pd.read_excel(file.name, index_col=0)
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
- iface = gr.Interface(
34
- fn=convert_schedule,
35
- inputs=[
36
- gr.File(label="Upload Schedule (.xlsx)", file_count="single", type="file"),
37
- gr.Radio(["A to B", "B to A"], label="Conversion Direction")
38
- ],
39
- outputs=gr.Dataframe(label="Converted Schedule"),
40
- title="Dynamic Schedule Converter",
41
- description="Upload an Excel file in Format A or B and convert between models-as-rows ↔ texters-as-rows."
42
- )
 
 
 
43
 
44
  if __name__ == "__main__":
45
- # Ensure compatibility with Hugging Face Spaces
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()