Origin code for loading the image. Args: image_file (str): the path or the url of the image. Note we didn't do any resize action here. Returns: Image: the Image class.
(image_file: str)
| 465 | """ |
| 466 | |
| 467 | def load_image(image_file: str) -> Image: |
| 468 | """ |
| 469 | Origin code for loading the image. |
| 470 | |
| 471 | Args: |
| 472 | image_file (str): the path or the url of the image. |
| 473 | |
| 474 | Note we didn't do any resize action here. |
| 475 | |
| 476 | Returns: |
| 477 | Image: the Image class. |
| 478 | """ |
| 479 | if image_file.startswith(("http://", "https://")): |
| 480 | response = requests.get(image_file) |
| 481 | image = Image.open(BytesIO(response.content)).convert("RGB") |
| 482 | else: |
| 483 | image = Image.open(image_file).convert("RGB") |
| 484 | return image |
| 485 | |
| 486 | image: Image = load_image(image_path) |
| 487 | instruction:str = episode['instruction'] |