diegokauer commited on
Commit
04f5b7c
·
1 Parent(s): a01acdf

Update model.py

Browse files
Files changed (1) hide show
  1. model.py +4 -9
model.py CHANGED
@@ -3,7 +3,6 @@ import logging
3
  import torch
4
  import datetime
5
  import requests
6
- from io import BytesIO
7
 
8
  from google.cloud import storage
9
  from transformers import AutoImageProcessor, AutoModelForObjectDetection
@@ -15,10 +14,6 @@ from PIL import Image
15
  from creds import get_credentials
16
 
17
 
18
- os.environ["GOOGLE_APPLICATION_CREDENTIALS"]= get_credentials()
19
- print("cred set")
20
-
21
-
22
  def generate_download_signed_url_v4(blob_name):
23
  """Generates a v4 signed URL for downloading a blob.
24
 
@@ -42,8 +37,8 @@ def generate_download_signed_url_v4(blob_name):
42
 
43
  print("Generated GET signed URL:")
44
  print(url)
45
- print("You can use this URL with any user agent, for example:")
46
- print(f"curl '{url}'")
47
  return url
48
 
49
 
@@ -61,8 +56,8 @@ class Model(LabelStudioMLBase):
61
 
62
 
63
  url = task["data"]["image"]
64
- response = requests.get(generate_download_signed_url_v4(url))
65
- image = Image.open(BytesIO(response.content))
66
  original_width, original_height = image.size
67
  with torch.no_grad():
68
 
 
3
  import torch
4
  import datetime
5
  import requests
 
6
 
7
  from google.cloud import storage
8
  from transformers import AutoImageProcessor, AutoModelForObjectDetection
 
14
  from creds import get_credentials
15
 
16
 
 
 
 
 
17
  def generate_download_signed_url_v4(blob_name):
18
  """Generates a v4 signed URL for downloading a blob.
19
 
 
37
 
38
  print("Generated GET signed URL:")
39
  print(url)
40
+ # print("You can use this URL with any user agent, for example:")
41
+ # print(f"curl '{url}'")
42
  return url
43
 
44
 
 
56
 
57
 
58
  url = task["data"]["image"]
59
+ image = Image.open(requests.get(url, stream=True).raw)
60
+
61
  original_width, original_height = image.size
62
  with torch.no_grad():
63