ans123 commited on
Commit
5d951f6
·
verified ·
1 Parent(s): 64fc317

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +36 -38
app.py CHANGED
@@ -39,6 +39,22 @@ def submit_questionnaire(name, age, location, gender, ethnicity, height, weight,
39
 
40
  return "Thank you for completing the questionnaire!"
41
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
42
  # Function to handle chat
43
  def chat(user_input, messages):
44
  if user_input:
@@ -73,7 +89,7 @@ def chat(user_input, messages):
73
 
74
  # Gradio Interface
75
  with gr.Blocks() as demo:
76
- gr.Markdown("## FRIDAY")
77
 
78
  # Sidebar for user inputs
79
  with gr.Row():
@@ -87,7 +103,7 @@ with gr.Blocks() as demo:
87
  weight = gr.Number(label="Weight (kg)", value=70, minimum=20, maximum=200)
88
 
89
  with gr.Column():
90
- submit_btn = gr.Button("Submit Inputs")
91
  reset_btn = gr.Button("Reset Chat")
92
 
93
  # Questionnaire with fashion-related questions
@@ -101,55 +117,37 @@ with gr.Blocks() as demo:
101
  ("How often do you experiment with new trends?", ["Always", "Sometimes", "Rarely", "Never"]),
102
  ("What kind of accessories do you usually wear?", ["Watches", "Rings", "Necklaces", "Bracelets", "Earrings"]),
103
  ("Do you follow fashion trends?", ["Always", "Sometimes", "Never"]),
104
- ("How satisfied are you with your wardrobe?", ["Very Satisfied", "Satisfied", "Neutral", "Unsatisfied"]),
105
  ("Do you consider your style unique?", ["Yes", "No"]),
106
  ("How confident do you feel in your style?", ["Very Confident", "Somewhat Confident", "Not Confident"]),
107
  ("Where do you look for fashion inspiration?", ["Social Media", "Fashion Magazines", "Friends", "Other"]),
108
  ("Do you have specific attire for special occasions?", ["Yes", "No"]),
109
  ("Do you wear gender-neutral clothing?", ["Yes", "No"]),
110
- ("Which clothing materials do you prefer?", ["Cotton", "Silk", "Denim", "Synthetic", "Wool"]),
111
- ("How important is sustainability in your fashion choices?", ["Very Important", "Somewhat Important", "Not Important"]),
112
- ("Do you prefer shopping online or in physical stores?", ["Online", "Physical Stores"]),
113
- ("How often do you update your wardrobe?", ["Seasonally", "Every Few Months", "Once a Year", "Rarely"]),
114
- ("Do you participate in clothing swaps or second-hand shopping?", ["Yes", "No"]),
115
  ]
116
 
117
- # Create a button for filling the questionnaire
118
  fill_questionnaire_btn = gr.Button("Fill Questionnaire")
 
 
 
119
 
120
- # Output message for questionnaire submission
121
- questionnaire_output = gr.Textbox(label="Questionnaire Submission", interactive=False)
122
-
123
- # Function to collect all questionnaire responses
124
- def collect_questionnaire_responses():
125
- # Store questionnaire responses in a DataFrame
126
- questionnaire_data = {
127
- "Style Preference": style_preference.value,
128
- "Color Palette": color_palette.value,
129
- "Everyday Style": everyday_style.value
130
- }
131
-
132
- # Append additional responses
133
- for question, choices in fashion_questions:
134
- questionnaire_data[question] = gr.Radio(label=question, choices=choices).value
135
-
136
- df = pd.DataFrame([questionnaire_data]) # Create DataFrame from dictionary
137
-
138
- # Append to CSV file
139
- df.to_csv("questionnaire_responses.csv", mode='a', header=not pd.io.common.file_exists("questionnaire_responses.csv"), index=False)
140
-
141
- return "Thank you for completing the questionnaire!"
142
 
143
  # Connect the buttons to their respective functions
144
  submit_btn.click(submit_questionnaire, inputs=[name, age, location, gender, ethnicity, height, weight,
145
- style_preference, color_palette, everyday_style], outputs=questionnaire_output)
146
-
147
- fill_questionnaire_btn.click(collect_questionnaire_responses, outputs=questionnaire_output)
148
-
149
- reset_btn.click(reset_chat, outputs=[gr.Chatbot(type='messages'), "title"])
150
 
151
- user_input = gr.Textbox(label="Your Message", placeholder="Type your message here...")
152
- chatbox = gr.Chatbot(type='messages')
 
 
153
 
154
  user_input.submit(chat, inputs=[user_input, chatbox], outputs=[chatbox, user_input])
155
 
 
39
 
40
  return "Thank you for completing the questionnaire!"
41
 
42
+ # Function to collect responses to additional fashion-related questions
43
+ def collect_questionnaire_responses(style_preference, color_palette, everyday_style):
44
+ # Store additional responses in a DataFrame
45
+ additional_data = {
46
+ "Style Preference": style_preference,
47
+ "Color Palette": color_palette,
48
+ "Everyday Style": everyday_style
49
+ }
50
+
51
+ df = pd.DataFrame([additional_data]) # Create DataFrame from dictionary
52
+
53
+ # Append to CSV file
54
+ df.to_csv("additional_questionnaire_responses.csv", mode='a', header=not pd.io.common.file_exists("additional_questionnaire_responses.csv"), index=False)
55
+
56
+ return "Thank you for answering the additional questions!"
57
+
58
  # Function to handle chat
59
  def chat(user_input, messages):
60
  if user_input:
 
89
 
90
  # Gradio Interface
91
  with gr.Blocks() as demo:
92
+ gr.Markdown("## Fashion Assistant Chatbot")
93
 
94
  # Sidebar for user inputs
95
  with gr.Row():
 
103
  weight = gr.Number(label="Weight (kg)", value=70, minimum=20, maximum=200)
104
 
105
  with gr.Column():
106
+ submit_btn = gr.Button("Submit User Inputs")
107
  reset_btn = gr.Button("Reset Chat")
108
 
109
  # Questionnaire with fashion-related questions
 
117
  ("How often do you experiment with new trends?", ["Always", "Sometimes", "Rarely", "Never"]),
118
  ("What kind of accessories do you usually wear?", ["Watches", "Rings", "Necklaces", "Bracelets", "Earrings"]),
119
  ("Do you follow fashion trends?", ["Always", "Sometimes", "Never"]),
120
+ ("How satisfied are you with your wardrobe?", ["Yes", "No"]),
121
  ("Do you consider your style unique?", ["Yes", "No"]),
122
  ("How confident do you feel in your style?", ["Very Confident", "Somewhat Confident", "Not Confident"]),
123
  ("Where do you look for fashion inspiration?", ["Social Media", "Fashion Magazines", "Friends", "Other"]),
124
  ("Do you have specific attire for special occasions?", ["Yes", "No"]),
125
  ("Do you wear gender-neutral clothing?", ["Yes", "No"]),
126
+ ("What influences your fashion choices the most?", ["Celebrities", "Social Media", "Friends", "Personal Preference"]),
127
+ ("Do you enjoy shopping for clothes?", ["Yes", "No"]),
128
+ ("How often do you declutter your wardrobe?", ["Regularly", "Occasionally", "Rarely"]),
129
+ ("Do you have a favorite fashion brand?", ["Yes", "No"]),
130
+ ("How do you feel about thrift shopping?", ["Love it", "Neutral", "Dislike it"]),
131
  ]
132
 
133
+ # Create a separate button for the questionnaire
134
  fill_questionnaire_btn = gr.Button("Fill Questionnaire")
135
+
136
+ for question, choices in fashion_questions:
137
+ gr.Radio(label=question, choices=choices)
138
 
139
+ # Chat functionality
140
+ chatbox = gr.Chatbot(type='messages')
141
+ user_input = gr.Textbox(label="Your Message", placeholder="Type your message here...")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
142
 
143
  # Connect the buttons to their respective functions
144
  submit_btn.click(submit_questionnaire, inputs=[name, age, location, gender, ethnicity, height, weight,
145
+ style_preference, color_palette, everyday_style], outputs="Thank you for completing the questionnaire!")
 
 
 
 
146
 
147
+ fill_questionnaire_btn.click(collect_questionnaire_responses, inputs=[style_preference, color_palette, everyday_style], outputs="Thank you for answering the additional questions!")
148
+
149
+ # Corrected reset button output
150
+ reset_btn.click(reset_chat, outputs=[chatbox, "title"])
151
 
152
  user_input.submit(chat, inputs=[user_input, chatbox], outputs=[chatbox, user_input])
153