What do you want to save?
Add Code snippet
New code examples
-
Python 2022-03-02 21:10:02
array storing in file by python
# long arrays can be stored in csv files far more efficiently import numpy as np import csv # uploading arrays in a csv file arr1 = [i for i in range(500)] arr2 = [i for i in range(1000)] arr3 = [i for i in range(2000)] # you can write('w') or append('a'... Add solution -
Python 2022-02-15 06:30:11
find most used colors in image python
from __future__ import print_function import binascii import struct from PIL import Image import numpy as np import scipy import scipy.misc import scipy.cluster NUM_CLUSTERS = 5 print('reading image') im = Image.open('image.jpg') im = im.resize((150, 15... Add solution -
Python 2022-01-23 04:30:08
image classification web app using stramlit
import cv2from PIL import Image, ImageOpsimport numpy as npdef import_and_predict(image_data, model): size = (150,150) image = ImageOps.fit(image_data, size, Image.ANTIALIAS) image = np.asarray(image) img = cv2.cvtColor... Add solution -
Python 2022-01-22 23:30:02
convert opencv image to pil image
import cv2 import numpy as np from PIL import Image img = cv2.imread("path/to/img.png") # You may need to convert the color. img = cv2.cvtColor(img, cv2.COLOR_BGR2RGB) im_pil = Image.fromarray(img) # For reversing the operation: im_np = np.as... Add solution -
Python 2021-11-17 22:50:11
long arrays storing in file python
# long arrays can be stored in csv files far more efficiently import numpy as np import csv # uploading arrays in a csv file arr1 = [i for i in range(500)] arr2 = [i for i in range(1000)] arr3 = [i for i in range(2000)] # you can write('w') or append('a'... Add solution -
Python 2021-11-06 09:26:13
python numpy find nearest value
import numpy as np def find_nearest(array, value): array = np.asarray(array) idx = (np.abs(array - value)).argmin() return array[idx] array = np.random.random(10) print(array) # [ 0.21069679 0.61290182 0.63425412 0.84635244 0.91599191 0.... Add solution -
Python 2021-10-17 19:48:11
fnd closest element in array numpy
import numpy as np def find_nearest(array, value): array = np.asarray(array) idx = (np.abs(array - value)).argmin() return array[idx] array = np.random.random(10) print(array) # [ 0.21069679 0.61290182 0.63425412 0.84635244 0.91599191 0.... Add solution