OmniParser icon indicating copy to clipboard operation
OmniParser copied to clipboard

Issue: Redundant Imports for torch and PIL.Image in gradio_demo.py

Open yabi90 opened this issue 3 months ago • 0 comments

Description:

In the current code, there are multiple imports of torch and PIL.Image. This redundancy can be eliminated by consolidating these imports into a single block to maintain cleaner code and improve readability.

Current Code:

from typing import Optional

import gradio as gr
import numpy as np
import torch
from PIL import Image
import io


import base64, os
from utils import check_ocr_box, get_yolo_model, get_caption_model_processor, get_som_labeled_img
import torch
from PIL import Image

Suggested Fix:

Consolidate the imports for torch and PIL.Image into a single block, as shown below:

from typing import Optional
import gradio as gr
import numpy as np
import io
import base64, os
from utils import check_ocr_box, get_yolo_model, get_caption_model_processor, get_som_labeled_img
import torch
from PIL import Image

Impact:

  • Reduced redundancy in imports.
  • Improved code clarity and maintainability.

yabi90 avatar Nov 17 '24 23:11 yabi90