Kunalv commited on
Commit
4d6b92b
·
1 Parent(s): 0e40d04

Custom UI

Browse files
Files changed (4) hide show
  1. app.py +26 -0
  2. requirements.txt +6 -0
  3. ui/layout.py +27 -0
  4. ui/style.css +74 -0
app.py ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from ui.layout import create_ui
3
+
4
+ # Load the custom CSS for the "Off-Brand" Badge
5
+ try:
6
+ with open("ui/style.css", "r") as f:
7
+ custom_css = f.read()
8
+ except FileNotFoundError:
9
+ custom_css = ""
10
+
11
+ # Build the Gradio App with a modern theme and our custom CSS injected
12
+ demo = gr.Blocks(
13
+ css=custom_css,
14
+ theme=gr.themes.Default(
15
+ primary_hue="blue",
16
+ neutral_hue="slate",
17
+ font=[gr.themes.GoogleFont("Inter"), "sans-serif"]
18
+ )
19
+ )
20
+
21
+ with demo:
22
+ # Initialize the UI layout from the ui folder
23
+ create_ui()
24
+
25
+ if __name__ == "__main__":
26
+ demo.launch()
requirements.txt ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
 
1
+ gradio>=4.0.0
2
+ spaces
3
+ torch
4
+ transformers
5
+ accelerate
6
+ pillow
ui/layout.py ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+
3
+ def create_ui():
4
+ """
5
+ Creates the main UI layout for the Gradio app using custom CSS classes.
6
+ """
7
+ with gr.Column(elem_classes=["app-container"]):
8
+
9
+ # Header Section
10
+ gr.Markdown("# 💸 Family Bill Assistant", elem_classes=["header-title"])
11
+ gr.Markdown("Upload your grocery or medical bills to get them categorized and explained in simple Hindi/English.", elem_classes=["header-subtitle"])
12
+
13
+ # Main Layout
14
+ with gr.Row():
15
+
16
+ # Left Panel: Inputs
17
+ with gr.Column(scale=1):
18
+ image_input = gr.Image(type="filepath", label="Upload Bill Image", elem_classes=["input-box"])
19
+ audio_input = gr.Audio(type="filepath", label="Or Send a Voice Note", elem_classes=["input-box"])
20
+ submit_btn = gr.Button("Analyze Bill", elem_classes=["submit-btn"])
21
+
22
+ # Right Panel: Output/Chat Agent
23
+ with gr.Column(scale=2):
24
+ chatbot = gr.Chatbot(label="Agent", elem_classes=["chat-window"], height=500)
25
+ msg_input = gr.Textbox(label="Ask a question", placeholder="e.g. How much did I spend on junk food?", elem_classes=["chat-input"])
26
+
27
+ # TODO: In Milestone 2 & 3, we will bind functions to the submit_btn and msg_input.
ui/style.css ADDED
@@ -0,0 +1,74 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*
2
+ * Custom CSS for the "Off-Brand" Badge
3
+ * This overrides Gradio's default blocky styles to make it look like a premium React/MERN app.
4
+ */
5
+
6
+ body {
7
+ background-color: #f8fafc; /* Tailwind slate-50 background */
8
+ }
9
+
10
+ .app-container {
11
+ max-width: 1200px;
12
+ margin: 0 auto;
13
+ padding: 2rem;
14
+ }
15
+
16
+ .header-title {
17
+ text-align: center;
18
+ color: #0f172a;
19
+ font-size: 2.5rem !important;
20
+ font-weight: 800 !important;
21
+ margin-bottom: 0.5rem;
22
+ }
23
+
24
+ .header-subtitle {
25
+ text-align: center;
26
+ color: #64748b;
27
+ font-size: 1.1rem;
28
+ margin-bottom: 2rem;
29
+ }
30
+
31
+ /* Glassmorphism effect for the input boxes */
32
+ .input-box {
33
+ background: rgba(255, 255, 255, 0.7) !important;
34
+ backdrop-filter: blur(10px);
35
+ border-radius: 16px !important;
36
+ border: 1px solid rgba(255, 255, 255, 0.5) !important;
37
+ box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05);
38
+ transition: all 0.2s ease;
39
+ }
40
+
41
+ .input-box:hover {
42
+ box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
43
+ }
44
+
45
+ /* Premium gradient submit button */
46
+ .submit-btn {
47
+ background: linear-gradient(135deg, #3b82f6, #2563eb) !important;
48
+ color: white !important;
49
+ border: none !important;
50
+ border-radius: 12px !important;
51
+ padding: 12px !important;
52
+ font-weight: bold !important;
53
+ font-size: 1.1rem !important;
54
+ margin-top: 1rem;
55
+ box-shadow: 0 4px 14px 0 rgba(59, 130, 246, 0.39);
56
+ transition: transform 0.1s ease;
57
+ }
58
+
59
+ .submit-btn:hover {
60
+ transform: translateY(-2px);
61
+ }
62
+
63
+ /* Sleek chat window */
64
+ .chat-window {
65
+ border-radius: 16px !important;
66
+ border: 1px solid #e2e8f0 !important;
67
+ box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.05);
68
+ background-color: white !important;
69
+ }
70
+
71
+ .chat-input {
72
+ border-radius: 12px !important;
73
+ border: 1px solid #cbd5e1 !important;
74
+ }