• [问题求助] CPU:2核心8GB 使用conda创建虚拟Python环境会有很大的几率失败,报错如下:(大于此规格目前正常)
    /home/ma-user/anaconda3/lib/python3.7/site-packages/requests/__init__.py:91: RequestsDependencyWarning: urllib3 (1.26.12) or chardet (3.0.4) doesn't match a supported version! RequestsDependencyWarning) Collecting package metadata (current_repodata.json): done Solving environment: failed with repodata from current_repodata.json, will retry with next repodata source. Collecting package metadata (repodata.json): failed # >>>>>>>>>>>>>>>>>>>>>> ERROR REPORT <<<<<<<<<<<<<<<<<<<<<< Traceback (most recent call last): File "/home/ma-user/anaconda3/lib/python3.7/site-packages/urllib3/response.py", line 443, in _error_catcher yield File "/home/ma-user/anaconda3/lib/python3.7/site-packages/urllib3/response.py", line 818, in read_chunked chunk = self._handle_chunk(amt) File "/home/ma-user/anaconda3/lib/python3.7/site-packages/urllib3/response.py", line 762, in _handle_chunk value = self._fp._safe_read(amt) File "/home/ma-user/anaconda3/lib/python3.7/http/client.py", line 622, in _safe_read raise IncompleteRead(b''.join(s), amt) http.client.IncompleteRead: IncompleteRead(4223 bytes read, 6017 more expected) During handling of the above exception, another exception occurred: Traceback (most recent call last): File "/home/ma-user/anaconda3/lib/python3.7/site-packages/requests/models.py", line 750, in generate for chunk in self.raw.stream(chunk_size, decode_content=True): File "/home/ma-user/anaconda3/lib/python3.7/site-packages/urllib3/response.py", line 623, in stream for line in self.read_chunked(amt, decode_content=decode_content): File "/home/ma-user/anaconda3/lib/python3.7/site-packages/urllib3/response.py", line 844, in read_chunked self._original_response.close() File "/home/ma-user/anaconda3/lib/python3.7/contextlib.py", line 130, in __exit__ self.gen.throw(type, value, traceback) File "/home/ma-user/anaconda3/lib/python3.7/site-packages/urllib3/response.py", line 460, in _error_catcher raise ProtocolError("Connection broken: %r" % e, e) urllib3.exceptions.ProtocolError: ('Connection broken: IncompleteRead(4223 bytes read, 6017 more expected)', IncompleteRead(4223 bytes read, 6017 more expected)) During handling of the above exception, another exception occurred: Traceback (most recent call last): File "/home/ma-user/anaconda3/lib/python3.7/site-packages/conda/exceptions.py", line 1079, in __call__ return func(*args, **kwargs) File "/home/ma-user/anaconda3/lib/python3.7/site-packages/conda/cli/main.py", line 84, in _main exit_code = do_call(args, p) File "/home/ma-user/anaconda3/lib/python3.7/site-packages/conda/cli/conda_argparse.py", line 82, in do_call return getattr(module, func_name)(args, parser) File "/home/ma-user/anaconda3/lib/python3.7/site-packages/conda/cli/main_create.py", line 37, in execute install(args, parser, 'create') File "/home/ma-user/anaconda3/lib/python3.7/site-packages/conda/cli/install.py", line 265, in install should_retry_solve=(_should_retry_unfrozen or repodata_fn != repodata_fns[-1]), File "/home/ma-user/anaconda3/lib/python3.7/site-packages/conda/core/solve.py", line 117, in solve_for_transaction should_retry_solve) File "/home/ma-user/anaconda3/lib/python3.7/site-packages/conda/core/solve.py", line 158, in solve_for_diff force_remove, should_retry_solve) File "/home/ma-user/anaconda3/lib/python3.7/site-packages/conda/core/solve.py", line 262, in solve_final_state ssc = self._collect_all_metadata(ssc) File "/home/ma-user/anaconda3/lib/python3.7/site-packages/conda/common/io.py", line 88, in decorated return f(*args, **kwds) File "/home/ma-user/anaconda3/lib/python3.7/site-packages/conda/core/solve.py", line 415, in _collect_all_metadata index, r = self._prepare(prepared_specs) File "/home/ma-user/anaconda3/lib/python3.7/site-packages/conda/core/solve.py", line 1011, in _prepare self.subdirs, prepared_specs, self._repodata_fn) File "/home/ma-user/anaconda3/lib/python3.7/site-packages/conda/core/index.py", line 228, in get_reduced_index repodata_fn=repodata_fn) File "/home/ma-user/anaconda3/lib/python3.7/site-packages/conda/core/subdir_data.py", line 105, in query_all result = tuple(concat(executor.map(subdir_query, channel_urls))) File "/home/ma-user/anaconda3/lib/python3.7/concurrent/futures/_base.py", line 598, in result_iterator yield fs.pop().result() File "/home/ma-user/anaconda3/lib/python3.7/concurrent/futures/_base.py", line 435, in result return self.__get_result() File "/home/ma-user/anaconda3/lib/python3.7/concurrent/futures/_base.py", line 384, in __get_result raise self._exception File "/home/ma-user/anaconda3/lib/python3.7/concurrent/futures/thread.py", line 57, in run result = self.fn(*self.args, **self.kwargs) File "/home/ma-user/anaconda3/lib/python3.7/site-packages/conda/core/subdir_data.py", line 98, in <lambda> package_ref_or_match_spec)) File "/home/ma-user/anaconda3/lib/python3.7/site-packages/conda/core/subdir_data.py", line 110, in query self.load() File "/home/ma-user/anaconda3/lib/python3.7/site-packages/conda/core/subdir_data.py", line 174, in load _internal_state = self._load() File "/home/ma-user/anaconda3/lib/python3.7/site-packages/conda/core/subdir_data.py", line 248, in _load repodata_fn=self.repodata_fn) File "/home/ma-user/anaconda3/lib/python3.7/site-packages/conda/core/subdir_data.py", line 485, in fetch_repodata_remote_request timeout=timeout) File "/home/ma-user/anaconda3/lib/python3.7/site-packages/requests/sessions.py", line 546, in get return self.request('GET', url, **kwargs) File "/home/ma-user/anaconda3/lib/python3.7/site-packages/requests/sessions.py", line 533, in request resp = self.send(prep, **send_kwargs) File "/home/ma-user/anaconda3/lib/python3.7/site-packages/requests/sessions.py", line 686, in send r.content File "/home/ma-user/anaconda3/lib/python3.7/site-packages/requests/models.py", line 828, in content self._content = b''.join(self.iter_content(CONTENT_CHUNK_SIZE)) or b'' File "/home/ma-user/anaconda3/lib/python3.7/site-packages/requests/models.py", line 753, in generate raise ChunkedEncodingError(e) requests.exceptions.ChunkedEncodingError: ('Connection broken: IncompleteRead(4223 bytes read, 6017 more expected)', IncompleteRead(4223 bytes read, 6017 more expected)) `$ /home/ma-user/anaconda3/bin/conda create -n py36 python=3.6.10 -y` environment variables: CIO_TEST=<not set> CONDA_DIR=/modelarts/authoring/notebook-conda CONDA_ROOT=/home/ma-user/anaconda3 FTP_PROXY=<set> HTTPS_PROXY=<set> HTTP_PROXY=<set> LD_LIBRARY_PATH=/usr/local/cuda/lib64:/usr/local/cuda/extras/CUPTI/lib64:/usr/local/nv idia/lib:/usr/local/nvidia/lib64:/usr/lib/x86_64-linux-gnu/ LIBRARY_PATH=/usr/local/cuda/lib64/stubs: MODELARTS_MODEL_PATH=/home/ma-user/infer/model/1 NO_PROXY=<set> PATH=/home/ma-user/anaconda3/envs/TensorFlow-2.1/bin:/home/ma-user/anaconda 3/envs/TensorFlow-2.1/bin:/usr/local/openmpi/bin:/usr/local/nvidia/bin :/usr/local/cuda/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin :/sbin:/bin:/modelarts/authoring/notebook-conda/bin:/home/ma- user/modelarts-dev/ma- cli/bin:/modelarts/authoring/script/entrypoint/deps/ssh/bin:/home/ma- user/anaconda3/envs/TensorFlow-2.1/bin PYTHONPATH=/usr/local/seccomponent/lib:/home/ma-user/infer/model/1 REQUESTS_CA_BUNDLE=<not set> SCC_CONFIG_PATH=/home/ma-user/scc/kmc.conf SITE_PACKAGES_PATH=/home/ma-user/anaconda3/envs/TensorFlow-2.1/lib/python3.7/site- packages SSL_CERT_FILE=<not set> ftp_proxy=<set> http_proxy=<set> https_proxy=<set> no_proxy=<set> active environment : None user config file : /home/ma-user/.condarc populated config files : /home/ma-user/.condarc conda version : 4.8.2 conda-build version : not installed python version : 3.7.6.final.0 virtual packages : __glibc=2.27 base environment : /home/ma-user/anaconda3 (writable) channel URLs : cid:link_0 cid:link_2 cid:link_1 cid:link_3 cid:link_4 cid:link_5 cid:link_6 cid:link_7 package cache : /home/ma-user/anaconda3/pkgs /home/ma-user/.conda/pkgs envs directories : /home/ma-user/anaconda3/envs /home/ma-user/.conda/envs platform : linux-64 user-agent : conda/4.8.2 requests/2.22.0 CPython/3.7.6 Linux/4.18.0-147.5.1.6.h841.eulerosv2r9.x86_64 ubuntu/18.04.6 glibc/2.27 UID:GID : 1000:100 netrc file : None offline mode : False An unexpected error has occurred. Conda has prepared the above report.
  • [开发环境] [Notebook] notebook上如何用GPU训练
    训练yolov7,device输入参数默认是cpu,在cpu上训练。想改用GPU,device参数改成0,但是notebook运行报了错:请问可怎么解决?
  • [开发环境] 使用ma-cli进行镜像构建报错:connection error
    命令和报错信息: (python-3.7.10) [ma-user work]$ma-cli image build .ma/customize_from_ubuntu_18.04_to_modelarts/Dockerfile -swr hw03426922/only-conda:0.0.1 [+] Building 0.0s (0/0) error: failed to get status: rpc error: code = Unavailable desc = connection error: desc = "transport: error while dialing: dial tcp 127.0.0.1:1234: connect: connection refused"   Failed to build image, for details, see /home/ma-user/work/.ma/customize_from_ubuntu_18.04_to_modelarts/build_log.log. [ FAILED ] Build image hw03426922/only-conda:0.0.1 failed! 这是为什么呢?
  • [开发环境] notebook里如何修改Ctrl-B快捷键的行为?
    在Notebook里开了一个teminal, 然后打开了vim用Ctrl-F是往下翻页当想用Ctrl-B向上翻页时,发现是切换文件浏览器的隐藏和显示,所以,notebook里如何修改Ctrl-B快捷键的行为?
  • [技术干货] 情人节季,快来上传你的女神照片,测试下你们的夫妻相
    情人节季,快来上传你的女神照片,测试下你们的夫妻相有没有夫妻相?刷一下脸就知道!“夫妻相”是指两人之间的相貌让人感觉是一对夫妻,还有一种说法是指夫妻之间面容相似。有研究认为:两个人在一起生活得久了,表情动作彼此模仿,会越来越像。其实是因为大多数人都珍爱自己,看到跟自己相像的人格外顺眼,从一开头就是拿自己当范本选择另一半。“夫妻相”的大抵意思是因为常常接触,心灵相倾,习惯趋同,相同的作息、肠道菌落交换等相互影响,以致到了面容相像。夫妻相是面容相像,心灵相倾,习惯趋同,相互影响。世界各地都有类似的说法:人们容易被面容与自己有共同之处的人吸引。一些进化生物学家认为,这是因为我们潜意识里觉得,与自己长相相似的人更值得信任。然而也有研究表明,当动物处于压力下,它们更倾向与同伴中遗传距离较远的个体交配。尽管上述描述在当今心理学、生物学方面有争议,但是大多数人还是比较认同“夫妻相”这一说法的。(以上“夫妻相”解释来自百度百科)基于此,本文利用ssim算法,帮你快速打造一个“刷脸测试夫妻相”Demo出来。夫妻相似度 ssim算法原理SSIM(structural similarity)是一种用来衡量图片相似度的指标,也可用来判断图片压缩后的质量。基本原理:其中有几个需要注意的点:C1、C2、C3为常数,避免分母接近于0时造成的不稳定性。SSIM函数S具有对称性、有界性(不超过1)和最大值唯一性(当且仅当x=y时,S=1,表示两幅图一样)。上述S函数为C3=C2/2的简化形式。(更多SSIM介绍可自行搜索论文《Image Quality Assessment: From Error Visibility to Structural Similarity》)注意事项:本案例使用框架**:** PyTorch-1.8本案例使用硬件规格**:** CPU: 2核 4GB本案例的AI Gallery链接 上传你的女神照片,测试下你们的夫妻相步骤一:下载需要的海报文件和字体import os import os.path as osp import moxing as mox parent = osp.join(os.getcwd(),'Valentine') if not os.path.exists(parent): mox.file.copy_parallel('obs://modelarts-labs-bj4-v2/case_zoo/Valentine',parent) if os.path.exists(parent): print('Download success') else: raise Exception('Download Failed') else: print("Model Package already exists!") INFO:root:Using MoXing-v2.1.0.5d9c87c8-5d9c87c8 INFO:root:Using OBS-Python-SDK-3.20.9.1 Download success步骤二:使用ssim算法计算夫妻相import numpy as np import cv2 import random import matplotlib.pyplot as plt from matplotlib import font_manager import warnings from scipy.signal import convolve2d from PIL import Image,ImageDraw,ImageFont warnings.filterwarnings('ignore')def matlab_style_gauss2D(shape=(3,3),sigma=0.5): """ 2D gaussian mask - should give the same result as MATLAB's fspecial('gaussian',[shape],[sigma]) """ m,n = [(ss-1.)/2. for ss in shape] y,x = np.ogrid[-m:m+1,-n:n+1] h = np.exp( -(x*x + y*y) / (2.*sigma*sigma) ) h[ h < np.finfo(h.dtype).eps*h.max() ] = 0 sumh = h.sum() if sumh != 0: h /= sumh return h def filter2(x, kernel, mode='same'): return convolve2d(x, np.rot90(kernel, 2), mode=mode) def compute_ssim(im1, im2, k1=0.01, k2=0.04, win_size=11, L=255): if not im1.shape == im2.shape: raise ValueError("Input Imagees must have the same dimensions") if len(im1.shape) > 2: raise ValueError("Please input the images with 1 channel") M, N = im1.shape C1 = (k1*L)**2 C2 = (k2*L)**2 window = matlab_style_gauss2D(shape=(win_size,win_size), sigma=0.5) window = window/np.sum(np.sum(window)) if im1.dtype == np.uint8: im1 = np.double(im1) if im2.dtype == np.uint8: im2 = np.double(im2) mu1 = filter2(im1, window, 'valid') mu2 = filter2(im2, window, 'valid') mu1_sq = mu1 * mu1 mu2_sq = mu2 * mu2 mu1_mu2 = mu1 * mu2 sigma1_sq = filter2(im1*im1, window, 'valid') - mu1_sq sigma2_sq = filter2(im2*im2, window, 'valid') - mu2_sq sigmal2 = filter2(im1*im2, window, 'valid') - mu1_mu2 ssim_map = ((2*mu1_mu2+C1) * (2*sigmal2+C2)) / ((mu1_sq+mu2_sq+C1) * (sigma1_sq+sigma2_sq+C2)) return np.mean(np.mean(ssim_map)) def img_show(similarity, img1, img2, name1, name2): # similarity = random.uniform(60,100) zt = "./Valentine/方正兰亭准黑_GBK.ttf" my_font = font_manager.FontProperties(fname = zt,size =20 ) img1 = cv2.resize(img1, (520, 520)) img2 = cv2.resize(img2, (520, 520)) imgs = np.hstack([img1, img2]) imgs2 = imgs[:,:, ::-1] plt.axis('off') plt.title('{0} VS {1} \n CP指数: {2}%'.format(name1, name2, round(similarity, 2)), fontproperties=my_font) plt.imshow(imgs2) path = "a.jpg" cv2.imwrite(path, imgs)加入人脸检测def getFaces(gray): cascPath = "/home/ma-user/anaconda3/envs/PyTorch-1.8/lib/python3.7/site-packages/cv2/data/haarcascade_frontalface_default.xml" faceCascade = cv2.CascadeClassifier(cascPath) im1 = cv2.cvtColor(img1, cv2.COLOR_BGR2GRAY) # Detect faces faces = faceCascade.detectMultiScale( gray, scaleFactor=1.1, minNeighbors=5, flags=cv2.CASCADE_SCALE_IMAGE ) return faces步骤三:修改预置的视频和图片在Valentine文件夹下中,有一个预置的1.png和2.png图片,大家可以将里面的图片替换成自己的, 图片的名称不建议修改,如果修改成其他的名称,后面的路径也要相应的修改,上传的图片不要太大,尽量使用正脸的图片。if __name__ == '__main__': name1 = input('请输入图1照片姓名: \n') name2 = input('请输入图2照片姓名: \n') img1_path = 'Valentine/1.png' img2_path = 'Valentine/2.png' img1 = cv2.imread(img1_path) img2 = cv2.imread(img2_path) im1 = cv2.cvtColor(img1, cv2.COLOR_BGR2GRAY) im2 = cv2.cvtColor(img2, cv2.COLOR_BGR2GRAY) im1_faces = getFaces(im1) im2_faces = getFaces(im2) if len(im1_faces) !=1 or len(im2_faces)!= 1: raise ValueError("输入图片需要包含一个人脸") im1 = cv2.resize(im1, (520,520)) im2 = cv2.resize(im2, (520,520)) similarity = compute_ssim(im1, im2)*100 if similarity == 100: raise ValueError("图片重复! 请重新上传图片") img_show(similarity, img1, img2, name1, name2)请输入图1照片姓名: 王强 请输入图2照片姓名: 李欣image = Image.open("a.jpg") image = image.resize((498,278))步骤四:打印输出海报import os from PIL import Image,ImageDraw,ImageFont,ImageFilter from PIL import ImageFile ImageFile.LOAD_TRUNCATED_IMAGES = True#@title 请在下面填写创作者 : def gen_poster(img,txt1,txt2,path): font1 = ImageFont.truetype(zt,42) font2 = ImageFont.truetype(zt,24) img_draw = ImageDraw.Draw(img) img_draw.text((197,629), txt1, font=font1,fill='#961900') img_draw.text((152,689), txt2, font=font2, fill='#252b3a') img.filter(ImageFilter.BLUR) img.save(path) template_img = "./Valentine/ValentinPoster.png" zt = "./Valentine/方正兰亭准黑_GBK.ttf" temp_image = Image.open(template_img) temp_image.paste(image ,(40,266)) title_char = str(round(similarity,1)) + "%" author_char = "王强" #@param {type:"string"} savepath = 'ValentinPoster.png' # 海报图片路径 gen_poster(temp_image,title_char,author_char,savepath) Image.open(savepath) # 显示图片
  • [技术干货] Jupyter Lab无法打开终端窗口的解决方法
    本地Anaconda使用pip install jupyterlab后使用jupyter-lab打开窗口创建Terminal出现错误Launcher Error、Unhandled error、Dismiss解决方案通过查询Anaconda窗口信息发现报错如下:Traceback (most recent call last):      File "e:\anaconda3\envs\pytorch1.6.0\lib\site-packages\tornado\web.py", line 1702, in _execute        result = method(*self.path_args, **self.path_kwargs)      File "e:\anaconda3\envs\pytorch1.6.0\lib\site-packages\tornado\web.py", line 3173, in wrapper        return method(self, *args, **kwargs)      File "e:\anaconda3\envs\pytorch1.6.0\lib\site-packages\jupyter_server\terminal\api_handlers.py", line 26, in post        name, _ = self.terminal_manager.new_named_terminal(**data)      File "e:\anaconda3\envs\pytorch1.6.0\lib\site-packages\terminado\management.py", line 319, in new_named_terminal        term = self.new_terminal(**kwargs)      File "e:\anaconda3\envs\pytorch1.6.0\lib\site-packages\terminado\management.py", line 171, in new_terminal        pty = PtyProcessUnicode.spawn(argv, env=env, cwd=options.get('cwd', None))      File "e:\anaconda3\envs\pytorch1.6.0\lib\site-packages\winpty\ptyprocess.py", line 89, in spawn        'executable: %s.' % command    FileNotFoundError: The command was not found or was not executable: powershell.exe.可以发现报错的原因是JupyterLab在创建Ternimal时无法定位到PowerShell。为此,我通过CMD启用PowerShell仍然失败,如下所示:因此怀疑时是环境变量中缺少`PowerShell`路径,因此我找到`PowerShell`路径并添加至环境变量,如下所示完成后在CMD中输入PowerShell即可进入PowerShell模式此时打开Anaconda启动JupyterLab,即可正常启动Terminal,如下所示:总结如果在Win10平台使用JupyterLab无法正常启动Terminal且报错为FileNotFoundError: The command was not found or was not executable: powershell.exe.,只需要在环境变量中添加PowerShell路径
  • [开发环境] 学生求助,想问一下notebook中有内置NVDIA的驱动吗
    如题,notebook好像没有办法自己装驱动,非常感谢
  • [问题求助] kernel Restarting是什么意思
    小白求助,使用notebook老是碰到以下问题
  • [问题求助] notebook,使用PIL库 无法显示图片
    如图如图如图如图如图
  • [开发环境] 使用pip install时出现“没有空间”的错误
    使用pip install时出现“没有空间”的错误
  • [开发环境] 如何在Notebook中安装外部库?
    如何在Notebook中安装外部库?
  • [开发环境] 在Notebook中,如何访问其他帐号的OBS桶?
    在Notebook中,如何访问其他帐号的OBS桶?
  • [开发环境] 如何对OBS的文件重命名?
    Notebook可以访问OBS中的文件,如果对文件进行重命名?
  • [开发环境] Notebook停止或者重启后,“/cache”下的文件还存在么?
    Notebook停止或者重启后,“/cache”下的文件还存在么?
  • [开发环境] 报错内存已满或者“CUDA error: out of memory”怎么办?
    报错内存已满或者“CUDA error: out of memory”怎么办? 有没有什么办法?