Unable to find “e:\pythonenv\dataspider\lib\sit-packages\setuptools-40.8.0-py3.7.egg\EGG-INFO” when adding binary and data files.
Error resolution.
The version of setuptools is too low, upgrade the version on it, click File-settings-project:xxx-Project interpreter – click
然后install package即可
Category Archives: Python
[Solved] RuntimeError: Numpy is not available (Associated Torch or Tensorflow)
Runtimeerror: numpy is not available solution
Problem Description:
Today, the old computer crashed (cried) and the new computer got started. I couldn’t wait to install the pytorch and check the operation of the previous project. As a result, there was an error running the model training
the key sentence is the sentence loading the model training data
for i, data in enumerate(train_loader):
The bottom layer of this statement is applied to the operation of converting the tensor variable to numpy, that is
import numpy
import torch
test_torch = torch.rand(100,1,28,28)
print(test_torch.numpy())
# will produce the same error
Problem root
The direct correlation between pytoch and tensorflow is ignored
if there is only torch but no tensorflow in the environment, the tensor variable used by torch will lose the tensor related operation function, such as torch. Numpy()
Solution:
Install tensorflow in the basic environment, whether CPU version or GPU version
in Anaconda environment, you can directly
conda install tensorflow
Otherwise pip
pip install --ignore-installed --upgrade tensorflow-gpu
Python Run Error: TypeError: hog() got an unexpected keyword argument ‘visualise‘”
Running Python code reports an error “typeerror: hog() got an unexpected keyword argument ‘visualise'”
FD, hog_ image = hog(image, orientations=8, pixels_ per_ cell=(12, 12),
cells_ per_ Block = (1, 1), visualise = true) can be normal by changing visualise to visualize, that is (changing the letter S to Z):
fd, hog_image = hog(image, orientations=8, pixels_per_cell=(12, 12),
cells_per_block=(1, 1), visualize=True)
[Solved] RuntimeError: cublas runtime error : resource allocation failed at
[root@bsyocr server-train]# tail trainall210722_6.log.txt
File “/home/server-train/pytorch_pretrained/modeling.py”, line 300, in forward
mixed_query_layer = self.query(hidden_states)
File “/usr/local/lib64/python3.6/site-packages/torch/nn/modules/module.py”, line 547, in __call__
result = self.forward(*input, **kwargs)
File “/usr/local/lib64/python3.6/site-packages/torch/nn/modules/linear.py”, line 87, in forward
return F.linear(input, self.weight, self.bias)
File “/usr/local/lib64/python3.6/site-packages/torch/nn/functional.py”, line 1371, in linear
output = input.matmul(weight.t())
RuntimeError: cublas runtime error : resource allocation failed at /pytorch/aten/src/THC/THCGeneral.cpp:216
RuntimeError: CUDA out of memory. error when running the model Checked a lot of related content, the reason is: GPU memory memory is not enough Briefly summarize the solution: change the batch_size to a smaller size
Modify the pad.size of bert from 2048 -> 1024
Opencv Python realizes the paint filling function in PS, one click filling color and the possible reasons for opencv’s frequent errors
First of all, first solve the opencv error problem, once up on the error report headache
cv2.error: OpenCV(4.5.3) C:\Users\runneradmin\AppData\Local\Temp\pip-req-build-z4706ql7\opencv\modules\highgui\src\window.cpp:1274: error: (-2:Unspecified error) The function is not implemented. Rebuild the library with Windows, GTK+ 2.x or Cocoa support. If you are on Ubuntu or Debian, install libgtk2.0-dev and pkg-config, then re-run cmake or configure script in function ‘cvShowImage’
This version is probably not downloaded well, delete and start again
pip uninstall opencv-python
Then download the command
pip3 install opencv-contrib-python
Nice successfully solved the problem. Of course, there may be errors in the path with Chinese or spaces, and sometimes errors will be reported.
No more code, no more nonsense
import cv2 as cv
import numpy as np
def fill_color_demo(image): #Define the function to fill the color with one click
Img2 = image.copy() # make a copy of the input image
h, w = image.shape[:2] #Get the length and width of the image
mask = np.zeros([h+2, w+2],np.uint8) #mask must be row and column plus 2, and must be uint8 single-channel array, fill the edges need more than 2 pixels, otherwise it will report an error
cv.floodFill(Img2, mask, (100, 100), (127, 127, 127), (100, 100, 100), (50, 50 ,50), cv.FLOODFILL_FIXED_RANGE)
#cv.floodFill, parameter 1,: indicates the input image, parameter 2: indicates the mask of a single channel, parameter 3: indicates the starting point of the flooding algorithm, parameter 4 indicates the color of the fill, and parameters 5,6 indicate the maximum positive and negative difference between the currently observed pixel point and the neighboring pixel points
#x coordinates are from left to right, y coordinates are from top to bottom
cv.imshow("result", Img2) # display the result image
img = cv.imread('. /1.jpg') # read in the image
cv.imshow('input', img) #Show the input image
fill_color_demo(img) #Transfer the input image into the defined fill color function
cv.waitKey(0)
Then there is the result, as shown below
On the left is the original image of input and on the right is the output image. The color is (127127) gray and the coordinates are (100100). You can change the color coordinates as you like. It’s still very fun
Remember to like, pay attention to and collect
[Solved] Sudo doesn‘t work: “/etc/sudoers is owned by uid 1000, should be 0”
1.error
When I type a sudo command into the terminal it shows the following error:
sudo: /etc/sudoers is owned by uid 1000, should be 0
sudo: no valid sudoers sources found, quitting
sudo: unable to initialize policy plugin
How do I fix this?
2. Solution:
Change the owner back to root:
pkexec chown root:root /etc/sudoers /etc/sudoers.d -R
Or use the visudo
command to ensure general correctness of the files:
pkexec visudo
How to Solve RuntimeError: Expected all tensors to be on the same device, but found at least two devices, cpu
In this case, the data and models are generally one in the CPU, one in the GPU, or the data used for calculation. Some have been put in the GPU, and some still exist in the CPU. Here is an idea.
First, find the error reporting line, see which variables or data are used in the calculation, and then use. Is_ CUDA this attribute to check which are on the GPU and which are on the CPU, and then put them on the CPU or GPU. for instance:
The error message indicates that there is a problem in line 46 of utils.py. Then enter the file and locate line 46
Print idx_ Range and reverse_ Mapping to check whether it is on the GPU or the CPU at the same time,
print(idx_ range.is_cuda,reverse_mapping.is_cuda)
After verification, IDX was found_ Range on CPU, reverse_ Mapping on GPU, idx_ Range on GPU (IDX)_ Range. To (device)), problem-solving
[Solved] modulenotfounderror: no module named ‘torchtext.legacy.data.datasets_ utils‘
Cause: pytorch version is too low## Title
Solution.
Step 1: Find the utils.py file inside the downloaded E:\anaconda\package\envs\pytorch_gpu\Lib\site-packages\d2lzh_pytorch installation package and open it.
Step 2: Change the import torchtext inside to import torchtext.legacy as torchtext
Step 3: Close jupyter and reopen it, successfully.
‘c’ argument looks like a single numeric RGB or RGBA sequence, which should be avoided as value-mapp
When Python draws a line chart, using scatter, the use of parameter C = ” will cause warning:
ax.scatter(x_value,y_value,c=(0,0.2,0),s=10)
‘c’ argument looks like a single numeric RGB or RGBA sequence, which should be avoided as value-mapping will have precedence in case its length matches with ‘x’ & ‘y’. Please use a 2-D array with a single row if you really want to specify the same RGB or RGBA value for all points.
It may be a problem with the version of matplotlib, higher versions no longer report a warning.
You can change the original statement to the following one.
ax.scatter(x_value,y_value,color=(0,0.2,0),s=10)
Or let the log display only errors of error level:
from matplotlib.axes._axes import _log as matplotlib_axes_logger
matplotlib_axes_logger.setLevel('ERROR')
Hope to help you through sharing, thank you.
Ab3dmot vehicle pedestrian recognition (How to Use)
Code base: https://github.com/xinshuoweng/AB3DMOT
Setting up environment:
Ubuntu 16.04, Python 3.7.6 in anaconda, python 1.2 + CUDA 9.2
refer to pointrcnn environment setting up and running for the pre research environment
Kitti object tracking dataset Download
Dataset official website: http://www.cvlibs.net/datasets/kitti/eval_Tracking. PHP
when pre researching according to the project description, you only need to download the image_ 02 dataset:
http://www.cvlibs.net/download.php?file=data_tracking_image_2.zip
Xinshuo_Pytoolbox preparation
The project requires the author’s toolkit https://github.com/xinshuoweng/Xinshuo_ Pytoolbox
you need to install the package described in its requirements.txt, and then put all the folders directly into the ab3dmot folder
step
1. install dependeny:
$ cd path/to/AB3DMOT
$ pip install -r requirements.txt
2. Inference - run our tracker on the KITTI MOT validation set with the provided detection:
$ python main.py pointrcnn_Car_val
$ python main.py pointrcnn_Pedestrian_val
$ python main.py pointrcnn_Cyclist_val
Just select one, e.g. pedestrian
3. Extract the files in the image_2 package to data/KITTI/resources
4. Change the variable seq_list in visualization.py to the sample number you want to visualize, e.g.
seq_list = ['0000', '0001', '0002', '0003', '0004', '0005', '0006', '0007', '0008']
5. execute python visualization.py pointrcnn_Pedestrian_val (corresponds to pointrcnn_Pedestrian_val in step 2)
6. Check the results in results/pointrcnn_Pedestrian_val/trk_image_vis
Effect evaluation
It is easy to recognize cuboids/columns as vehicles/pedestrians, especially when recognizing vehicles, but this misjudgment generally occurs outside the road area, – and the number of continuous frames is very small; It is possible to distinguish cyclists as ordinary pedestrians; There is no obvious missing judgment, but the tracking is likely to be interrupted when occlusion occurs, resulting in unstable tracking object ID;
[Solved] Conda Upgrade Error: PackageNotInstalledError: Package is not installed in prefix.
Use CONDA update CONDA to update CONDA. If you encounter a packagenotinstallederror problem, record it here!
Problem description
conda update –prefix /Users/omeiko/opt/miniconda3 anaconda
PackageNotInstalledError: Package is not installed in prefix.
prefix: /Users/omeiko/opt/miniconda3
package name: anaconda
When you run CONDA update, you will be prompted whether you want to run CONDA update — prefix/users/omeiko/opt/minicanda3 anaconda. After running, the above error prompt will be displayed
the reason for the problem is that you installed miniconda instead of anaconda.
Solution:
Method 1
execute CONDA install anaconda, install anaconda, and then run again.
Method 2
execute CONDA update — prefix/users/omeiko/opt/miniconda3 CONDA. There is no need to update anaconda
or execute CONDA update — name base CONDA (I solved it myself with this command) to update the base command
[Solved] Pylint Warning: An attribute defined in json.encoder line 158 hides this methodpylint(method-hidden)
code:
class Encoder(JSONEncoder):
def default(self, o):
if isinstance(o, ObjectId):
o = str(o)
return o
Pylint tip:
An attribute defined in json.encoder line 158 hides this methodpylint(method-hidden)
The code check may not pass. In addition, obsessive-compulsive disorder is completely unacceptable.
Solution: add # pylint: disable = e0202. As follows:
class Encoder(JSONEncoder):
def default(self, o): # pylint: disable=E0202
if isinstance(o, ObjectId):
o = str(o)
return o