Skip to content

Commit

Permalink
Lazy import some modules
Browse files Browse the repository at this point in the history
  • Loading branch information
nv-hwoo committed Jul 15, 2024
1 parent 1ecca60 commit 68bacca
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/c++/perf_analyzer/genai-perf/genai_perf/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,8 @@
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

import base64
import json
from enum import Enum
from io import BytesIO
from pathlib import Path
from typing import Any, Dict, List, Optional, Type

Expand All @@ -39,6 +37,10 @@

def encode_image(img: Image, format: str):
"""Encodes an image into base64 encoding."""
# Lazy import for vision related endpoints
import base64
from io import BytesIO

buffered = BytesIO()
img.save(buffered, format=format)
return base64.b64encode(buffered.getvalue()).decode("utf-8")
Expand Down

0 comments on commit 68bacca

Please sign in to comment.