![](https://img-blog.csdnimg.cn/20201014180756757.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
python
代码小白的成长
不管多么难熬,人生都要眉开眼笑
展开
-
Sketchycoco:根据coco中图像获得对应的caption,并生成prompt.json文件
【代码】Sketchycoco:根据coco中图像获得对应的caption,并生成prompt.json文件。原创 2023-10-13 11:56:47 · 202 阅读 · 0 评论 -
SketchyCOCO数据集进行前景图像、背景图像和全景图像的分类
【代码】SketchyCOCO数据集进行前景图像、背景图像和全景图像的分类。原创 2023-10-08 20:57:54 · 315 阅读 · 0 评论 -
python: 修改分割标签的类别
python: 修改分割标签的类别原创 2023-03-06 21:29:50 · 185 阅读 · 0 评论 -
python报错: OSError: cannot open resource
问题: File "D:\Windows_DL_Environment\anaconda3\envs\py37\lib\site-packages\PIL\ImageFont.py", line 852, in freetype return FreeTypeFont(font, size, index, encoding, layout_engine) File "D:\Windows_DL_Environment\anaconda3\envs\py37\lib\site-packages原创 2022-03-01 15:18:17 · 3976 阅读 · 0 评论 -
python: 海量图片检索:“以图搜图“
说明:由于很多论文里面的测试图片没有标号,就不能确定它们是Testset数据集中哪几张图片。为了能解决这个问题,需要完成以图片去搜索整个数据集文件目录的任务。待搜索图:测试集:new_similarity_compare.py# -*- encoding=utf-8 -*-from image_similarity_function import *import osimport shutil# 融合相似度阈值threshold1 = 0.70# 最终相似度较高判断阈值thre原创 2021-05-26 17:41:45 · 1707 阅读 · 1 评论 -
python:make_dataset读取文件图片
def is_image_file(filename): return any(filename.endswith(extension) for extension in IMG_EXTENSIONS)def make_dataset_rec(dir, images): assert os.path.isdir(dir), '%s is not a valid directory' % dir for root, dnames, fnames in sorted(os.walk原创 2021-05-26 15:40:17 · 1204 阅读 · 0 评论 -
ADE20K_outdoor数据集生成对应的.odgt文件
ADE20K_outdoor数据集生成对应的.odgt文件import osfrom PIL import Imagedef getFileList(root, file_path): file_list = [] for file in os.listdir(os.path.join(root, file_path)): if file.endswith(".png") or file.endswith(".jpg"): write_name原创 2021-04-14 18:53:14 · 634 阅读 · 2 评论 -
python:读取txt文本中的每一行的同时,对每一行以空格进行分割
文本中格式:一行中有许多列ADE_train_00000001 airport_terminalADE_train_00000002 airport_terminalADE_train_00000003 art_galleryADE_train_00000004 badlandsADE_train_00000005 ball_pitADE_train_00000006 bathroomADE_train_00000007 bathroomADE_train_00000008 bathroo原创 2021-03-31 11:12:24 · 5763 阅读 · 2 评论 -
图像质量评价指标: MMD ( maximum-mean-discrepancy) 最大平均差异
MMD:maximum mean discrepancy。最大平均差异, 用于判断两个分布p和q是否相同。它的基本假设是:如果对于所有以分布生成的样本空间为输入的函数f,如果两个分布生成的足够多的样本在f上的对应的像的均值都相等,那么那么可以认为这两个分布是同一个分布。现在一般用于度量两个分布之间的相似性。import torchimport matplotlibimport osimport argparseimport numpy as npfrom PIL import Imagefr原创 2020-08-31 23:03:53 · 2625 阅读 · 1 评论 -
readImg: 读取图片到Variable变量
from PIL import Imagefrom torch.autograd import Variablefrom torchvision import transformstransform = transforms.Compose( [ # 函数接受PIL Image或numpy.ndarray,将其先由HWC转置为CHW格式,再转为float后每个像素除以255 transforms.ToTensor(), # 对数据按通道进行标准化到[-1,1原创 2020-08-31 20:49:58 · 1882 阅读 · 0 评论 -
Pytorch:tensor.scatter_()将label变成one hot编码
将针对全连接网络和全卷积网络输出的形式不同,将one hot编码分两种情况:第一种针对网络输出是二维,即全连接层的输出形式, [Batchsize, Num_class]第二种针对输出是四维特征图,即分割网络的输出形式,[Batchsize, Num_class, H,W]第二种方式:[Batchsize, Num_class, H,W]input.scatter_(dim, index, src) → Tensor参数:input: 我们需要插入数据的起源tensor;也就是想原创 2020-06-22 10:44:44 · 1095 阅读 · 1 评论 -
python: scipy.misc.imresize:先裁剪成矩形,再调整图片大小并归一化
img = cv2.imread(img_path,cv2.IMREAD_COLOR)def resize(self, img, height, width, centerCrop=True, interp='bilinear'): imgh, imgw = img.shape[0:2] if centerCrop and imgh != imgw: # center crop side = np.minimum(imgh.原创 2020-06-04 10:22:17 · 1229 阅读 · 0 评论 -
python字符串连接的常用3种方式:加号+ , join, 替换
方法1:直接通过加号(+)操作符连接website = 'python' + 'tab' + '.com'方法2:join方法listStr = ['python', 'tab', '.com'] website = ''.join(listStr)方法3:替换website = '%s%s%s' % ('python', 'tab', '.com')原创 2020-06-03 18:33:41 · 1556 阅读 · 0 评论 -
python:读取配置文件.yaml中的内容
注意:.yaml文件中每个’ : '后都有一个空格config = Config(args)class Config(dict): def __init__(self, args): # open the file of .yaml with open(args.yaml_path, 'r') as f: self._dict = yaml.load(f.read()) # Load the dictionary def _..原创 2020-05-21 18:32:48 · 533 阅读 · 1 评论 -
pycharm导入相同目录和不同目录下模块
1.导入的模块与当前程序代码在同一个目录下方法1:如上图,当前程序代码为main.py, 如果import相同目录tools下的_init__paths.py,则用import tools._init_paths方法2:鼠标右键tools目录,mark directory as==>sources root ,tools目录会变蓝色。2.导入的模块与当前程序代码不在同一个目录下方法1:将路径不全,即是添加.lib方法2:对于和当前程序代码不在同一个目录下的模块(code/l原创 2020-05-20 19:46:25 · 4229 阅读 · 1 评论