当前位置:网站首页>pychrm社区版调用matplotlib.pyplot.imshow()函数图像不弹出的解决方法
pychrm社区版调用matplotlib.pyplot.imshow()函数图像不弹出的解决方法
2022-07-06 11:02:00 【--吉择--】
前言
学习吴恩达老师的deeplearningai课程,完成第二周编程作业二,想自己在pycharm中重新写一遍代码,发现加载完数据集后图像不显示。
环境
win10
anaconda3
python3.8
pychrm-community-2022.1.3
解决方法
方法一:
导入pylab库(pylab是matplotlib中的一个模块,直接导入即可。)
在plt.imshow(train_set_x_orig[index])后加一句pylab.show()
import numpy as np
from matplotlib import pyplot as plt
import h5py
import scipy
from PIL import Image
from scipy import ndimage
import scipy.misc
import pylab
def load_dataset():
train_dataset = h5py.File('datasets/train_catvnoncat.h5', "r")
train_set_x_orig = np.array(train_dataset["train_set_x"][:]) # your train set features
train_set_y_orig = np.array(train_dataset["train_set_y"][:]) # your train set labels
test_dataset = h5py.File('datasets/test_catvnoncat.h5', "r")
test_set_x_orig = np.array(test_dataset["test_set_x"][:]) # your test set features
test_set_y_orig = np.array(test_dataset["test_set_y"][:]) # your test set labels
classes = np.array(test_dataset["list_classes"][:]) # the list of classes
train_set_y_orig = train_set_y_orig.reshape((1, train_set_y_orig.shape[0]))
test_set_y_orig = test_set_y_orig.reshape((1, test_set_y_orig.shape[0]))
return train_set_x_orig, train_set_y_orig, test_set_x_orig, test_set_y_orig, classes
train_set_x_orig, train_set_y, test_set_x_orig, test_set_y, classes = load_dataset()
index = 5
plt.imshow(train_set_x_orig[index])
pylab.show()
print("y = " + str(train_set_y[:, index]) + ", it's a '" + classes[np.squeeze(train_set_y[:, index])].decode(
"utf-8") + "' picture.")

方法二:
在plt.imshow(train_set_x_orig[index])后加一句plt.show()
PS
- 网上有中解决方法是pycharm–>File | Settings | Tools | Python Scientific | 取消勾选Show plots in tool window,但我的pycharm里根本没有Python Scientific这个选项
- pycharm使用plt不显示图片解决方案
这篇博客解释了为什么在jupyter中可以显示而pycharm中不可以显示。 - 感觉中科大的镜像源蛮好用
pip3 install -i https://pypi.mirrors.ustc.edu.cn/simple/ pylab
边栏推荐
- epoll()无论涉及wait队列分析
- How does crmeb mall system help marketing?
- 2022-2024年CIFAR Azrieli全球学者名单公布,18位青年学者加入6个研究项目
- [depth first search] Ji suanke: Square
- Interpreting cloud native technology
- Cocos2d Lua smaller and smaller sample memory game
- About NPM install error 1
- Jushan database was among the first batch of financial information innovation solutions!
- openmv4 学习笔记1----一键下载、图像处理背景知识、LAB亮度-对比度
- 一种用于夜间和无袖测量血压手臂可穿戴设备【翻译】
猜你喜欢

CSRF vulnerability analysis
![[Sun Yat sen University] information sharing of postgraduate entrance examination and re examination](/img/a8/41e62a7a8d0a2e901e06c751c30291.jpg)
[Sun Yat sen University] information sharing of postgraduate entrance examination and re examination
![[the 300th weekly match of leetcode]](/img/a7/16b491656863e2c423ff657ac6e9c5.png)
[the 300th weekly match of leetcode]

Handwritten online chat system (principle part 1)

Summary of performance knowledge points
![Noninvasive and cuff free blood pressure measurement for telemedicine [translation]](/img/56/8deaec18cd9f2cf49ff234b09b1283.png)
Noninvasive and cuff free blood pressure measurement for telemedicine [translation]

Introduction and case analysis of Prophet model

Execution process of MySQL query request - underlying principle

Understanding disentangling in β- VAE paper reading notes
![Estimate blood pressure according to PPG using spectral spectrum time depth neural network [turn]](/img/f2/194ae452609d3e474b7b580d61bf4f.png)
Estimate blood pressure according to PPG using spectral spectrum time depth neural network [turn]
随机推荐
Splay
徐翔妻子应莹回应“股评”:自己写的!
图片缩放中心
青龙面板最近的库
十、进程管理
测试行业的小伙伴,有问题可以找我哈。菜鸟一枚~
44所高校入选!分布式智能计算项目名单公示
POJ 2208 six lengths of tetrahedron are known, and the volume is calculated
监控界的最强王者,没有之一!
基于ppg和fft神经网络的光学血压估计【翻译】
Crawling data encounters single point login problem
Estimate blood pressure according to PPG using spectral spectrum time depth neural network [turn]
使用cpolar建立一个商业网站(1)
Implementation of AVL tree
[matlab] Simulink the input and output variables of the same module cannot have the same name
AcWing 3537. Tree lookup complete binary tree
[the 300th weekly match of leetcode]
Noninvasive and cuff free blood pressure measurement for telemedicine [translation]
With the implementation of MapReduce job de emphasis, a variety of output folders
Penetration test information collection - WAF identification