Update app.py
Browse files
app.py
CHANGED
@@ -6,7 +6,7 @@ import scipy
|
|
6 |
from PIL import Image
|
7 |
import torch.nn as nn
|
8 |
from transformers import Blip2Processor, Blip2ForConditionalGeneration, InstructBlipProcessor, InstructBlipForConditionalGeneration
|
9 |
-
from my_model.object_detection import
|
10 |
|
11 |
def load_caption_model(blip2=False, instructblip=True):
|
12 |
|
@@ -96,15 +96,12 @@ def perform_object_detection(image, model_name, threshold):
|
|
96 |
PIL.Image, str: The image with drawn bounding boxes and a string of detected objects.
|
97 |
"""
|
98 |
|
99 |
-
# Initialize the ObjectDetector
|
100 |
-
detector = ObjectDetector()
|
101 |
-
# Load the specified model
|
102 |
-
detector.load_model(model_name)
|
103 |
|
104 |
try:
|
105 |
# Perform object detection and draw bounding boxes
|
106 |
-
processed_image, detected_objects =
|
107 |
st.write("66666666666666")
|
|
|
108 |
return processed_image, detected_objects
|
109 |
except Exception as e:
|
110 |
# Print the error for debugging
|
|
|
6 |
from PIL import Image
|
7 |
import torch.nn as nn
|
8 |
from transformers import Blip2Processor, Blip2ForConditionalGeneration, InstructBlipProcessor, InstructBlipForConditionalGeneration
|
9 |
+
from my_model.object_detection import detect_and_draw_objects
|
10 |
|
11 |
def load_caption_model(blip2=False, instructblip=True):
|
12 |
|
|
|
96 |
PIL.Image, str: The image with drawn bounding boxes and a string of detected objects.
|
97 |
"""
|
98 |
|
|
|
|
|
|
|
|
|
99 |
|
100 |
try:
|
101 |
# Perform object detection and draw bounding boxes
|
102 |
+
processed_image, detected_objects = detect_and_draw_objects(image, model_name, threshold)
|
103 |
st.write("66666666666666")
|
104 |
+
st.write(detected_objects[:20])
|
105 |
return processed_image, detected_objects
|
106 |
except Exception as e:
|
107 |
# Print the error for debugging
|