I try to run the git repository : https://github.com/DinoMan/speech-driven-animation
on jupyter.
I followed the steps indicated but I encountered an error when I wanted to run example :
Here is my code amd the error :
import sda
va = sda.VideoAnimator(gpu=-1, model_path="crema")# Instantiate the animator
vid, aud = va("example/image.bmp", "example/audio.wav")
---------------------------------------------------------------------------
RuntimeError Traceback (most recent call last)
Input In [7], in <cell line: 1>()
----> 1 vid, aud = va("example/image.bmp", "example/audio.wav")
File ~\IVERSE\sda\sda.py:229, in VideoAnimator.__call__(self, img, audio, fs, aligned)
226 frame = img
228 if not aligned:
--> 229 frame = self.preprocess_img(frame)
231 if isinstance(audio, str): # if we have a path then grab the audio clip
232 info = mediainfo(audio)
File ~\IVERSE\sda\sda.py:191, in VideoAnimator.preprocess_img(self, img)
190 def preprocess_img(self, img):
--> 191 src = self.fa.get_landmarks(img)[0][self.stablePntsIDs, :]
192 dst = self.mean_face[self.stablePntsIDs, :]
193 tform = tf.estimate_transform('similarity', src, dst) # find the transformation matrix
File ~\AppData\Local\Programs\Python\Python310\lib\site-packages\face_alignment\api.py:110, in FaceAlignment.get_landmarks(self, image_or_path, detected_faces, return_bboxes, return_landmark_score)
98 def get_landmarks(self, image_or_path, detected_faces=None, return_bboxes=False, return_landmark_score=False):
99 """Deprecated, please use get_landmarks_from_image
100
101 Arguments:
(...)
108 return_landmark_score {boolean} -- If True, return the keypoint scores along with the keypoints.
109 """
--> 110 return self.get_landmarks_from_image(image_or_path, detected_faces, return_bboxes, return_landmark_score)
File ~\AppData\Local\Programs\Python\Python310\lib\site-packages\torch\autograd\grad_mode.py:27, in _DecoratorContextManager.__call__.<locals>.decorate_context(*args, **kwargs)
24 #functools.wraps(func)
25 def decorate_context(*args, **kwargs):
26 with self.clone():
---> 27 return func(*args, **kwargs)
File ~\AppData\Local\Programs\Python\Python310\lib\site-packages\face_alignment\api.py:141, in FaceAlignment.get_landmarks_from_image(self, image_or_path, detected_faces, return_bboxes, return_landmark_score)
138 image = get_image(image_or_path)
140 if detected_faces is None:
--> 141 detected_faces = self.face_detector.detect_from_image(image.copy())
143 if len(detected_faces) == 0:
144 warnings.warn("No faces were detected.")
File ~\AppData\Local\Programs\Python\Python310\lib\site-packages\face_alignment\detection\sfd\sfd_detector.py:45, in SFDDetector.detect_from_image(self, tensor_or_path)
42 def detect_from_image(self, tensor_or_path):
43 image = self.tensor_or_path_to_ndarray(tensor_or_path)
---> 45 bboxlist = detect(self.face_detector, image, device=self.device)[0]
46 bboxlist = self._filter_bboxes(bboxlist)
48 return bboxlist
File ~\AppData\Local\Programs\Python\Python310\lib\site-packages\face_alignment\detection\sfd\detect.py:15, in detect(net, img, device)
12 # Creates a batch of 1
13 img = np.expand_dims(img, 0)
---> 15 img = torch.from_numpy(img.copy()).to(device, dtype=torch.float32)
17 return batch_detect(net, img, device)
RuntimeError: Numpy is not available
I uploaded models via Google drive, I tried to uninstall numpy and reinstall a lower version (1.19) but this doesn't work too..
The error was:
note: This error originates from a subprocess, and is likely not a problem with pip.
error: metadata-generation-failed
Could you help me understand what can I do to resolve the problem please ?
Thanks
Related
I am using skimage and applying a morphological binary closing to an array by setting the footprint to a disk equal to 5. When I run the code with the default values and without the footprint = disk(5) the code works but when I add the footprint parameter it throws an error:
from skimage.morphology import disk
import skimage.feature
import skimage.morphology
import rasterio as rio
import rasterio.plot
footprint = disk(5)
flood_closing = skimage.morphology.binary_closing(flood_uint8_test, footprint)
I get the following error
---------------------------------------------------------------------------
IndexError Traceback (most recent call last)
<ipython-input-98-10bd8239dd40> in <module>
----> 1 flood_closing = skimage.morphology.binary_closing(flood_uint8_test, footprint)
~/anaconda3/envs/eobox/lib/python3.6/site-packages/skimage/morphology/misc.py in func_out(image, selem, *args, **kwargs)
37 if selem is None:
38 selem = _default_selem(image.ndim)
---> 39 return func(image, selem=selem, *args, **kwargs)
40
41 return func_out
~/anaconda3/envs/eobox/lib/python3.6/site-packages/skimage/morphology/binary.py in binary_closing(image, selem, out)
142
143 """
--> 144 dilated = binary_dilation(image, selem)
145 out = binary_erosion(dilated, selem, out=out)
146 return out
~/anaconda3/envs/eobox/lib/python3.6/site-packages/skimage/morphology/misc.py in func_out(image, selem, *args, **kwargs)
37 if selem is None:
38 selem = _default_selem(image.ndim)
---> 39 return func(image, selem=selem, *args, **kwargs)
40
41 return func_out
~/anaconda3/envs/eobox/lib/python3.6/site-packages/skimage/morphology/binary.py in binary_dilation(image, selem, out)
75 if out is None:
76 out = np.empty(image.shape, dtype=np.bool)
---> 77 ndi.binary_dilation(image, structure=selem, output=out)
78 return out
79
~/anaconda3/envs/eobox/lib/python3.6/site-packages/scipy/ndimage/morphology.py in binary_dilation(input, structure, iterations, mask, output, border_value, origin, brute_force)
513 for ii in range(len(origin)):
514 origin[ii] = -origin[ii]
--> 515 if not structure.shape[ii] & 1:
516 origin[ii] -= 1
517
IndexError: tuple index out of range
I have tiff image stacks of 1000 frames in which I'm trying to track particles diffusing in Brownian motion. So I'm using trackpy for particle tracking: import the tiff stack, locate the features (particles) and then plot their trajectories. I'm using the following code (as from the trackpy walkthrough page):
import pims
import trackpy as tp
frames = pims.open("image.tif")
f = tp.locate(frames[0], 9, invert=False)
But this last line (tp.locate) gives a traceback:
AttributeError Traceback (most recent call last)
<ipython-input-78-0fbce96715a7> in <module>
----> 1 f = tp.locate(frames[0], 9, invert=False)
~\anaconda3\lib\site-packages\slicerator\__init__.py in __getitem__(self, i)
186 indices, new_length = key_to_indices(i, len(self))
187 if new_length is None:
--> 188 return self._get(indices)
189 else:
190 return cls(self, indices, new_length, propagate_attrs)
~\anaconda3\lib\site-packages\pims\base_frames.py in __getitem__(self, key)
96 """__getitem__ is handled by Slicerator. In all pims readers, the data
97 returning function is get_frame."""
---> 98 return self.get_frame(key)
99
100 def __iter__(self):
~\anaconda3\lib\site-packages\pims\tiff_stack.py in get_frame(self, j)
119 t = self._tiff[j]
120 data = t.asarray()
--> 121 return Frame(data, frame_no=j, metadata=self._read_metadata(t))
122
123 def _read_metadata(self, tiff):
~\anaconda3\lib\site-packages\pims\tiff_stack.py in _read_metadata(self, tiff)
124 """Read metadata for current frame and return as dict"""
125 # tags are only stored as a TiffTags object on the parent TiffPage now
--> 126 tags = tiff.keyframe.tags
127 md = {}
128 for name in ('ImageDescription', 'image_description'):
~\anaconda3\lib\site-packages\skimage\external\tifffile\tifffile.py in __getattr__(self, name)
2752 setattr(self, name, value)
2753 return value
-> 2754 raise AttributeError(name)
2755
2756 def __str__(self):
AttributeError: keyframe
where I'm going wrong?
I also tried using
imageio.imread("image.tif")
to import the image and then used
f=tp.locate(frames[0], 9, invert=False)
to locate the particles. But the output of this is supposed to be data for both x and y coordinates, like so
whereas what I get is just for the x axis:
I just had this same problem and solved it by entering "conda install pims" into my anaconda prompt. I had done "pip install pims" before, and I think that messed it up.
00157.jpg is an image in the folder images
For a FileNotFoundError, I'd be expecting to see '/host/Mask_RCNN/Kangaroo/kangaroo-master/images/00157.jpg' where the images and 00157.jpg are seperatd by /. However, in the error below, that's not the case. The image file seems to be "joined" to its directory.
FileNotFoundError: [Errno 2] No such file or directory: '/host/Mask_RCNN/Kangaroo/kangaroo-master/images00157.jpg'
I've provided the code below. I'd like to know the changes that I should make to the code in order to solve this, please.
P.S. I'm running the file on Jupyter notebook, in a docker container, if that helps.
Complete error message:
FileNotFoundError Traceback (most recent call last)
<ipython-input-70-383929dd479b> in <module>()
1 # load an image
2 image_id = 20
----> 3 image = test_set.load_image(image_id)
4 print(image.shape)
5 print(test_set.class_ids)
/host/Mask_RCNN/mrcnn/utils.py in load_image(self, image_id)
357 """
358 # Load image
--> 359 image = skimage.io.imread(self.image_info[image_id]['path'])
360 # If grayscale. Convert to RGB for consistency.
361 if image.ndim != 3:
/usr/local/lib/python3.5/dist-packages/skimage/io/_io.py in imread(fname, as_grey, plugin, flatten, **plugin_args)
59
60 with file_or_url_context(fname) as fname:
---> 61 img = call_plugin('imread', fname, plugin=plugin, **plugin_args)
62
63 if not hasattr(img, 'ndim'):
/usr/local/lib/python3.5/dist-packages/skimage/io/manage_plugins.py in call_plugin(kind, *args, **kwargs)
209 (plugin, kind))
210
--> 211 return func(*args, **kwargs)
212
213
/usr/local/lib/python3.5/dist-packages/skimage/io/_plugins/pil_plugin.py in imread(fname, dtype, img_num, **kwargs)
33 """
34 if isinstance(fname, string_types):
---> 35 with open(fname, 'rb') as f:
36 im = Image.open(f)
37 return pil_to_ndarray(im, dtype=dtype, img_num=img_num)
FileNotFoundError: [Errno 2] No such file or directory: '/host/Mask_RCNN/Kangaroo/kangaroo-master/images00157.jpg'
Code:
from keras.preprocessing.image import load_img
from keras.preprocessing.image import img_to_array
#Loading the model in the inference mode
model = modellib.MaskRCNN(mode="inference", config=config, model_dir='./')
# loading the trained weights o the custom dataset
model.load_weights(model_path, by_name=True)
img = load_img("/host/Mask_RCNN/Kangaroo/kangaroo-master/images/00157.jpg")
img = img_to_array(img)
# detecting objects in the image
result= model.detect([img])
# load an image
image_id = 20
image = test_set.load_image(image_id)
print(image.shape)
print(test_set.class_ids)
# load image mask
mask, class_ids = test_set.load_mask(image_id)
print(mask.shape)
print(class_ids)
# plot image
pyplot.imshow(image)
# plot mask
pyplot.imshow(mask[:, :, 0], cmap='gray', alpha=0.4)
pyplot.show()
I am trying to import downloaded MNIST data to Jupyter Notebook, but when I try to run the code, it says that it doesn't have permissions.
How do I solve the problem?
pip install python-mnist
from mnist import MNIST
mndata = MNIST('C:\\Users\\username\\path\\to\\the\\samples')
images, labels = mndata.load_training()
---------------------------------------------------------------------------
PermissionError Traceback (most recent call last)
<ipython-input-2-1df33381d649> in <module>
3 mndata = MNIST('C:\\Users\\username\\path\\to\\the\\samples')
4
----> 5 images, labels = mndata.load_training()
D:\Anaconda\lib\site-packages\mnist\loader.py in load_training(self)
124 def load_training(self):
125 ims, labels = self.load(os.path.join(self.path, self.train_img_fname),
--> 126 os.path.join(self.path, self.train_lbl_fname))
127
128 self.train_images = self.process_images(ims)
D:\Anaconda\lib\site-packages\mnist\loader.py in load(self, path_img, path_lbl, batch)
245 '(start_point, batch_size)')
246
--> 247 with self.opener(path_lbl, 'rb') as file:
248 magic, size = struct.unpack(">II", file.read(8))
249 if magic != 2049:
D:\Anaconda\lib\site-packages\mnist\loader.py in opener(self, path_fn, *args, **kwargs)
237 return gzip.open(path_fn + '.gz', *args, **kwargs)
238 else:
--> 239 return open(path_fn, *args, **kwargs)
240
241 def load(self, path_img, path_lbl, batch=None):
PermissionError: [Errno 13] Permission denied: 'C:\\Users\\username\\path\\to\\the\\samples\\train-labels-idx1-ubyte'
Hello I am trying to open a .xlsx file with python, my code is really simple it looks as follows:
import openpyxl
wb = openpyxl.load_workbook('prod334.xlsx')
However I am getting an error, I am not sure about the cause of this error since I am just opening the file, I would like to appreciate any suggestion to overcome this failure.
The error that I am getting is the following:
__init__() got an unexpected keyword argument 'vertAlign'
TypeError Traceback (most recent call last)
main.py in <module>()
2
3
----> 4 wb = openpyxl.load_workbook('prod334.xlsx')
/usr/local/lib/anaconda/lib/python2.7/site-packages/openpyxl/reader/excel.pyc in load_workbook(filename, use_iterators, keep_vba, guess_types, data_only)
163
164 try:
--> 165 _load_workbook(wb, archive, filename, use_iterators, keep_vba)
166 except KeyError:
167 e = exc_info()[1]
/usr/local/lib/anaconda/lib/python2.7/site-packages/openpyxl/reader/excel.pyc in _load_workbook(wb, archive, filename, use_iterators, keep_vba)
210 assert wb.loaded_theme == None, "even though the theme information is missing there is a theme object ?"
211
--> 212 style_properties = read_style_table(archive.read(ARC_STYLE))
213 style_table = style_properties.pop('table')
214 wb.shared_styles = style_properties.pop('list')
/usr/local/lib/anaconda/lib/python2.7/site-packages/openpyxl/reader/style.pyc in read_style_table(xml_source)
221 def read_style_table(xml_source):
222 p = SharedStylesParser(xml_source)
--> 223 p.parse()
224 return p.style_prop
/usr/local/lib/anaconda/lib/python2.7/site-packages/openpyxl/reader/style.pyc in parse(self)
37 self.parse_color_index()
38 self.style_prop['color_index'] = self.color_index
---> 39 self.font_list = list(self.parse_fonts())
40 self.fill_list = list(self.parse_fills())
41 self.border_list = list(self.parse_borders())
/usr/local/lib/anaconda/lib/python2.7/site-packages/openpyxl/reader/style.pyc in parse_fonts(self)
89 if fonts is not None:
90 for node in safe_iterator(fonts, '{%s}font' % SHEET_MAIN_NS):
---> 91 yield self.parse_font(node)
92
93 def parse_font(self, font_node):
/usr/local/lib/anaconda/lib/python2.7/site-packages/openpyxl/reader/style.pyc in parse_font(self, font_node)
105 if color is not None:
106 font['color'] = Color(**dict(color.items()))
--> 107 return Font(**font)
108
109 def parse_fills(self):
TypeError: __init__() got an unexpected keyword argument 'vertAlign'