Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -114,9 +114,9 @@ def generate_answers(image_path, question):
|
|
114 |
@spaces.GPU
|
115 |
def generate_caption_llava(image_path, caption_bool):
|
116 |
if caption_bool:
|
117 |
-
text_prompt =f"[INST]
|
118 |
else:
|
119 |
-
text_prompt =f"[INST]
|
120 |
|
121 |
inputs = processor(prompt, Image.open(image_path), return_tensors="pt").to(device)
|
122 |
|
@@ -126,7 +126,7 @@ def generate_caption_llava(image_path, caption_bool):
|
|
126 |
|
127 |
@spaces.GPU
|
128 |
def generate_answer_llava(image_path, question):
|
129 |
-
text_prompt =f"[INST]
|
130 |
inputs = processor(text_prompt, Image.open(image_path), return_tensors="pt").to(device)
|
131 |
output = model.generate(**inputs, max_new_tokens=100)
|
132 |
return processor.decode(output[0], skip_special_tokens=True)["generated_text"][len(text_prompt):]
|
|
|
114 |
@spaces.GPU
|
115 |
def generate_caption_llava(image_path, caption_bool):
|
116 |
if caption_bool:
|
117 |
+
text_prompt =f"[INST] <image>\nCaption this image in detail in objective manner.[/INST]"
|
118 |
else:
|
119 |
+
text_prompt =f"[INST] <image>\nCaption this image briefly in objective manner. [/INST]"
|
120 |
|
121 |
inputs = processor(prompt, Image.open(image_path), return_tensors="pt").to(device)
|
122 |
|
|
|
126 |
|
127 |
@spaces.GPU
|
128 |
def generate_answer_llava(image_path, question):
|
129 |
+
text_prompt =f"[INST] <image>\n{question} [/INST]"
|
130 |
inputs = processor(text_prompt, Image.open(image_path), return_tensors="pt").to(device)
|
131 |
output = model.generate(**inputs, max_new_tokens=100)
|
132 |
return processor.decode(output[0], skip_special_tokens=True)["generated_text"][len(text_prompt):]
|