Skip to content

Commit

Permalink
backend: fix lint issues
Browse files Browse the repository at this point in the history
  • Loading branch information
Nuullll committed Nov 15, 2024
1 parent 382c04c commit 3ae9852
Show file tree
Hide file tree
Showing 9 changed files with 10 additions and 13 deletions.
2 changes: 1 addition & 1 deletion service/device_detect.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import torch
import intel_extension_for_pytorch as ipex
import intel_extension_for_pytorch as ipex # noqa: F401

# filter out non-Arc devices
supported_ids = []
Expand Down
6 changes: 3 additions & 3 deletions service/inpaint_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -164,11 +164,11 @@ def __transparent_back(img: Image.Image):
:return: 返回替换白色后的透明图
"""
img = img.convert("RGBA")
L, H = img.size
W, H = img.size
color_0 = (255, 255, 255, 255) # 要替换的颜色
for h in range(H):
for l in range(L):
dot = (l, h)
for w in range(W):
dot = (w, h)
color_1 = img.getpixel(dot)
if color_1 == color_0:
color_1 = color_1[:-1] + (0,)
Expand Down
1 change: 0 additions & 1 deletion service/llm_biz.py
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,6 @@ def chat(
is_first = True
first_token_time = 0
last_token_time = 0
total_time = 0
with torch.inference_mode():
all_stream_output = ""
for stream_output in generate(
Expand Down
2 changes: 1 addition & 1 deletion service/model_downloader.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ def __init__(self, hf_token=None) -> None:
def is_gated(self, repo_id: str):
try:
info = model_info(repo_id)
return info.gated != False
return info.gated
except Exception as ex:
print(f"Error while trying to determine whether {repo_id} is gated: {ex}")
return False
Expand Down
4 changes: 2 additions & 2 deletions service/outpaint_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ def outpaint_canny_gradient(
left_pad: int,
right_pad: int,
):
if type(image) == Image.Image:
if isinstance(image, Image.Image):
img_ndata = np.array(image)
else:
img_ndata = image
Expand Down Expand Up @@ -119,7 +119,7 @@ def outpaint_canny_blur(
left_pad: int,
right_pad: int,
):
if type(image) == Image.Image:
if isinstance(image, Image.Image):
img_ndata = np.array(image)
else:
img_ndata = image
Expand Down
1 change: 0 additions & 1 deletion service/real_esrgan_patch.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import os
import sys

def patch_import(file_path):
Expand Down
1 change: 0 additions & 1 deletion service/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,6 @@ def get_ESRGAN_size():


def get_support_graphics(env_type: str):
import re
import model_config

device_count = torch.xpu.device_count()
Expand Down
4 changes: 2 additions & 2 deletions service/web_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,15 @@
# Set the environment variable to filter devices
os.environ["ONEAPI_DEVICE_SELECTOR"] = f"*:{supported_ids}"
print(f"Set ONEAPI_DEVICE_SELECTOR={os.environ['ONEAPI_DEVICE_SELECTOR']}")
except:
except: # noqa: E722
pass

# Credit to https://github.com/AUTOMATIC1111/stable-diffusion-webui/pull/14186
# Related issues:
# + https://github.com/XPixelGroup/BasicSR/issues/649
# + https://github.com/AUTOMATIC1111/stable-diffusion-webui/issues/13985
try:
import torchvision.transforms.functional_tensor
import torchvision.transforms.functional_tensor # noqa: F401
except ImportError:
try:
import torchvision.transforms.functional as functional
Expand Down
2 changes: 1 addition & 1 deletion service/xpu_hijacks.py
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ def torch_empty(*args, device=None, **kwargs):
original_torch_randn = torch.randn
@wraps(torch.randn)
def torch_randn(*args, device=None, dtype=None, **kwargs):
if dtype == bytes:
if dtype == bytes: # noqa: E721
dtype = None
if check_device(device):
return original_torch_randn(*args, device=return_xpu(device), **kwargs)
Expand Down

0 comments on commit 3ae9852

Please sign in to comment.