merve HF staff commited on
Commit
d2b0ea9
1 Parent(s): e0de7f3

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -0
app.py CHANGED
@@ -19,6 +19,11 @@ device = torch.device('cuda' if torch.cuda.is_available() else "cpu")
19
  processor = AutoProcessor.from_pretrained("nielsr/siglip-base-patch16-224")
20
  model = SiglipModel.from_pretrained("nielsr/siglip-base-patch16-224").to(device)
21
 
 
 
 
 
 
22
  def extract_features_siglip(image):
23
  with torch.no_grad():
24
  inputs = processor(images=image, return_tensors="pt").to(device)
 
19
  processor = AutoProcessor.from_pretrained("nielsr/siglip-base-patch16-224")
20
  model = SiglipModel.from_pretrained("nielsr/siglip-base-patch16-224").to(device)
21
 
22
+ def read_image_from_url(url):
23
+ response = requests.get(url)
24
+ img = Image.open(BytesIO(response.content)).convert("RGB")
25
+ return img
26
+
27
  def extract_features_siglip(image):
28
  with torch.no_grad():
29
  inputs = processor(images=image, return_tensors="pt").to(device)