Beispiel #1
0
def picture():
    img_root = "images"
    img_name = "{}.jpeg".format(datetime.datetime.now())

    if not os.path.exists(img_root):
        os.makedirs(img_root)

    img_path = os.path.join(img_root, img_name)

    cmd_array = [
        "streamer",
        "-c",
        "/dev/video1",
        "-s",
        resolution,
        "-o",
        img_path,
    ]
    cmd_array

    ret = check_output(cmd_array)

    display_jpeg(Image(img_path))
Beispiel #2
0
def display_all():
    display_jpeg(Image("blended.jpg"))
filename = f'./{track.artist} - {track.title}.mp3'

# trackをmp3で保存
with open(filename, 'wb+') as fp:
    track.write_mp3_to(fp)

# trackの持つプロパティをすべて表示
track = api.resolve(
    'https://soundcloud.com/orco-350884854/diamond-dustprodweirdove')
array = dir(track)
for index, item in enumerate(array):
    print('■' + str(index) + ':' + item)
    x = 'track.' + item
    print(eval(x))
display_jpeg(Image(track.user['avatar_url']))

# playlistのtracksをすべて表示
playlist_url = 'https://soundcloud.com/chillysource/sets/dj-kro-mix'

# assertを使う方法 -> noとtitleの設定ができない
# playlist = api.resolve(playlist_url)
# assert type(playlist) is Playlist
# for track in playlist.tracks:
#     print(str(track.track_no) + ':' + track.title)

# enumarateを使う方法
playlist = api.resolve(playlist_url)
for track_number, track in enumerate(playlist):
    track.track_no = track_number
    track.album = playlist.title
    if finded_photo['label'] == "Square":
        print(finded_photo['source'])
        img = requests.get(finded_photo['source'])
        img_file = open(f'flickr_photo/{i}.jpg', 'wb')
        img_file.write(img.content)
        img_file.close()
print("ok")

for i in range(100):
    image = Image.open(f'flickr_photo/{i}.jpg')

    w, h = image.size
    rr, gg, bb = 0, 0, 0

    for x in range(w):
        for y in range(h):
            r, g, b = image.getpixel((x, y))
            rr += r
            gg += g
            bb += b

    cnt = w * h
    print(rr // cnt, gg // cnt, bb // cnt)
    awg_color = Image.new('RGB', (150, 75),
                          color=(rr // cnt, gg // cnt, bb // cnt))
    awg_color.paste(image, (0, 0, 75, 75))
    awg_color.save(f'flickr_photo/awg_{i}.jpg', "JPEG")
    image = display.Image(f'flickr_photo/{i}.jpg')
    awg_color = display.Image(f'flickr_photo/awg_{i}.jpg')
    display.display_jpeg(awg_color)
Beispiel #5
0
    np.save(out_npy_path, song_features)
    return (output_dict, song_features)


if __name__ == '__main__':
    soundnet = load_model("./data/models/soundnet.hdf5")
    imagenet = MobileNet(include_top=True,
                         weights='imagenet')  # using MobileNet

    # create sound features using SoundNet model
    (mp3_files, sound_features) = create_sound_libs(soundnet)

    print("#of mp3 files", len(mp3_files['mp3']))

    with open("./data/sounds.json") as f:
        mp3_files = json.load(f)
    sound_features = np.load("./data/song_features.npy")

    IMG_PATH = "./snow_skyscraper.jpg"
    display_jpeg(Image(IMG_PATH))

    # Extract image features using ImageNet model(MobileNet)
    img_feature = get_image_features(imagenet, IMG_PATH)

    # Match the image features and pre-processed sound features,
    # then find the topK best matched sound files
    topk_indecies = get_topk_songs(img_feature, sound_features, k=3)

    print("The best-matched sound:")

    display(Audio(mp3_files["mp3"][topk_indecies[0]]["filepath"]))
Beispiel #6
0
#%%
from icrawler.builtin import BingImageCrawler

# 猫の画像100枚を取得
crawler = BingImageCrawler(storage={'root_dir': 'cat'})
crawler.crawl(keyword='猫', max_num=100)
# %%
# 犬の画像を100枚を取得
crawler = BingImageCrawler(storage={'root_dir': 'dog'})
crawler.crawl(keyword='犬', max_num=100)
# %%
# 画像の表示
import os
from IPython.display import Image, display_jpeg
path = os.getcwd()
display_jpeg(Image(path + '\\cat\\000001.jpg'))
# %%
from PIL import Image, ImageFile
import glob
import numpy as np

ImageFile.LOAD_TRUNCATED_IMAGES = True

classes = ['dog', 'cat']
num_classes = len(classes)
image_size = 64
num_testdata = 25

X_train, X_test, y_train, y_test = [], [], [], []

for index, classlabel in enumerate(classes):
 def img_download(self, video_id, thumbnail_link):
   response = requests.get(thumbnail_link, allow_redirects=False)
   if response.status_code == 200:
     img = response.content
     display_jpeg(Image(img))
#画像ファイルの表示

from IPython.display import Image, display_jpeg
import requests

URL = "http://www.teu.ac.jp/common/images/mainimgs/mainimgs_gaiyou.jpg"
FNAME = "gakuen.jpg"
r = requests.get(URL)
display_jpeg(Image(r.content))
open(FNAME, "wb").write(r.content)

#im = Image.open("gakuen.jpg")
#im.show()