Skip to content

Commit

Permalink
fix bug
Browse files Browse the repository at this point in the history
  • Loading branch information
jokester-zzz committed Sep 5, 2024
1 parent 9f235ce commit ff13cfb
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ data
data/*
pretrained
pretrained/*
dreamer_pretrained
dreamer_pretrained/*

# vscode
.vscode/*
Expand Down
11 changes: 9 additions & 2 deletions WorldDreamer/tools/dreamer_fast_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ async def process(request: Request, background_tasks: BackgroundTasks):
combined_image.save(img_byte_array, format="PNG")
img_byte_array.seek(0)
# add into image_queue
image_queue.put({'param': param, 'img': img_byte_array})
image_queue.put({'param': param, 'img': gen_imgs_list[0]})
background_tasks.add_task(send2agent)

return StreamingResponse(io.BytesIO(img_byte_array.read()), media_type="image/png")
Expand All @@ -121,7 +121,14 @@ async def send2agent():
print("current timestamp:", timestamp)
if image_queue.qsize() >= 1:
cur_data = image_queue.get()
img_byte_array = cur_data['img']
gen_imgs = cur_data['img']
combined_image = Image.new("RGB", (gen_imgs[0].width, sum(img.height for img in gen_imgs)))
y_offset = 0
for img in gen_imgs:
combined_image.paste(img, (0, y_offset))
y_offset += img.height
img_byte_array = io.BytesIO()
combined_image.save(img_byte_array, format="PNG")
img_byte_array = img_byte_array.getvalue()
image_base64 = base64.b64encode(img_byte_array).decode('utf-8')
ego_pose = cur_data['param']['metas']['ego_pos']
Expand Down

0 comments on commit ff13cfb

Please sign in to comment.