Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -61,13 +61,11 @@ def get_image_description(image):
|
|
61 |
torch.cuda.empty_cache()
|
62 |
gc.collect()
|
63 |
|
64 |
-
descriptions = []
|
65 |
prompt = "[INST] <image>\nDescribe the image in a sentence [/INST]"
|
66 |
|
67 |
inputs = processor(prompt, image, return_tensors="pt").to("cuda:0")
|
68 |
output = vision_model.generate(**inputs, max_new_tokens=100)
|
69 |
-
|
70 |
-
return descriptions
|
71 |
|
72 |
|
73 |
CSS = """
|
@@ -100,10 +98,13 @@ def get_vectordb(text, images, img_doc_files):
|
|
100 |
)
|
101 |
descs = []
|
102 |
for i in range(len(images)):
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
|
|
|
|
|
|
107 |
print(descs[-1])
|
108 |
print()
|
109 |
|
|
|
61 |
torch.cuda.empty_cache()
|
62 |
gc.collect()
|
63 |
|
|
|
64 |
prompt = "[INST] <image>\nDescribe the image in a sentence [/INST]"
|
65 |
|
66 |
inputs = processor(prompt, image, return_tensors="pt").to("cuda:0")
|
67 |
output = vision_model.generate(**inputs, max_new_tokens=100)
|
68 |
+
return (processor.decode(output[0], skip_special_tokens=True))
|
|
|
69 |
|
70 |
|
71 |
CSS = """
|
|
|
98 |
)
|
99 |
descs = []
|
100 |
for i in range(len(images)):
|
101 |
+
try:
|
102 |
+
descs.append(img_doc_files[i]+"\n"+get_image_description(images[i]))
|
103 |
+
except:
|
104 |
+
descs.append("Could not generate image description due to some error")
|
105 |
+
print(img_doc_files)
|
106 |
+
print(images[i])
|
107 |
+
print()
|
108 |
print(descs[-1])
|
109 |
print()
|
110 |
|