sergioska commited on
Commit
c9efb0d
·
1 Parent(s): ab53b8d

trying zero object detection

Browse files
Files changed (1) hide show
  1. app.py +3 -2
app.py CHANGED
@@ -1,6 +1,6 @@
1
  import streamlit as st
2
  import torch
3
- # Load model directly
4
  from transformers import pipeline, OwlViTProcessor, OwlViTForObjectDetection
5
  from tempfile import NamedTemporaryFile
6
 
@@ -40,7 +40,8 @@ if uploaded_image_zero_file is not None:
40
  with NamedTemporaryFile() as temp:
41
  temp.write(uploaded_image_zero_file.getvalue())
42
  temp.seek(0)
43
- image = temp.name;
 
44
  inputs = processor(text=texts, images=image, return_tensors="pt")
45
  outputs = model(**inputs)
46
  target_sizes = torch.Tensor([image.size[::-1]])
 
1
  import streamlit as st
2
  import torch
3
+ from PIL import Image
4
  from transformers import pipeline, OwlViTProcessor, OwlViTForObjectDetection
5
  from tempfile import NamedTemporaryFile
6
 
 
40
  with NamedTemporaryFile() as temp:
41
  temp.write(uploaded_image_zero_file.getvalue())
42
  temp.seek(0)
43
+ image = Image.open(temp.name)
44
+ st.image(image)
45
  inputs = processor(text=texts, images=image, return_tensors="pt")
46
  outputs = model(**inputs)
47
  target_sizes = torch.Tensor([image.size[::-1]])