antoinette-f commited on
Commit
dd4bb67
·
verified ·
1 Parent(s): 204f79a

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +1 -37
app.py CHANGED
@@ -2,29 +2,11 @@ import gradio as gr
2
  import pandas as pd
3
  from huggingface_hub import InferenceClient
4
 
5
- # Load the AI model and clothing database
6
- # NOTE: Replace 'microsoft/phi-4' with the actual model ID if different
7
- # The client is used for generating the AI's text response.
8
- client = InferenceClient("microsoft/phi-4")
9
-
10
- # Load the clothing database CSV. Make sure 'clothing.csv' is in the same directory.
11
- try:
12
- clothing_df = pd.read_csv("clothing.csv")
13
- except FileNotFoundError:
14
- print("Error: 'clothing.csv' not found. Please ensure the file is in the same directory.")
15
- clothing_df = pd.DataFrame(columns=['weather', 'formality', 'category', 'image_path'])
16
 
17
- # Simple filtering function to get clothing suggestions based on a query
18
- import gradio as gr
19
- import pandas as pd
20
- from huggingface_hub import InferenceClient
21
 
22
- # Load the AI model and clothing database
23
- # NOTE: Replace 'microsoft/phi-4' with the actual model ID if different
24
- # The client is used for generating the AI's text response.
25
  client = InferenceClient("microsoft/phi-4")
26
 
27
- # Load the clothing database CSV. Make sure 'clothing.csv' is in the same directory.
28
  try:
29
  clothing_df = pd.read_csv("clothing.csv")
30
  except FileNotFoundError:
@@ -113,24 +95,6 @@ def get_suggestions(query):
113
  # Return the updated chat history and the image paths
114
  return chat_history, image_paths
115
 
116
- # Gradio UI ---
117
- with gr.Blocks(theme=gr.themes.Soft()) as demo:
118
- gr.Markdown("## Fashioneer - your fashion pioneer!")
119
- gr.Markdown("Ask me what to wear and I'll suggest clothing with images from the database.")
120
-
121
- # This is the search bar at the top
122
- user_input = gr.Textbox(label="Type your outfit requirements here", placeholder="e.g., What should I wear on a rainy day?")
123
-
124
- # This row will place the chatbot and gallery side-by-side
125
- with gr.Row():
126
- chatbot = gr.Chatbot(label="Chatbot Conversation")
127
- gallery = gr.Gallery(label="Recommended Clothing", columns=2, height='auto')
128
-
129
- # This is the original line that connects the input and output
130
- user_input.submit(fn=respond, inputs=[user_input, chatbot], outputs=[chatbot, gallery])
131
-
132
- # This starts the Gradio app
133
- demo.launch()
134
 
135
  # Chatbot + image output function
136
  def respond(message, chat_history):
 
2
  import pandas as pd
3
  from huggingface_hub import InferenceClient
4
 
 
 
 
 
 
 
 
 
 
 
 
5
 
 
 
 
 
6
 
 
 
 
7
  client = InferenceClient("microsoft/phi-4")
8
 
9
+ # Load the clothing database CSV.
10
  try:
11
  clothing_df = pd.read_csv("clothing.csv")
12
  except FileNotFoundError:
 
95
  # Return the updated chat history and the image paths
96
  return chat_history, image_paths
97
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
98
 
99
  # Chatbot + image output function
100
  def respond(message, chat_history):