Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -389,12 +389,14 @@ def start(_, calibrate_prompts, user_id, request: gr.Request):
|
|
389 |
image = list(imageio.imiter(im))
|
390 |
image = image[len(image)//2]
|
391 |
im_emb, gemb = encode_space(image)
|
|
|
|
|
392 |
|
393 |
-
tmp_df['embeddings'] = [im_emb
|
394 |
-
tmp_df['gemb'] = [gemb
|
395 |
tmp_df['user:rating'] = [{' ': ' '}]
|
396 |
prevs_df = pd.concat((prevs_df, tmp_df))
|
397 |
-
|
398 |
|
399 |
|
400 |
|
@@ -579,10 +581,10 @@ def encode_space(x):
|
|
579 |
im = torchvision.transforms.ToTensor()(x).to('cuda').unsqueeze(0)
|
580 |
im = torch.nn.functional.interpolate(im, (224, 224))
|
581 |
im = (im - .5) * 2
|
582 |
-
gemb = pali.vision_tower(im.to(dtype)).last_hidden_state
|
583 |
|
584 |
print('pali_enced')
|
585 |
-
return im_emb.detach().to(
|
586 |
|
587 |
demo.launch(share=True,)
|
588 |
|
|
|
389 |
image = list(imageio.imiter(im))
|
390 |
image = image[len(image)//2]
|
391 |
im_emb, gemb = encode_space(image)
|
392 |
+
im_emb = im_emb.to('cpu')
|
393 |
+
gemb = gemb.to('cpu')
|
394 |
|
395 |
+
tmp_df['embeddings'] = [im_emb]
|
396 |
+
tmp_df['gemb'] = [gemb]
|
397 |
tmp_df['user:rating'] = [{' ': ' '}]
|
398 |
prevs_df = pd.concat((prevs_df, tmp_df))
|
399 |
+
done_init = True
|
400 |
|
401 |
|
402 |
|
|
|
581 |
im = torchvision.transforms.ToTensor()(x).to('cuda').unsqueeze(0)
|
582 |
im = torch.nn.functional.interpolate(im, (224, 224))
|
583 |
im = (im - .5) * 2
|
584 |
+
gemb = pali.vision_tower(im.to(dtype)).last_hidden_state
|
585 |
|
586 |
print('pali_enced')
|
587 |
+
return im_emb.detach().to(torch.float32), gemb.detach().to(torch.float32)
|
588 |
|
589 |
demo.launch(share=True,)
|
590 |
|