Ashrafb commited on
Commit
f1d6c73
·
verified ·
1 Parent(s): a9a425c

Update main.py

Browse files
Files changed (1) hide show
  1. main.py +3 -5
main.py CHANGED
@@ -1193,7 +1193,6 @@ def cached_vision_encoder(image):
1193
  torch.save(image_vec, cache_path)
1194
  return image_vec.to(DEVICE, dtype=DTYPE)
1195
 
1196
-
1197
  def answer_question(image, question):
1198
  yield "Encoding image..."
1199
 
@@ -1209,18 +1208,17 @@ def answer_question(image, question):
1209
  buffer += new_text
1210
  if len(buffer) > 1:
1211
  yield re.sub("<$", "", re.sub("END$", "", buffer))
1212
-
1213
  # Define route for answering questions
1214
  @app.post("/upload/")
1215
  async def answer(image:UploadFile = File(...), Question: str = Form(...)):
1216
  image_pil = Image.open(image.file)
1217
 
1218
  answer = answer_question(image_pil, Question)
1219
- # Concatenate the result sentences into a single sentence
1220
- combined_result = ", ".join(answer)
1221
 
1222
  # Return the combined result as a single sentence
1223
- return {"answer": combined_result}
1224
 
1225
  app.mount("/", StaticFiles(directory="static", html=True), name="static")
1226
 
 
1193
  torch.save(image_vec, cache_path)
1194
  return image_vec.to(DEVICE, dtype=DTYPE)
1195
 
 
1196
  def answer_question(image, question):
1197
  yield "Encoding image..."
1198
 
 
1208
  buffer += new_text
1209
  if len(buffer) > 1:
1210
  yield re.sub("<$", "", re.sub("END$", "", buffer))
1211
+
1212
  # Define route for answering questions
1213
  @app.post("/upload/")
1214
  async def answer(image:UploadFile = File(...), Question: str = Form(...)):
1215
  image_pil = Image.open(image.file)
1216
 
1217
  answer = answer_question(image_pil, Question)
1218
+
 
1219
 
1220
  # Return the combined result as a single sentence
1221
+ return {"answer": answer}
1222
 
1223
  app.mount("/", StaticFiles(directory="static", html=True), name="static")
1224