p1atdev commited on
Commit
aa50ee2
1 Parent(s): bc9c134

fix: use AutoImageProcessor

Browse files
Files changed (1) hide show
  1. app.py +3 -3
app.py CHANGED
@@ -5,7 +5,7 @@ import numpy as np
5
  import torch
6
 
7
  from transformers import (
8
- AutoProcessor,
9
  )
10
 
11
  import gradio as gr
@@ -20,7 +20,7 @@ EXAMPLES = [["./images/sample.jpg"], ["./images/sample2.webp"]]
20
 
21
  model = SiglipForImageClassification.from_pretrained(MODEL_NAME, token=HF_TOKEN)
22
  # model = torch.compile(model)
23
- processor = AutoProcessor.from_pretrained(PROCESSOR_NAME, token=HF_TOKEN)
24
 
25
 
26
  def compose_text(results: dict[str, float], threshold: float = 0.3):
@@ -35,7 +35,7 @@ def compose_text(results: dict[str, float], threshold: float = 0.3):
35
 
36
  @torch.no_grad()
37
  def predict_tags(image: Image.Image, threshold: float):
38
- inputs = processor(images=image, return_tensors="pt")
39
 
40
  logits = model(**inputs.to(model.device, model.dtype)).logits.detach().cpu()
41
 
 
5
  import torch
6
 
7
  from transformers import (
8
+ AutoImageProcessor,
9
  )
10
 
11
  import gradio as gr
 
20
 
21
  model = SiglipForImageClassification.from_pretrained(MODEL_NAME, token=HF_TOKEN)
22
  # model = torch.compile(model)
23
+ processor = AutoImageProcessor.from_pretrained(PROCESSOR_NAME, token=HF_TOKEN)
24
 
25
 
26
  def compose_text(results: dict[str, float], threshold: float = 0.3):
 
35
 
36
  @torch.no_grad()
37
  def predict_tags(image: Image.Image, threshold: float):
38
+ inputs = processor(image, return_tensors="pt")
39
 
40
  logits = model(**inputs.to(model.device, model.dtype)).logits.detach().cpu()
41