When I use code:
predictions = lm.predict(Xtest)
give me following error:
ValueError: could not convert string to float: '0.01%'
And I don't see any value like this in file. Any idea how to fix?
Related
I'm using opencv-python in VSCODE, I create 2 2-dimensions arrays of the same type and same size. but I got this error when it executes the method cv2.addWeighted, I see other people are asking the same question, but their problem is the different data type. However, I have double checked the data type in my code, they are the same (np.uint8).
img01 = np.ones((200, 200), dtype=np.uint8) * 1000
img02 = np.ones((200, 200), dtype=np.uint8) * 100
weightedImg = cv2.addWeighted(img01,0.6,img02,0.4,3)
error: (-5:Bad argument) When the input arrays in add/subtract/multiply/divide functions have different types, the output array type must be explicitly specified in function 'cv::arithm_op'
I would like to know what's wrong in my code. thanks.
I need to use open cv functions: cv2.imencode,cv2.imdecode to compress (jpeg) and decompress (jpeg) for different QF values.
The picture is 'bridge.ppm' from https://imagecompression.info/test_images/
I've tried:
bridge = cv2.imread('./bridge.ppm')
bridge_en = cv2.imencode('.jpeg', bridge)
bridge_de = cv2.imdecode('.jpeg', bridge_en)
cv2.imshow('image',bridge_de)
but I'm getting an error in the 2nd line saying: "Expected Ptr<cv::UMat> for argument 'buf'".
Also, how can I change and test different QF values?
Please take a look to the documentation for imencode and imdecode
imencode returns two values, the encoded buffer is the second one. And imdecode accepts the encoded buffer and a flag. So:
bridge = cv2.imread('./bridge.ppm')
bridge_en = cv2.imencode('.jpeg', bridge)[1] # you need the second value
bridge_de = cv2.imdecode(bridge_en, cv2.IMREAD_UNCHANGED) # or any other flag, same as 'imread'
cv2.imshow('image',bridge_de)
I am trying to format a numeric number to display in exponential form. e.g 140500.45 as 1.4050045E5 using NumberFormat class in Dart. How do i go about this in flutter.
The following is what i have tried so far;
`NumberFormat numbFormat = NumberFormat("E", "en_US");
returnFormat = numbFormat.format(numericNumber);
print(returnFormat);`
Thanks.
This is how i eventually solved the problem;
double resultme = 140500.45;
double myreturnFormat = resultMe;
returnFormat = myreturnFormat.toStringAsExponential();
print(returnFormat);
The output is now correctly 1.4050045e+5
What i was initial doing wrong is supplying double argument to toStringAsExponential() method. The method requires no argument to return the results without rounding up the result. If you desire to return result such as 1.405e+5, do it like so;
myreturnFormat.toStringAsExponential(3);
The output will be 1.405e+5
Hope this help someone.
I want to apply a log function to images. But it fails showing this error: function is not defined on this type of argument.
uk=imread('image.jpg');
result=log(uk(:,:,1));
I think your problem is that imread returns a matrix of uint8 type. To apply log, you should convert it to double. There are at least 2 ways to do this, one built in, and one from SIVP:
clc;
clear;
im = imread("d:\Attila\PROJECTS\Scilab\Stackoverflow\mixer_crop.jpg");
//imshow(im);
disp(typeof(im(:,:,1)),"Original type:");
//use double
M = double(im(:,:,1));
disp(typeof(M),"Modified type:");
result=log(M);
//imshow(uint8(M));
//use im2double
M2 = im2double(im);
disp(typeof(M2(:,:,1)),"Modified type 2:");
result=log(M2(:,:,1));
//imshow(im2uint8(M2));
I am trying to save some tables of strings to files in Torch. I have tried using this Torch extension by Deepmind: hdf5.
require 'hdf5'
label = {'a', 'b','c','d'}
local myFile = hdf5.open(features_repo .. 't.h5', 'w')
myFile:write('label', label)
myFile:close()
I am getting the error:
/home/user/torch/install/bin/luajit: ...e/user/torch/install/share/lua/5.1/hdf5/group.lua:222: torch-hdf5: writing data of type string is not supported
Torch Tensors are written to file as intended.
I have also tried using matio to write to mat files (for MatLab). I am getting this error:
bad argument #1 to 'varCreate' (cannot convert 'number' to 'const char *')
The error is because "label" is a table of strings, but the function HDF5Group:_writeData is expecting a form of "tensor".
Looking at ffi.lua, it seems that the "tensor" is a typedef for "integer", so maybe replace:
label = {'a', 'b','c','d'}
with
label = {1,2,3,4}
You can use the function t2s from the module (https://github.com/aryajur/tableUtils.git) to generate a string you can save to a file. To convert back just use function s2t.