Spaces:
Runtime error
Runtime error
epochs-demos
commited on
Commit
·
25cfecc
1
Parent(s):
12c88cf
Update app.py
Browse files
app.py
CHANGED
@@ -112,101 +112,6 @@ class Retriever:
|
|
112 |
return paths_and_scores
|
113 |
|
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(
|
162 |
-
# fn: Callable[[Image], str], flagging: bool = False, gantry: bool = False, app_name: str = "fashion-aggregator"
|
163 |
-
# ):
|
164 |
-
# """Creates a gradio.Interface frontend for text to image search function."""
|
165 |
-
|
166 |
-
# allow_flagging = "never"
|
167 |
-
|
168 |
-
# title = f"""
|
169 |
-
# <h1 style="background-image: linear-gradient(to right, #ADD8E6, #87CEFA); -webkit-background-clip: text;
|
170 |
-
# -webkit-text-fill-color: transparent; text-align: center;">
|
171 |
-
# Fashion Aggregator
|
172 |
-
# </h1>
|
173 |
-
# """
|
174 |
-
|
175 |
-
# disclaimer = f"""
|
176 |
-
# <div style="display: flex; align-items: center; justify-content: center;">
|
177 |
-
# <img src='data:image/jpeg;base64,{image_base64}' width='50' height='50' style="margin-right: 10px;"/>
|
178 |
-
# <p style="font-size: small; color: gray;">
|
179 |
-
# Disclaimer: This web app is for demonstration purposes only and not intended for commercial use. Contact: [email protected] for full solution.
|
180 |
-
# </p>
|
181 |
-
# </div>
|
182 |
-
# """
|
183 |
-
|
184 |
-
# description = f"""
|
185 |
-
# <div style="display: flex; align-items: center; justify-content: center; flex-direction: column;">
|
186 |
-
# <img src='data:image/jpeg;base64,{image_base64}' width='50' height='50' style="margin-right: 10px;"/>
|
187 |
-
# <p style="font-size: small; color: gray; margin-top: 10px;">
|
188 |
-
# Disclaimer: The search results are based on embeddings and may not always be accurate.
|
189 |
-
# </p>
|
190 |
-
# <p style="font-size: 18px; color: blue; margin-top: 10px; text-align: center;">
|
191 |
-
# Discover your perfect apparel effortlessly. Simply describe what you're looking for!
|
192 |
-
# </p>
|
193 |
-
# </div>
|
194 |
-
# """
|
195 |
-
|
196 |
-
# frontend = gr.Interface(
|
197 |
-
# fn=fn,
|
198 |
-
# inputs=gr.inputs.Textbox(label="Item Description", placeholder="Enter item description here"),
|
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
|
208 |
-
|
209 |
-
|
210 |
class PredictorBackend:
|
211 |
"""Interface to a backend that serves predictions.
|
212 |
|
@@ -241,7 +146,6 @@ class PredictorBackend:
|
|
241 |
|
242 |
|
243 |
predictor = PredictorBackend()
|
244 |
-
|
245 |
# Read the image file and encode it as base64
|
246 |
with open("./1001epochs.png", "rb") as f:
|
247 |
image_data = f.read()
|
@@ -250,19 +154,19 @@ with open("./1001epochs.png", "rb") as f:
|
|
250 |
allow_flagging = "never"
|
251 |
|
252 |
title = f"""
|
253 |
-
<h1 style="background-image: linear-gradient(to right, #
|
254 |
-webkit-text-fill-color: transparent; text-align: center;">
|
255 |
Fashion Aggregator
|
256 |
</h1>
|
257 |
-
|
258 |
|
259 |
description = f"""
|
260 |
<div style="display: flex; align-items: center; justify-content: center; flex-direction: column;">
|
261 |
-
<img src='data:image/jpeg;base64,{image_base64}' width='50' height='50' style="margin-right:
|
262 |
-
<p style="font-size: small; color:
|
263 |
Disclaimer: This web app is for demonstration purposes only and not intended for commercial use. Contact: [email protected] for full solution.
|
264 |
</p>
|
265 |
-
<p style="font-size:
|
266 |
Discover your perfect apparel effortlessly. Simply describe what you're looking for!
|
267 |
</p>
|
268 |
</div>
|
@@ -278,8 +182,45 @@ frontend = gr.Interface(
|
|
278 |
allow_flagging=allow_flagging, # should we show users the option to "flag" outputs?
|
279 |
flagging_options=["incorrect", "offensive", "other"], # what options do users have for feedback?
|
280 |
)
|
281 |
-
frontend.launch(
|
282 |
-
|
283 |
-
|
284 |
-
|
285 |
-
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
112 |
return paths_and_scores
|
113 |
|
114 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
115 |
class PredictorBackend:
|
116 |
"""Interface to a backend that serves predictions.
|
117 |
|
|
|
146 |
|
147 |
|
148 |
predictor = PredictorBackend()
|
|
|
149 |
# Read the image file and encode it as base64
|
150 |
with open("./1001epochs.png", "rb") as f:
|
151 |
image_data = f.read()
|
|
|
154 |
allow_flagging = "never"
|
155 |
|
156 |
title = f"""
|
157 |
+
<h1 style="background-image: linear-gradient(to right, #3A5FCD, #87CEFA); -webkit-background-clip: text;
|
158 |
-webkit-text-fill-color: transparent; text-align: center;">
|
159 |
Fashion Aggregator
|
160 |
</h1>
|
161 |
+
"""
|
162 |
|
163 |
description = f"""
|
164 |
<div style="display: flex; align-items: center; justify-content: center; flex-direction: column;">
|
165 |
+
<img src='data:image/jpeg;base64,{image_base64}' width='50' height='50' style="margin-right: 5px;"/>
|
166 |
+
<p style="font-size: small; color: #555; margin: 5px 0;">
|
167 |
Disclaimer: This web app is for demonstration purposes only and not intended for commercial use. Contact: [email protected] for full solution.
|
168 |
</p>
|
169 |
+
<p style="font-size: 16px; color: #333; margin: 5px 0; text-align: center;">
|
170 |
Discover your perfect apparel effortlessly. Simply describe what you're looking for!
|
171 |
</p>
|
172 |
</div>
|
|
|
182 |
allow_flagging=allow_flagging, # should we show users the option to "flag" outputs?
|
183 |
flagging_options=["incorrect", "offensive", "other"], # what options do users have for feedback?
|
184 |
)
|
185 |
+
frontend.launch()
|
186 |
+
# # Read the image file and encode it as base64
|
187 |
+
# with open("./1001epochs.png", "rb") as f:
|
188 |
+
# image_data = f.read()
|
189 |
+
# image_base64 = base64.b64encode(image_data).decode("utf-8")
|
190 |
+
|
191 |
+
# allow_flagging = "never"
|
192 |
+
|
193 |
+
# title = f"""
|
194 |
+
# <h1 style="background-image: linear-gradient(to right, #ADD8E6, #87CEFA); -webkit-background-clip: text;
|
195 |
+
# -webkit-text-fill-color: transparent; text-align: center;">
|
196 |
+
# Fashion Aggregator
|
197 |
+
# </h1>
|
198 |
+
# """
|
199 |
+
|
200 |
+
# description = f"""
|
201 |
+
# <div style="display: flex; align-items: center; justify-content: center; flex-direction: column;">
|
202 |
+
# <img src='data:image/jpeg;base64,{image_base64}' width='50' height='50' style="margin-right: 10px;"/>
|
203 |
+
# <p style="font-size: small; color: gray; margin-top: 10px;">
|
204 |
+
# Disclaimer: This web app is for demonstration purposes only and not intended for commercial use. Contact: [email protected] for full solution.
|
205 |
+
# </p>
|
206 |
+
# <p style="font-size: 18px; color: blue; margin-top: 10px; text-align: center;">
|
207 |
+
# Discover your perfect apparel effortlessly. Simply describe what you're looking for!
|
208 |
+
# </p>
|
209 |
+
# </div>
|
210 |
+
# """
|
211 |
+
|
212 |
+
# frontend = gr.Interface(
|
213 |
+
# fn=predictor.run,
|
214 |
+
# inputs=gr.inputs.Textbox(label="Item Description", placeholder="Enter item description here"),
|
215 |
+
# outputs=gr.Gallery(label="Relevant Items", show_labels=True, label_position="below"),
|
216 |
+
# title=title,
|
217 |
+
# description=description,
|
218 |
+
# cache_examples=False, # should we cache those inputs for faster inference? slows down start
|
219 |
+
# allow_flagging=allow_flagging, # should we show users the option to "flag" outputs?
|
220 |
+
# flagging_options=["incorrect", "offensive", "other"], # what options do users have for feedback?
|
221 |
+
# )
|
222 |
+
# frontend.launch(
|
223 |
+
# # server_name="0.0.0.0", # make server accessible, binding all interfaces # noqa: S104
|
224 |
+
# # server_port=args.port, # set a port to bind to, failing if unavailable
|
225 |
+
# # share=False, # should we create a (temporary) public link on https://gradio.app?
|
226 |
+
# )
|