leadingbridge commited on
Commit
8ca8dfd
·
verified ·
1 Parent(s): 8235aef

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +20 -2
app.py CHANGED
@@ -1,7 +1,25 @@
1
  import gradio as gr
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2
 
3
  def dummy_function(*args):
4
- # This dummy function does nothing and is only used for UI display.
5
  return "This is a UI display only. No computation performed."
6
 
7
  # Define Gradio interface with updated inputs
@@ -20,7 +38,7 @@ iface = gr.Interface(
20
  gr.Dropdown(choices=list(range(1, 31)), label='Unit (e.g., A=1, B=2, C=3, ...)'),
21
  gr.Slider(minimum=137, maximum=5000, step=1, label='Area (in sq. feet)'),
22
  gr.Dropdown(choices=list(range(2022, 2024)), label='Year'),
23
- gr.Dropdown(choices=list(range(1, 53)), label='Week Number')
24
  ],
25
  outputs=gr.Textbox(label='Output'),
26
  title="PROPERTY PRICE PREDICTION TOOL UI DISPLAY",
 
1
  import gradio as gr
2
+ from datetime import date
3
+
4
+ def generate_week_choices(year=2022):
5
+ week_choices = []
6
+ # Generate choices for weeks 1 to 52 (using ISO week dates)
7
+ for week in range(1, 53):
8
+ try:
9
+ week_start = date.fromisocalendar(year, week, 1)
10
+ week_end = date.fromisocalendar(year, week, 7)
11
+ week_str = f"Week {week} ({week_start.strftime('%b %d')} - {week_end.strftime('%b %d')})"
12
+ week_choices.append(week_str)
13
+ except ValueError:
14
+ # If the week number is invalid for the given year, skip it.
15
+ continue
16
+ return week_choices
17
+
18
+ # Generate week choices for the default year 2022
19
+ week_choices = generate_week_choices(2022)
20
 
21
  def dummy_function(*args):
22
+ # Dummy function for UI display only.
23
  return "This is a UI display only. No computation performed."
24
 
25
  # Define Gradio interface with updated inputs
 
38
  gr.Dropdown(choices=list(range(1, 31)), label='Unit (e.g., A=1, B=2, C=3, ...)'),
39
  gr.Slider(minimum=137, maximum=5000, step=1, label='Area (in sq. feet)'),
40
  gr.Dropdown(choices=list(range(2022, 2024)), label='Year'),
41
+ gr.Dropdown(choices=week_choices, label='Week Number and Date Period')
42
  ],
43
  outputs=gr.Textbox(label='Output'),
44
  title="PROPERTY PRICE PREDICTION TOOL UI DISPLAY",