图像赢得';t在dash-python中加载
我在我的应用程序中创建了一个if语句来加载图像。如果情感为回调的==值,则在应用程序中加载图像图像赢得';t在dash-python中加载,python,html,if-statement,dashboard,Python,Html,If Statement,Dashboard,我在我的应用程序中创建了一个if语句来加载图像。如果情感为回调的==值,则在应用程序中加载图像 # load image for sentiment if overall_sentiment == "fear": image_filename = "fear.png" image = base64.b64encode(open(image_filename, 'rb').read()).decode('ascii') if overall_se
# load image for sentiment
if overall_sentiment == "fear":
image_filename = "fear.png"
image = base64.b64encode(open(image_filename, 'rb').read()).decode('ascii')
if overall_sentiment == "sadness":
image_filename = "sadness.png"
image = base64.b64encode(open(image_filename, 'rb').read()).decode('ascii')
if overall_sentiment == "anger":
image_filename = "anger.png"
image = base64.b64encode(open(image_filename, 'rb').read()).decode('ascii')
if overall_sentiment == "disgust":
image_filename = "disgust.png"
image = base64.b64encode(open(image_filename, 'rb').read()).decode('ascii')
if overall_sentiment == "enjoyment":
image_filename = "enjoyment"
image = base64.b64encode(open(image_filename, 'rb').read()).decode('ascii')
我在我的应用程序中加载图像,如下所示:
html.Img(
html.H4("Overall sentiment"),
id ="overall_sentiment",
src='data:image/png;base64,{}'.format(image)
)])
由于某些原因,图像将不会显示