forked from NTMatBoiseState/FiberFit
-
Notifications
You must be signed in to change notification settings - Fork 1
/
foruploading5.py
32 lines (29 loc) · 1 KB
/
foruploading5.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
import io
import ipywidgets as widgets
import numpy
import cv2
import os
from os import listdir
from os.path import isfile, join
import numpy as np
def ff(b):
for elem in b.new.values():
#print(elem['metadata']['name'])
with open(os.path.join('Data/',elem['metadata']['name']), 'wb') as file:
file.write( elem['content'])
def upload(s):
s.style.button_color = "lightblue"
s.observe(ff, names='value')
def prepimages(mypath):
##Path to folder where you would like images to be saved
savepath = 'output2/'
## Upload Files
onlyfiles = [ f for f in listdir(mypath) if isfile(join(mypath,f)) ];
images = numpy.empty(len(onlyfiles), dtype=object);
names = numpy.empty(len(onlyfiles), dtype=object);
for n in range(0, len(onlyfiles)):
images[n] = cv2.imread( join(mypath,onlyfiles[n]) );
names[n]= (onlyfiles[n]);
img_tot = numpy.empty(len(images), dtype=object);
for n in range(0,len(images)):
img_tot[n]= np.invert(images[n])