isaiahkabraham commited on
Commit
f671c42
·
verified ·
1 Parent(s): 1833f28

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +46 -0
app.py ADDED
@@ -0,0 +1,46 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import comet_ml
2
+ comet_ml.init(anonymous=True, project_name="3: OWL-ViT + SAM")
3
+ exp = comet_ml.Experiment()
4
+ # To display the image
5
+ from PIL import Image
6
+ logged_artifact = exp.get_artifact("L3-data", "anmorgan24")
7
+ # Display the images
8
+ raw_image = Image.open("L3_data/dogs.jpg")
9
+ raw_image
10
+
11
+ from transformers import pipeline
12
+ OWL_checkpoint = "./models/google/owlvit-base-patch32"
13
+
14
+ # Load the model
15
+ detector = pipeline(
16
+ model= OWL_checkpoint,
17
+ task="zero-shot-object-detection"
18
+ )
19
+
20
+ # What you want to identify in the image
21
+ text_prompt = "dog"
22
+
23
+ output = detector(
24
+ raw_image,
25
+ candidate_labels = [text_prompt]
26
+ )
27
+
28
+ # Print the output to identify the bounding boxes detected
29
+ output
30
+
31
+ from utils import preprocess_outputs
32
+
33
+ input_scores, input_labels, input_boxes = preprocess_outputs(output)
34
+
35
+ from utils import show_boxes_and_labels_on_image
36
+
37
+ # Show the image with the bounding boxes
38
+ show_boxes_and_labels_on_image(
39
+ raw_image,
40
+ input_boxes[0],
41
+ input_labels,
42
+ input_scores
43
+ )
44
+
45
+ #Model distillation
46
+