epochs-demos commited on
Commit
2c792b1
·
1 Parent(s): 2280c36

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +41 -13
app.py CHANGED
@@ -1,7 +1,3 @@
1
- import os
2
- os.system("pip uninstall -y gradio")
3
- os.system("pip install gradio==3.32.0")
4
-
5
  """Find your apparel effortlessly. Just describe your apparel and get the relevant recommendations with links!"""
6
  import argparse
7
  import logging
@@ -118,19 +114,48 @@ class Retriever:
118
 
119
  def main(args):
120
  predictor = PredictorBackend(url=args.model_url)
121
- frontend = make_frontend(predictor.run, flagging=args.flagging, gantry=args.gantry, app_name=args.application)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
122
  frontend.launch(
123
  # server_name="0.0.0.0", # make server accessible, binding all interfaces # noqa: S104
124
  # server_port=args.port, # set a port to bind to, failing if unavailable
125
  # share=False, # should we create a (temporary) public link on https://gradio.app?
126
- # favicon_path=LOGO, # what icon should we display in the address bar?
127
- )
128
-
129
- # Read the image file and encode it as base64
130
- with open("./1001epochs.png", "rb") as f:
131
- image_data = f.read()
132
- image_base64 = base64.b64encode(image_data).decode("utf-8")
133
-
134
 
135
 
136
  def make_frontend(
@@ -174,6 +199,9 @@ def make_frontend(
174
  outputs=gr.Gallery(label="Relevant Items", show_labels=True, label_position="below"),
175
  title=title,
176
  description=description,
 
 
 
177
  )
178
 
179
  return frontend
 
 
 
 
 
1
  """Find your apparel effortlessly. Just describe your apparel and get the relevant recommendations with links!"""
2
  import argparse
3
  import logging
 
114
 
115
  def main(args):
116
  predictor = PredictorBackend(url=args.model_url)
117
+
118
+ # Read the image file and encode it as base64
119
+ with open("./1001epochs.png", "rb") as f:
120
+ image_data = f.read()
121
+ image_base64 = base64.b64encode(image_data).decode("utf-8")
122
+
123
+ allow_flagging = "never"
124
+
125
+ title = f"""
126
+ <h1 style="background-image: linear-gradient(to right, #ADD8E6, #87CEFA); -webkit-background-clip: text;
127
+ -webkit-text-fill-color: transparent; text-align: center;">
128
+ Fashion Aggregator
129
+ </h1>
130
+ """
131
+
132
+ description = f"""
133
+ <div style="display: flex; align-items: center; justify-content: center; flex-direction: column;">
134
+ <img src='data:image/jpeg;base64,{image_base64}' width='50' height='50' style="margin-right: 10px;"/>
135
+ <p style="font-size: small; color: gray; margin-top: 10px;">
136
+ Disclaimer: This web app is for demonstration purposes only and not intended for commercial use. Contact: [email protected] for full solution.
137
+ </p>
138
+ <p style="font-size: 18px; color: blue; margin-top: 10px; text-align: center;">
139
+ Discover your perfect apparel effortlessly. Simply describe what you're looking for!
140
+ </p>
141
+ </div>
142
+ """
143
+
144
+ frontend = gr.Interface(
145
+ fn=predictor.run,
146
+ inputs=gr.inputs.Textbox(label="Item Description", placeholder="Enter item description here"),
147
+ outputs=gr.Gallery(label="Relevant Items", show_labels=True, label_position="below"),
148
+ title=title,
149
+ description=description,
150
+ cache_examples=False, # should we cache those inputs for faster inference? slows down start
151
+ allow_flagging=allow_flagging, # should we show users the option to "flag" outputs?
152
+ flagging_options=["incorrect", "offensive", "other"], # what options do users have for feedback?
153
+ )
154
  frontend.launch(
155
  # server_name="0.0.0.0", # make server accessible, binding all interfaces # noqa: S104
156
  # server_port=args.port, # set a port to bind to, failing if unavailable
157
  # share=False, # should we create a (temporary) public link on https://gradio.app?
158
+ )
 
 
 
 
 
 
 
159
 
160
 
161
  def make_frontend(
 
199
  outputs=gr.Gallery(label="Relevant Items", show_labels=True, label_position="below"),
200
  title=title,
201
  description=description,
202
+ cache_examples=False, # should we cache those inputs for faster inference? slows down start
203
+ allow_flagging=allow_flagging, # should we show users the option to "flag" outputs?
204
+ flagging_options=["incorrect", "offensive", "other"], # what options do users have for feedback?
205
  )
206
 
207
  return frontend