Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -55,7 +55,6 @@ if torch.cuda.is_available():
|
|
| 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):
|
|
@@ -63,6 +62,7 @@ def get_image_description(image):
|
|
| 63 |
gc.collect()
|
| 64 |
|
| 65 |
# n = len(prompt)
|
|
|
|
| 66 |
|
| 67 |
inputs = processor(prompt, image, return_tensors="pt").to("cuda:0")
|
| 68 |
output = vision_model.generate(**inputs, max_new_tokens=100)
|
|
@@ -100,11 +100,11 @@ 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 |
-
|
| 107 |
-
|
| 108 |
|
| 109 |
# image_descriptions = get_image_descriptions(images)
|
| 110 |
image_dict = [{"image": image_to_bytes(img)} for img in images]
|
|
|
|
| 55 |
load_in_4bit=True,
|
| 56 |
)
|
| 57 |
|
|
|
|
| 58 |
|
| 59 |
@spaces.GPU()
|
| 60 |
def get_image_description(image):
|
|
|
|
| 62 |
gc.collect()
|
| 63 |
|
| 64 |
# n = len(prompt)
|
| 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)
|
|
|
|
| 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])
|
| 107 |
+
print()
|
| 108 |
|
| 109 |
# image_descriptions = get_image_descriptions(images)
|
| 110 |
image_dict = [{"image": image_to_bytes(img)} for img in images]
|