rynmurdock commited on
Commit
512401a
·
1 Parent(s): 93ebe82

non_block?

Browse files
Files changed (1) hide show
  1. app.py +30 -26
app.py CHANGED
@@ -363,10 +363,39 @@ def next_image(calibrate_prompts, user_id):
363
 
364
 
365
 
366
-
367
 
368
 
369
  def start(_, calibrate_prompts, user_id, request: gr.Request):
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
370
  user_id = int(str(time.time())[-7:].replace('.', ''))
371
  image, calibrate_prompts, text = next_image(calibrate_prompts, user_id)
372
  return [
@@ -548,31 +577,6 @@ def encode_space(x):
548
 
549
  return im_emb.detach().to('cpu').to(torch.float32), gemb
550
 
551
- # prep our calibration videos
552
- for im in [
553
- './first.mp4',
554
- './second.mp4',
555
- './third.mp4',
556
- './fourth.mp4',
557
- './fifth.mp4',
558
- './sixth.mp4',
559
- './seventh.mp4',
560
- './eigth.mp4',
561
- './ninth.mp4',
562
- './tenth.mp4',
563
- ]:
564
- tmp_df = pd.DataFrame(columns=['paths', 'embeddings', 'ips', 'user:rating', 'text', 'gemb'])
565
- tmp_df['paths'] = [im]
566
- image = list(imageio.imiter(im))
567
- image = image[len(image)//2]
568
- im_emb, gemb = encode_space(image)
569
-
570
- tmp_df['embeddings'] = [im_emb.detach().to('cpu')]
571
- tmp_df['gemb'] = [gemb.detach().to('cpu')]
572
- tmp_df['user:rating'] = [{' ': ' '}]
573
- prevs_df = pd.concat((prevs_df, tmp_df))
574
-
575
-
576
  demo.launch(share=True, server_port=8443)
577
 
578
 
 
363
 
364
 
365
 
366
+ done_init = False
367
 
368
 
369
  def start(_, calibrate_prompts, user_id, request: gr.Request):
370
+ global done_init
371
+
372
+ if not done_init:
373
+ # prep our calibration videos
374
+ for im in [
375
+ './first.mp4',
376
+ './second.mp4',
377
+ './third.mp4',
378
+ './fourth.mp4',
379
+ './fifth.mp4',
380
+ './sixth.mp4',
381
+ './seventh.mp4',
382
+ './eigth.mp4',
383
+ './ninth.mp4',
384
+ './tenth.mp4',
385
+ ]:
386
+ tmp_df = pd.DataFrame(columns=['paths', 'embeddings', 'ips', 'user:rating', 'text', 'gemb'])
387
+ tmp_df['paths'] = [im]
388
+ image = list(imageio.imiter(im))
389
+ image = image[len(image)//2]
390
+ im_emb, gemb = encode_space(image)
391
+
392
+ tmp_df['embeddings'] = [im_emb.detach().to('cpu')]
393
+ tmp_df['gemb'] = [gemb.detach().to('cpu')]
394
+ tmp_df['user:rating'] = [{' ': ' '}]
395
+ prevs_df = pd.concat((prevs_df, tmp_df))
396
+
397
+
398
+
399
  user_id = int(str(time.time())[-7:].replace('.', ''))
400
  image, calibrate_prompts, text = next_image(calibrate_prompts, user_id)
401
  return [
 
577
 
578
  return im_emb.detach().to('cpu').to(torch.float32), gemb
579
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
580
  demo.launch(share=True, server_port=8443)
581
 
582