Spaces:
Runtime error
Runtime error
Commit
·
32b4589
1
Parent(s):
6b5ce80
app.py
CHANGED
|
@@ -222,7 +222,9 @@ def pluck_img(user_id, user_emb):
|
|
| 222 |
|
| 223 |
|
| 224 |
def background_next_image():
|
| 225 |
-
|
|
|
|
|
|
|
| 226 |
# only let it get N (maybe 3) ahead of the user
|
| 227 |
#not_rated_rows = prevs_df[[i[1]['user:rating'] == {' ': ' '} for i in prevs_df.iterrows()]]
|
| 228 |
rated_rows = prevs_df[[i[1]['user:rating'] != {' ': ' '} for i in prevs_df.iterrows()]]
|
|
@@ -245,7 +247,7 @@ def background_next_image():
|
|
| 245 |
|
| 246 |
# we pop previous ratings if there are > 10
|
| 247 |
if len(rated_from_user) >= 10:
|
| 248 |
-
oldest =
|
| 249 |
prevs_df = prevs_df[prevs_df['paths'] != oldest]
|
| 250 |
# we don't compute more after 10 are in the queue for them
|
| 251 |
if len(unrated_from_user) >= 10:
|
|
@@ -320,8 +322,11 @@ def next_image(calibrate_prompts, user_id):
|
|
| 320 |
|
| 321 |
|
| 322 |
def start(_, calibrate_prompts, user_id, request: gr.Request):
|
|
|
|
| 323 |
user_id = int(str(time.time())[-7:].replace('.', ''))
|
| 324 |
image, calibrate_prompts = next_image(calibrate_prompts, user_id)
|
|
|
|
|
|
|
| 325 |
return [
|
| 326 |
gr.Button(value='Like (L)', interactive=True),
|
| 327 |
gr.Button(value='Neither (Space)', interactive=True, visible=False),
|
|
@@ -479,9 +484,9 @@ Explore the latent space without text prompts based on your preferences. Learn m
|
|
| 479 |
log = logging.getLogger('log_here')
|
| 480 |
log.setLevel(logging.ERROR)
|
| 481 |
|
| 482 |
-
scheduler = BackgroundScheduler()
|
| 483 |
-
scheduler.add_job(func=background_next_image, trigger="interval", seconds=.1)
|
| 484 |
-
scheduler.start()
|
| 485 |
|
| 486 |
#thread = threading.Thread(target=background_next_image,)
|
| 487 |
#thread.start()
|
|
|
|
| 222 |
|
| 223 |
|
| 224 |
def background_next_image():
|
| 225 |
+
global prevs_df
|
| 226 |
+
global is_started
|
| 227 |
+
while True:
|
| 228 |
# only let it get N (maybe 3) ahead of the user
|
| 229 |
#not_rated_rows = prevs_df[[i[1]['user:rating'] == {' ': ' '} for i in prevs_df.iterrows()]]
|
| 230 |
rated_rows = prevs_df[[i[1]['user:rating'] != {' ': ' '} for i in prevs_df.iterrows()]]
|
|
|
|
| 247 |
|
| 248 |
# we pop previous ratings if there are > 10
|
| 249 |
if len(rated_from_user) >= 10:
|
| 250 |
+
oldest = rated_from_user.iloc[0]['paths']
|
| 251 |
prevs_df = prevs_df[prevs_df['paths'] != oldest]
|
| 252 |
# we don't compute more after 10 are in the queue for them
|
| 253 |
if len(unrated_from_user) >= 10:
|
|
|
|
| 322 |
|
| 323 |
|
| 324 |
def start(_, calibrate_prompts, user_id, request: gr.Request):
|
| 325 |
+
global is_started
|
| 326 |
user_id = int(str(time.time())[-7:].replace('.', ''))
|
| 327 |
image, calibrate_prompts = next_image(calibrate_prompts, user_id)
|
| 328 |
+
if not is_started:
|
| 329 |
+
background_next_image()
|
| 330 |
return [
|
| 331 |
gr.Button(value='Like (L)', interactive=True),
|
| 332 |
gr.Button(value='Neither (Space)', interactive=True, visible=False),
|
|
|
|
| 484 |
log = logging.getLogger('log_here')
|
| 485 |
log.setLevel(logging.ERROR)
|
| 486 |
|
| 487 |
+
#scheduler = BackgroundScheduler()
|
| 488 |
+
#scheduler.add_job(func=background_next_image, trigger="interval", seconds=.1)
|
| 489 |
+
#scheduler.start()
|
| 490 |
|
| 491 |
#thread = threading.Thread(target=background_next_image,)
|
| 492 |
#thread.start()
|