lobe / lobe-python

Python toolset for working with Lobe models
MIT License
185 stars 38 forks source link

Heatmap is not displayed #36

Open okamura-6880 opened 1 year ago

okamura-6880 commented 1 year ago

The visualization is done using a model created in Lobe. I tried to get a heatmap using the usage code but what was displayed was a slightly darkened original image.

from lobe import ImageModel from PIL import Image import os import sys os.environ["CUDA_VISIBLE_DEVICES"] = "-1" mePath = os.path.dirname(file) model = ImageModel.load('path/to/exported/model/folder') img = Image.open('path/to/file.jpg') result = model.predict(img) img.show()

print(result.prediction)

for label, confidence in result.labels: print(f"{label}: {confidence*100}%")

heatmap = model.visualize(img) heatmap.show()

I added a sentence to display heatmap_img at line 162 of image_model.py to test it, and found that heatmap_img was completely dark.

heatmap_img = heatmap_img.resize((height, width)) heatmap_img .show()