Spaces:
Sleeping
Sleeping
samlam111
commited on
Commit
·
fe6a861
1
Parent(s):
50cd4c6
Adding of multi word hashtags/designers
Browse files
app.py
CHANGED
@@ -105,6 +105,43 @@ def submit_form(
|
|
105 |
return int(prediction)
|
106 |
|
107 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
108 |
with gr.Blocks(theme="argilla/argilla-theme", title="Grailed Price Predictor") as demo:
|
109 |
global size_text_box
|
110 |
gr.HTML(
|
@@ -188,24 +225,82 @@ with gr.Blocks(theme="argilla/argilla-theme", title="Grailed Price Predictor") a
|
|
188 |
|
189 |
with gr.Row():
|
190 |
with gr.Column():
|
191 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
192 |
|
193 |
-
|
194 |
-
|
195 |
-
|
196 |
-
|
197 |
-
|
198 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
199 |
|
200 |
with gr.Column():
|
201 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
202 |
|
203 |
-
|
204 |
-
|
205 |
-
|
206 |
-
|
207 |
-
|
208 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
209 |
|
210 |
with gr.Row():
|
211 |
followernoNumber = gr.Number(label="Number of Followers")
|
@@ -227,8 +322,8 @@ with gr.Blocks(theme="argilla/argilla-theme", title="Grailed Price Predictor") a
|
|
227 |
sub_sub_category,
|
228 |
size_text_box,
|
229 |
color_text_box,
|
230 |
-
|
231 |
-
|
232 |
followernoNumber,
|
233 |
# userScoreNumber,
|
234 |
],
|
|
|
105 |
return int(prediction)
|
106 |
|
107 |
|
108 |
+
def add_hashtag(hashtags, new_hashtag):
|
109 |
+
if not new_hashtag:
|
110 |
+
return hashtags
|
111 |
+
current = hashtags.split() if hashtags else []
|
112 |
+
if new_hashtag not in current:
|
113 |
+
current.append(new_hashtag)
|
114 |
+
return " ".join(current)
|
115 |
+
|
116 |
+
def remove_hashtag(hashtags, hashtag_to_remove):
|
117 |
+
if not hashtags:
|
118 |
+
return ""
|
119 |
+
current = hashtags.split()
|
120 |
+
try:
|
121 |
+
current.remove(hashtag_to_remove.strip())
|
122 |
+
except ValueError:
|
123 |
+
pass
|
124 |
+
return " ".join(current)
|
125 |
+
|
126 |
+
def add_designer(designers, new_designer):
|
127 |
+
if not new_designer:
|
128 |
+
return designers
|
129 |
+
current = designers.split() if designers else []
|
130 |
+
if new_designer not in current:
|
131 |
+
current.append(new_designer)
|
132 |
+
return " ".join(current)
|
133 |
+
|
134 |
+
def remove_designer(designers, designer_to_remove):
|
135 |
+
if not designers:
|
136 |
+
return ""
|
137 |
+
current = designers.split()
|
138 |
+
try:
|
139 |
+
current.remove(designer_to_remove.strip())
|
140 |
+
except ValueError:
|
141 |
+
pass
|
142 |
+
return " ".join(current)
|
143 |
+
|
144 |
+
|
145 |
with gr.Blocks(theme="argilla/argilla-theme", title="Grailed Price Predictor") as demo:
|
146 |
global size_text_box
|
147 |
gr.HTML(
|
|
|
225 |
|
226 |
with gr.Row():
|
227 |
with gr.Column():
|
228 |
+
hashtags_state = gr.State("")
|
229 |
+
new_hashtag_input = gr.Textbox(label="Add Hashtag")
|
230 |
+
with gr.Row():
|
231 |
+
add_hashtag_btn = gr.Button("Add Hashtag")
|
232 |
+
clear_hashtags_btn = gr.Button("Clear All Hashtags")
|
233 |
+
hashtags_display = gr.Dataframe(
|
234 |
+
headers=["Hashtag"],
|
235 |
+
interactive=False,
|
236 |
+
label="Current Hashtags"
|
237 |
+
)
|
238 |
+
|
239 |
+
def update_hashtags_display(hashtags):
|
240 |
+
if not hashtags:
|
241 |
+
return []
|
242 |
+
return [[tag] for tag in hashtags.split()]
|
243 |
|
244 |
+
add_hashtag_btn.click(
|
245 |
+
add_hashtag,
|
246 |
+
inputs=[hashtags_state, new_hashtag_input],
|
247 |
+
outputs=hashtags_state
|
248 |
+
).then(
|
249 |
+
update_hashtags_display,
|
250 |
+
inputs=[hashtags_state],
|
251 |
+
outputs=hashtags_display
|
252 |
+
).then(
|
253 |
+
lambda: "",
|
254 |
+
outputs=new_hashtag_input
|
255 |
+
)
|
256 |
+
|
257 |
+
# Add clear functionality
|
258 |
+
clear_hashtags_btn.click(
|
259 |
+
lambda: "", # Clear the state
|
260 |
+
outputs=hashtags_state
|
261 |
+
).then(
|
262 |
+
lambda: [], # Clear the display
|
263 |
+
outputs=hashtags_display
|
264 |
+
)
|
265 |
|
266 |
with gr.Column():
|
267 |
+
designers_state = gr.State("")
|
268 |
+
new_designer_input = gr.Textbox(label="Add Designer")
|
269 |
+
with gr.Row():
|
270 |
+
add_designer_btn = gr.Button("Add Designer")
|
271 |
+
clear_designers_btn = gr.Button("Clear All Designers")
|
272 |
+
designers_display = gr.Dataframe(
|
273 |
+
headers=["Designer"],
|
274 |
+
interactive=False,
|
275 |
+
label="Current Designers"
|
276 |
+
)
|
277 |
|
278 |
+
def update_designers_display(designers):
|
279 |
+
if not designers:
|
280 |
+
return []
|
281 |
+
return [[designer] for designer in designers.split()]
|
282 |
+
|
283 |
+
add_designer_btn.click(
|
284 |
+
add_designer,
|
285 |
+
inputs=[designers_state, new_designer_input],
|
286 |
+
outputs=designers_state
|
287 |
+
).then(
|
288 |
+
update_designers_display,
|
289 |
+
inputs=[designers_state],
|
290 |
+
outputs=designers_display
|
291 |
+
).then(
|
292 |
+
lambda: "",
|
293 |
+
outputs=new_designer_input
|
294 |
+
)
|
295 |
+
|
296 |
+
# Add clear functionality
|
297 |
+
clear_designers_btn.click(
|
298 |
+
lambda: "", # Clear the state
|
299 |
+
outputs=designers_state
|
300 |
+
).then(
|
301 |
+
lambda: [], # Clear the display
|
302 |
+
outputs=designers_display
|
303 |
+
)
|
304 |
|
305 |
with gr.Row():
|
306 |
followernoNumber = gr.Number(label="Number of Followers")
|
|
|
322 |
sub_sub_category,
|
323 |
size_text_box,
|
324 |
color_text_box,
|
325 |
+
hashtags_state,
|
326 |
+
designers_state,
|
327 |
followernoNumber,
|
328 |
# userScoreNumber,
|
329 |
],
|