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