Skip to content

Commit

Permalink
Fix: linter format
Browse files Browse the repository at this point in the history
  • Loading branch information
geminixiang committed Sep 3, 2023
1 parent e360d31 commit 4cc1eff
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 5 deletions.
2 changes: 0 additions & 2 deletions huggingface/__init__.py
Original file line number Diff line number Diff line change
@@ -1,2 +0,0 @@
from .blip_image_captioning_large import blip_image_captioning_large
from .yolos_tiny import yolos_tiny
1 change: 0 additions & 1 deletion huggingface/blip_image_captioning_large.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import requests
import torch
from loguru import logger
from PIL import Image
from transformers import BlipForConditionalGeneration, BlipProcessor
Expand Down
9 changes: 7 additions & 2 deletions huggingface/yolos_tiny.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,19 @@ def yolos_tiny(url: str) -> ObjectDetectionResult:
Returns:
ObjectDetectionResult: object detection result
"""
model = YolosForObjectDetection.from_pretrained("hustvl/yolos-tiny").to(settings.compute_mode)
model = YolosForObjectDetection.from_pretrained(
"hustvl/yolos-tiny"
).to(settings.compute_mode)
image_processor = YolosImageProcessor.from_pretrained(
"hustvl/yolos-tiny", torch_dtype=torch.float16
)

image = Image.open(requests.get(url, stream=True).raw)
logger.info(f"Downloaded image from {url}")
inputs = image_processor(images=image, return_tensors="pt").to(settings.compute_mode) # type: ignore
inputs = image_processor(
images=image,
return_tensors="pt"
).to(settings.compute_mode) # type: ignore
outputs = model(**inputs) # type: ignore

target_sizes = torch.tensor([image.size[::-1]])
Expand Down

0 comments on commit 4cc1eff

Please sign in to comment.