Closed luomingshuang closed 1 year ago
@luomingshuang what is plot prediction function here ?
Please could you share your inference script.
def plot_prediction(image, scores, boxes, labels, ax=None, plot_prob=True, dataset='OWOD'):
if ax is None:
ax = plt.gca()
plot_results(image[0].permute(1, 2, 0).detach().cpu().numpy(), scores, boxes, labels, ax, plot_prob=plot_prob, dataset=dataset)
def plot_results(pil_img, scores, boxes, labels, ax, plot_prob=True, norm=True, dataset='OWOD'):
from matplotlib import pyplot as plt
h, w = pil_img.shape[:-1]
# w, h = pil_img.shape[:-1]
image = plot_image(ax, pil_img, norm)
colors = COLORS * 100
if boxes is not None:
# boxes = [rescale_bboxes(boxes[i], [w, h]).cpu() for i in range(len(boxes))]
for sc, cl, (xmin, ymin, xmax, ymax), c in zip(scores, labels, boxes, colors):
ax.add_patch(plt.Rectangle((xmin, ymin), xmax - xmin, ymax - ymin,
fill=False, color=c, linewidth=2))
text = f'{CLASSES[str(dataset)][cl]}: {sc:0.2f}'
ax.text(xmin, ymin, text, fontsize=5, bbox=dict(facecolor='yellow', alpha=0.5))
ax.grid('off')
Add rescale_boxes to viz:
probas = outputs['pred_logits'].softmax(-1)[0, :, :].cpu()
predicted_boxes = outputs['pred_boxes'][0,].cpu()
predicted_boxes = rescale_bboxes(predicted_boxes.cpu(), [w, h])
scores, predicted_boxes = filter_boxes(probas, predicted_boxes)
labels = scores.argmax(axis=1)
scores = scores.max(-1).values
Thank you so much @luomingshuang, really appreciate your quick response!
Em, but I think there are still some errors in my above codes for visualizing.
I am not able to generate the images that you have shown
how were you able to get those images, do I need to add viz to plot_utils.py?
You can have a reference about https://github.com/akshitac8/OW-DETR/blob/main/engine.py .
Thanks @luomingshuang will check it out
Hi @luomingshuang,
I believe I rejected proposals with high overlap with 'known' object predictions - it was my observation that known object were predicted with relatively high accuracy. Please note that you may lose some unknown object predictions in this case. Please note that the visualizations in the figures were not generated this way, but relied on the GT objects (See Issue #11).
If this is still an issue, please reopen and let me know what you need help with,
Best, Orr
@ae208gpu @luomingshuang Did you solve it? Can you share the visualization code?
Do we need to change the content of EVAL_M_OWOD_BENCHMARK.sh ?
I am getting this
Initialized from the pre-training model
Hi, @orrzohar , thanks for your great job. Here, I have some questions about visualization for known and unknown objects.
My codes for visualization as follows:
There are some results for visualization: when I set
probas = outputs['pred_logits'].softmax(-1)[0, :, :-1].cpu()
, (In this case, there will be just known objects (because it just considers 0-79 known classes.)):when I set
probas = outputs['pred_logits'].softmax(-1)[0, :, :].cpu()
, (In this case, there will be known and unknown objects (because it just considers 0-80 known classes.)):When I show the boxes of known and unknown objects in the picture, we can see that there are many overlap boxes on known objects and many boxes which are not objectness, so can you tell me how to modify the code and make it normal?