Beispiel #1
0
def blurthday():
    
    from imread import imread
    from pprint import pprint
    imfuckingshowalready = lambda mx: Image.fromarray(mx).show()
    
    identity = LUT()
    amatorka = LUT('amatorka')
    #miss_etikate = LUT('miss_etikate')
    #soft_elegance_1 = LUT('soft_elegance_1')
    #soft_elegance_2 = LUT('soft_elegance_2')
    
    im1 = imread(
        AppDirectoriesFinder().storages.get(
            'django_instakit').path(join(
                'django_instakit', 'img', '06-DSCN4771.JPG')))
    im2 = imread(
        AppDirectoriesFinder().storages.get(
            'django_instakit').path(join(
                'django_instakit', 'img',
                '430023_3625646599363_1219964362_3676052_834528487_n.jpg')))
    
    pprint(identity)
    pprint(amatorka)
    
    im9 = amatorka.transform(im1)
    pprint(im9)
    imfuckingshowalready(im9)
    print im1
    print im2
Beispiel #2
0
def blurthday():

    from imread import imread
    from pprint import pprint
    imfuckingshowalready = lambda mx: Image.fromarray(mx).show()

    identity = LUT()
    amatorka = LUT('amatorka')
    #miss_etikate = LUT('miss_etikate')
    #soft_elegance_1 = LUT('soft_elegance_1')
    #soft_elegance_2 = LUT('soft_elegance_2')

    im1 = imread(static.path(join('img', '06-DSCN4771.JPG')))
    im2 = imread(
        static.path(
            join('img',
                 '430023_3625646599363_1219964362_3676052_834528487_n.jpg')))

    pprint(identity)
    pprint(amatorka)

    im9 = amatorka.transform(im1)
    pprint(im9)
    imfuckingshowalready(im9)
    print im1
    print im2
Beispiel #3
0
    def Mix(self, Folder, filen, Sim):
        img = imread(os.path.join(Folder, "ForestInitial.png"))
        fstr = str(filen).zfill(4)

        #Path and name of the file
        PathFile = os.path.join(Folder, "Plots", "Plots" + str(Sim),
                                "forest" + fstr + ".png")

        # Reads the basic forest
        img2 = imread(PathFile)

        # Over plot
        gca().set_axis_off()
        subplots_adjust(top=1, bottom=0, right=1, left=0, hspace=0, wspace=0)
        margins(0, 0)
        gca().xaxis.set_major_locator(NullLocator())
        gca().yaxis.set_major_locator(NullLocator())

        plt.imshow(img, zorder=0)
        plt.imshow(img2, zorder=1)
        plt.savefig(PathFile, dpi=200, bbox_inches='tight', pad_inches=0)
        plt.close("all")
import numpy as np
from scipy,misc import imread, imsave, imresize

mean = np.load('./TFD/mean.npy')
std = np.load('./TFD/std.npy')

for i in range(4):
	img = imread('~/report_visu/%d.png' % i, True)
	img = imresize(img, (48,48), 'bilinear')
	imsave('~/report_visu/%d_good.png'%i, img)
Beispiel #5
0
inDirAtt ='/Users/edoardocalvello/Documents/Representation_Learning_2020/celebA/list_attr_celeba.txt'
inDirIm='/Users/edoardocalvello/Documents/Representation_Learning_2020/celebA/img_align_celeba'
IMSIZE=64

f = open(inDirAtt)
noSamples = int(f.readline())
print('There are %d samples' % noSamples)
labels = f.readline().split(' ')
print(labels, type(labels))
dataX = []
dataY = []
for i, line in enumerate(f):
    imName, labels = line.split(' ')[0], line.split(' ')[1:]
    label = np.loadtxt(labels)
    print(imName, label)

    print(i)
    im = imread(join(inDirIm, imName))
    im = Image.fromarray(im)
    im = fit(im, size=(IMSIZE, IMSIZE))
    label = label.astype('int')
    im = np.transpose(im, (2, 0, 1))
    dataX.append(im)
    dataY.append(label)

print(np.shape(dataX))
print(np.shape(dataY))

np.save('/Users/edoardocalvello/Documents/Representation_Learning_2020/xTrain.npy', np.asarray(dataX))
np.save('/Users/edoardocalvello/Documents/Representation_Learning_2020/yAllTrain.npy', np.asarray(dataY))
stopwords = newstop
stopwords.add("DIA")
stopwords.add("CIO")
stopwords.add("use")
stopwords.add("s")
stopwords.add("IC ")
stopwords.add("IC")
stopwords.add("ITE")
stopwords.add("t")
stopwords.add("ESITE")

print stopwords


# read the mask image
custom_mask = imread(os.path.normpath((os.path.join(path,'Pictures for Mask','soldier.png'))))

wc = WordCloud(background_color="white", max_words=150, mask=custom_mask,
               stopwords=stopwords)
# generate word cloud
wc.generate(text)

# store to file
wc.to_file(os.path.normpath((os.path.join(path,'Output','cloudsoldier.png'))))

# show
plt.imshow(wc)
plt.axis("off")
plt.figure()
plt.imshow(custom_mask, cmap=plt.cm.gray)
plt.axis("off")
def read_image(path):
    file = imread(path, as_grey=True)
    file = scipy.misc.imresize(file, IMAGE_SHAPE). \
                      reshape(IMAGE_ARRAY_SIZE)
    return file
def read_image(path):
    file = imread(path, as_grey=True)
    file = scipy.misc.imresize(file, IMAGE_SHAPE). \
                      reshape(IMAGE_ARRAY_SIZE)
    return file
def _imread(image_name):
        return imread(image_name)
Beispiel #10
0
    def MultiFireMix(self, Folder, nSims, mode="Scale", probs=[]):
        # Read initial forest status
        imgForest = imread(os.path.join(Folder, "ForestInitial.png"))
        #fstr = str(filen).zfill(4)

        # If no probs provided, alpha = 0.25 by default (otherwise, transparency is proportional to the fire probability)
        if len(probs) == 0:
            probs = np.full(nSims, 1 / nSims)

        #Path and name of the file
        PathFile = []
        for i in range(1, nSims + 1):
            #PathFile.append(os.path.join(Folder, "Plots", "Plots"+str(i), "forest" + fstr + ".png"))
            ScarPath = os.path.join(Folder, "Plots", "Plots" + str(i))
            ScarFiles = os.listdir(ScarPath)
            PathFile.append(ScarPath + "/" + ScarFiles[-1])
            #print(ScarFiles[-1])

        # Reads the basic forest
        imgArray = []

        for i in range(nSims):
            imgArray.append(imread(PathFile[i]))
            #print(imgArray[i].shape)

        # Summation mode: sum the pixels values for highlighting the intersections of fires (more intense than Scale)
        if mode == "Sum":
            SumPixels = np.zeros([
                imgArray[0].shape[0], imgArray[0].shape[1],
                imgArray[0].shape[2]
            ])
            for i in range(nSims):
                SumPixels[:, :, ] += imgArray[i][:, :, ]

            # Trick for seeing less likely scar
            SumPixels[:, :, ] += 1

            # Divide by the total number of simulations
            SumPixels /= (nSims + 1)

        # Over plot
        gca().set_axis_off()
        subplots_adjust(top=1, bottom=0, right=1, left=0, hspace=0, wspace=0)
        margins(0, 0)
        gca().xaxis.set_major_locator(NullLocator())
        gca().yaxis.set_major_locator(NullLocator())

        # Plot the initial forest state
        plt.imshow(imgForest, zorder=0)

        # Sum or Scale
        if mode == "Sum":
            plt.imshow(SumPixels, zorder=0, alpha=1, vmin=0, vmax=255)

        # Plot each fire
        else:
            for i in range(nSims):
                plt.imshow(imgArray[i],
                           zorder=i,
                           alpha=probs[i],
                           vmin=0,
                           vmax=255)

        # Save the combined picture
        plt.savefig(os.path.join(Folder, "Plots",
                                 "MultiFire_Plot" + mode + ".png"),
                    dpi=200,
                    bbox_inches='tight',
                    pad_inches=0)
        plt.close("all")
Beispiel #11
0
    detals.append(list(map(eval,line.spilt(","))))
f.close()
#自动绘制
for i in range(len(detals)):
    t.pencolor(detals[i][3],detals[i][4],detals[i][5])
    t.fd(detals[i][0])
    if detals[i][1]:
        t.right(detals[1][2])
    else:
        t.left(detals[i][2])

# 不规则图形词云
import jieba
import wordcloud
import  scipy.misc import imread  # 自定义词云形状
mask = imread("chinamap.jpg")    # 导入词云形状图,需是白底
excludes = {}
f = open("新时代中国特色社会主义.txt","r",encoding = "utf-8")
t = f.read()
f.close()
ls = jieba.lcut(t)
txt = "".join(ls)
w = wordcloud.WordCloud(width = 1000,height = 700,\
                        background_color = "white",
                        font_path = "msyh.ttc",mask = mask
                        )
w.generate(txt)
w.to_file("grwordcloudm.png")

# 文本的平均列数
f = open("latex.log")