Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -387,7 +387,12 @@ def start(_, calibrate_prompts, user_id, request: gr.Request):
|
|
| 387 |
tmp_df['paths'] = [im]
|
| 388 |
image = list(imageio.imiter(im))
|
| 389 |
image = image[len(image)//2]
|
| 390 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 391 |
im_emb = im_emb.to('cpu')
|
| 392 |
gemb = gemb.to('cpu')
|
| 393 |
|
|
@@ -568,7 +573,7 @@ scheduler.start()
|
|
| 568 |
|
| 569 |
# TODO shouldn't call this before gradio launch, yeah?
|
| 570 |
@spaces.GPU()
|
| 571 |
-
def encode_space(x):
|
| 572 |
print('encode')
|
| 573 |
im_emb, _ = pipe.encode_image(
|
| 574 |
x, DEVICE, 1, output_hidden_state
|
|
@@ -577,9 +582,6 @@ def encode_space(x):
|
|
| 577 |
print('encoded')
|
| 578 |
|
| 579 |
print('pali_enc')
|
| 580 |
-
im = torchvision.transforms.ToTensor()(x).unsqueeze(0)
|
| 581 |
-
im = torch.nn.functional.interpolate(im, (224, 224))
|
| 582 |
-
im = (im - .5) * 2
|
| 583 |
gemb = pali.vision_tower(im.to(dtype)).last_hidden_state
|
| 584 |
|
| 585 |
print('pali_enced')
|
|
|
|
| 387 |
tmp_df['paths'] = [im]
|
| 388 |
image = list(imageio.imiter(im))
|
| 389 |
image = image[len(image)//2]
|
| 390 |
+
|
| 391 |
+
im = torchvision.transforms.ToTensor()(x).unsqueeze(0)
|
| 392 |
+
im = torch.nn.functional.interpolate(im, (224, 224))
|
| 393 |
+
im = (im - .5) * 2
|
| 394 |
+
|
| 395 |
+
im_emb, gemb = encode_space(image, im.to('cuda'))
|
| 396 |
im_emb = im_emb.to('cpu')
|
| 397 |
gemb = gemb.to('cpu')
|
| 398 |
|
|
|
|
| 573 |
|
| 574 |
# TODO shouldn't call this before gradio launch, yeah?
|
| 575 |
@spaces.GPU()
|
| 576 |
+
def encode_space(x, im):
|
| 577 |
print('encode')
|
| 578 |
im_emb, _ = pipe.encode_image(
|
| 579 |
x, DEVICE, 1, output_hidden_state
|
|
|
|
| 582 |
print('encoded')
|
| 583 |
|
| 584 |
print('pali_enc')
|
|
|
|
|
|
|
|
|
|
| 585 |
gemb = pali.vision_tower(im.to(dtype)).last_hidden_state
|
| 586 |
|
| 587 |
print('pali_enced')
|