Spaces:
Running
Running
Update server_medical_RAM_optimize.py
Browse files
server_medical_RAM_optimize.py
CHANGED
|
@@ -72,7 +72,7 @@ class ImageSearchEngine:
|
|
| 72 |
if isinstance(text, str):
|
| 73 |
text = [text]
|
| 74 |
|
| 75 |
-
tokens = self.tokenizer(text).to(device)
|
| 76 |
|
| 77 |
with torch.no_grad():
|
| 78 |
text_features = self.model.encode_text(tokens)
|
|
@@ -81,7 +81,7 @@ class ImageSearchEngine:
|
|
| 81 |
return text_features.cpu().numpy()
|
| 82 |
|
| 83 |
def image_to_vector(self, image):
|
| 84 |
-
image_tensor = self.preprocess(image).unsqueeze(0).to(device)
|
| 85 |
|
| 86 |
with torch.no_grad():
|
| 87 |
image_features = self.model.encode_image(image_tensor)
|
|
|
|
| 72 |
if isinstance(text, str):
|
| 73 |
text = [text]
|
| 74 |
|
| 75 |
+
tokens = self.tokenizer(text).to(self.device)
|
| 76 |
|
| 77 |
with torch.no_grad():
|
| 78 |
text_features = self.model.encode_text(tokens)
|
|
|
|
| 81 |
return text_features.cpu().numpy()
|
| 82 |
|
| 83 |
def image_to_vector(self, image):
|
| 84 |
+
image_tensor = self.preprocess(image).unsqueeze(0).to(self.device)
|
| 85 |
|
| 86 |
with torch.no_grad():
|
| 87 |
image_features = self.model.encode_image(image_tensor)
|