Spaces:
Runtime error
Runtime error
Commit
·
12c88cf
1
Parent(s):
2c792b1
Update app.py
Browse files
app.py
CHANGED
@@ -112,99 +112,99 @@ class Retriever:
|
|
112 |
return paths_and_scores
|
113 |
|
114 |
|
115 |
-
def main(args):
|
116 |
-
|
117 |
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
def make_frontend(
|
162 |
-
|
163 |
-
):
|
164 |
-
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
-
|
190 |
-
|
191 |
-
|
192 |
-
|
193 |
-
|
194 |
-
|
195 |
-
|
196 |
-
|
197 |
-
|
198 |
-
|
199 |
-
|
200 |
-
|
201 |
-
|
202 |
-
|
203 |
-
|
204 |
-
|
205 |
-
|
206 |
-
|
207 |
-
|
208 |
|
209 |
|
210 |
class PredictorBackend:
|
@@ -240,40 +240,46 @@ class PredictorBackend:
|
|
240 |
logging.info(f"PRED >begin\n{pred}\nPRED >end")
|
241 |
|
242 |
|
243 |
-
|
244 |
-
|
245 |
-
|
246 |
-
|
247 |
-
|
248 |
-
|
249 |
-
|
250 |
-
|
251 |
-
|
252 |
-
|
253 |
-
|
254 |
-
|
255 |
-
|
256 |
-
|
257 |
-
|
258 |
-
|
259 |
-
|
260 |
-
|
261 |
-
|
262 |
-
|
263 |
-
|
264 |
-
|
265 |
-
|
266 |
-
|
267 |
-
|
268 |
-
|
269 |
-
|
270 |
-
|
271 |
-
|
272 |
-
|
273 |
-
|
274 |
-
|
275 |
-
|
276 |
-
|
277 |
-
|
278 |
-
|
279 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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:
|
|
|
240 |
logging.info(f"PRED >begin\n{pred}\nPRED >end")
|
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()
|
248 |
+
image_base64 = base64.b64encode(image_data).decode("utf-8")
|
249 |
+
|
250 |
+
allow_flagging = "never"
|
251 |
+
|
252 |
+
title = f"""
|
253 |
+
<h1 style="background-image: linear-gradient(to right, #ADD8E6, #87CEFA); -webkit-background-clip: text;
|
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: 10px;"/>
|
262 |
+
<p style="font-size: small; color: gray; margin-top: 10px;">
|
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: 18px; color: blue; margin-top: 10px; text-align: center;">
|
266 |
+
Discover your perfect apparel effortlessly. Simply describe what you're looking for!
|
267 |
+
</p>
|
268 |
+
</div>
|
269 |
+
"""
|
270 |
+
|
271 |
+
frontend = gr.Interface(
|
272 |
+
fn=predictor.run,
|
273 |
+
inputs=gr.inputs.Textbox(label="Item Description", placeholder="Enter item description here"),
|
274 |
+
outputs=gr.Gallery(label="Relevant Items", show_labels=True, label_position="below"),
|
275 |
+
title=title,
|
276 |
+
description=description,
|
277 |
+
cache_examples=False, # should we cache those inputs for faster inference? slows down start
|
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 |
+
# server_name="0.0.0.0", # make server accessible, binding all interfaces # noqa: S104
|
283 |
+
# server_port=args.port, # set a port to bind to, failing if unavailable
|
284 |
+
# share=False, # should we create a (temporary) public link on https://gradio.app?
|
285 |
+
)
|