Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -55,13 +55,13 @@ if torch.cuda.is_available():
|
|
55 |
load_in_4bit=True,
|
56 |
)
|
57 |
|
|
|
58 |
|
59 |
@spaces.GPU()
|
60 |
def get_image_description(image):
|
61 |
torch.cuda.empty_cache()
|
62 |
gc.collect()
|
63 |
|
64 |
-
prompt = "[INST] <image>\nDescribe the image in a sentence [/INST]"
|
65 |
# n = len(prompt)
|
66 |
|
67 |
inputs = processor(prompt, image, return_tensors="pt").to("cuda:0")
|
@@ -100,7 +100,7 @@ def get_vectordb(text, images, img_doc_files):
|
|
100 |
descs = []
|
101 |
for i in range(len(images)):
|
102 |
try:
|
103 |
-
descs.append(img_doc_files[i]+"\n"+get_image_description(images[i]))
|
104 |
except:
|
105 |
descs.append("Could not generate image description due to some error")
|
106 |
print(descs[-1])
|
|
|
55 |
load_in_4bit=True,
|
56 |
)
|
57 |
|
58 |
+
prompt = "[INST] <image>\nDescribe the image in a sentence [/INST]"
|
59 |
|
60 |
@spaces.GPU()
|
61 |
def get_image_description(image):
|
62 |
torch.cuda.empty_cache()
|
63 |
gc.collect()
|
64 |
|
|
|
65 |
# n = len(prompt)
|
66 |
|
67 |
inputs = processor(prompt, image, return_tensors="pt").to("cuda:0")
|
|
|
100 |
descs = []
|
101 |
for i in range(len(images)):
|
102 |
try:
|
103 |
+
descs.append(img_doc_files[i]+"\n"+get_image_description(images[i]).replace(prompt, ""))
|
104 |
except:
|
105 |
descs.append("Could not generate image description due to some error")
|
106 |
print(descs[-1])
|