Update app.py
Browse files
app.py
CHANGED
|
@@ -16,9 +16,6 @@ o1 = gr.outputs.Image()
|
|
| 16 |
o2 = gr.outputs.Textbox()
|
| 17 |
|
| 18 |
def extract_image(image, text, num=1):
|
| 19 |
-
|
| 20 |
-
feature_extractor = DetrFeatureExtractor.from_pretrained('facebook/detr-resnet-50')
|
| 21 |
-
dmodel = DetrForObjectDetection.from_pretrained('facebook/detr-resnet-50')
|
| 22 |
|
| 23 |
inputs = feature_extractor(images=image, return_tensors="pt")
|
| 24 |
outputs = dmodel(**inputs)
|
|
@@ -48,9 +45,9 @@ def extract_image(image, text, num=1):
|
|
| 48 |
|
| 49 |
images_list.append(roi_im)
|
| 50 |
|
| 51 |
-
|
| 52 |
-
|
| 53 |
-
logits_per_image =
|
| 54 |
probs = logits_per_image.softmax(-1)
|
| 55 |
l_idx = np.argsort(probs[-1].detach().numpy())[::-1][0:num]
|
| 56 |
|
|
|
|
| 16 |
o2 = gr.outputs.Textbox()
|
| 17 |
|
| 18 |
def extract_image(image, text, num=1):
|
|
|
|
|
|
|
|
|
|
| 19 |
|
| 20 |
inputs = feature_extractor(images=image, return_tensors="pt")
|
| 21 |
outputs = dmodel(**inputs)
|
|
|
|
| 45 |
|
| 46 |
images_list.append(roi_im)
|
| 47 |
|
| 48 |
+
inpu = processor(text = [text], images=images_list , return_tensors="pt", padding=True)
|
| 49 |
+
output = model(**inpu)
|
| 50 |
+
logits_per_image = output.logits_per_text
|
| 51 |
probs = logits_per_image.softmax(-1)
|
| 52 |
l_idx = np.argsort(probs[-1].detach().numpy())[::-1][0:num]
|
| 53 |
|