My mediapipe version is 0.8.9.1
I have tried redownloading it on a lower version but it doesnt allow me to go past my version.
I am using "PoseModule" code from here: https://www.computervision.zone/lessons/code-files-15/
This is the error i get:
TypeError: create_bool(): incompatible function arguments. The following argument types are supported:
1. (arg0: bool) -> mediapipe.python._framework_bindings.packet.Packet
Invoked with: 0.5
Could anyone help me in fixing the code please?
Most answers i saw are regarding "self.mpHands.Hands".
I heard there is something wrong with the init within class poseDetector but I dont know how to rewrite tho code :/
Related
I'm still new to type hints. Here's the minimal code example of the error I'm getting:
import sqlalchemy as sa
t = sa.Table("a", sa.MetaData(), sa.Column("id_", sa.Integer))
cols = t.columns
This raises the following error when I run mypy:
error: Expression type contains "Any" (has type "ReadOnlyColumnCollection[str, Column[Any]]") [misc]
I'm running mypy with the following configuration turned on (link):
disallow_any_expr = true
I've looked at the sql alchemy source code and the .colums method of the Table class does indeed have the return type that mypy states.
I don't know however how could I go about altering that to remove the Any. Would that be even the correct approach?
If it's not source code that you control(a), the easiest option is usually to drop a # type: ignore [xxx] at the end of the offending line.
I usually also place a comment stating why it's needed so that anyone looking at the code later understands since, during our PR process, we have to justify any disabling of checks for the compliance tools mypy/pylint/bandit/isort/black.
(a) We also follow this guideline if the effort to fix our legacy code is more than a certain threshold. For example, we don't want to have to refactor 10,000 lines of code to make a one-line bug fix :-) All new code (that we control) has to comply however.
Are you sure you are using the latest sqlalchemy version?
for me, when I run mypy to test your code, I find no issues:
f.py:5: note: Revealed type is "sqlalchemy.sql.base.ReadOnlyColumnCollection[builtins.str, sqlalchemy.sql.schema.Column[Any]]"
Success: no issues found in 1 source file
when running at:
import sqlalchemy as sa
t = sa.Table("a", sa.MetaData(), sa.Column("id_", sa.Integer))
cols = t.columns
reveal_type(cols)
Mypy: 1.0.0
sqlalchemy: 2.0.2
I was trying to run the sample code found here:
https://pytorch.org/tutorials/intermediate/torchvision_tutorial.html
I get a crash in the class CocoEvaluator() constructor in coco_eval.py where the following line of code:
for iou_type in iou_types:
self.coco_eval[iou_type] = COCOeval(coco_gt, iouType=iou_type)
will crash with the warning "object of type class 'numpy.float64' cannot be safely interpreted as an integer."
iou_type is a string 'bbox'
COCOeval is a class from pycocotools (pycocotools.cocoeval.COCOeval)
coco_gt is the return value from get_coco_api_from_dataset(data_loader.dataset)
its not clear to me where the numpy.float64 value is being used here, or what I can change to fix this
The problem most likely lies in the numpy version. Numpy version 1.18.+ usually throws this error. However when changing to numpy 1.17.4 the problem is fixed.
as shown here
-> https://github.com/pytorch/vision/issues/1700
-> https://www.kaggle.com/questions-and-answers/90865
#check for version number
np.version.version
#downgrade version
!pip install numpy==1.17.4
This fixed it for me, hope it helps.
The function that I am using for solve_ivp is defined as:
def ydot(t,y,kappa4,kappa16):
Upon using solve_ivp as below:
sol=solve_ivp(ydot,[0,10],initial_condition(),args=(50,100))
I get the following error:
ydot() missing 2 required positional arguments: 'kappa4' and 'kappa16'
I am not able debug the code even though I have defined the function ydot the way scipy documentation for solve_ivp defines (https://docs.scipy.org/doc/scipy/reference/generated/scipy.integrate.solve_ivp.html)
There's even an example in the end of the documentation that demonstrates the passing of arguments implemented in the same way as I have done.
I believe the problem is somewhere in the two above pieces of the code I have provided from an otherwise long code.
I was able to replicate the error with scipy 1.1.0 .
Upgrading scipy to the latest version via cmd (pip install scipy==1.4.1) solved that error message for me.
Then the minimal reproducible example gave another error:
TypeError: ydot() argument after * must be an iterable, not int
Which was solved by the solution given by Tejas. The full working minimal script is hence:
from scipy.integrate import solve_ivp
def ydot(t,y,a): return -a*y
sol=solve_ivp(ydot,[0,10],[5],args=(8,))
print(sol.y)
I had faced the same issue recently.
But the great Warren Weckesser
helped me out.
Change
args=(10)
to
args=(10,)
and your MWE will work fine.
This happens because of tuples with a single element.
For reference see pg 30 of Python tutorial pdf (Release 3.5.1) on python.org
I just put together the following "minimum" repro case (minimum in quotes because I wanted to ensure pylint threw no other errors, warnings, hints, or suggestions - meaning there's a bit of boilerplate):
pylint_error.py:
"""
Docstring
"""
import numpy as np
def main():
"""
Main entrypoint
"""
test = np.array([1])
print(test.shape[0])
if __name__ == "__main__":
main()
When I run pylint on this code (pylint pylint_error.py) I get the following output:
$> pylint pylint_error.py
************* Module pylint_error
pylint_error.py:13:10: E1136: Value 'test.shape' is unsubscriptable (unsubscriptable-object)
------------------------------------------------------------------
Your code has been rated at 1.67/10 (previous run: 1.67/10, +0.00)
It claims that test.shape is not subscriptable, even though it quite clearly is. When I run the code it works just fine:
$> python pylint_error.py
1
So what's causing pylint to become confused, and how can I fix it?
Some additional notes:
If I declare test as np.arange(1) the error goes away
If I declare test as np.zeros(1), np.zeros((1)), np.ones(1), or np.ones((1)) the error does not go away
If I declare test as np.full((1), 1) the error goes away
Specifying the type (test: np.ndarray = np.array([1])) does not fix the error
Specifying a dtype (np.array([1], dtype=np.uint8)) does not fix the error
Taking a slice of test (test[:].shape) makes the error go away
My first instinct says that the inconsistent behavior with various NumPY methods (arange vs zeros vs full, etc) suggests it's just a bug in NumPY. However it's possible there's some underlying concept to NumPY that I'm misunderstanding. I'd like to be sure I'm not writing code with undefined behavior that's only working on accident.
I don't have enough reputation to comment, but it looks like this is an open issue: https://github.com/PyCQA/pylint/issues/3139
Until the issue is resolved on their end, I would just change the line to
print(test.shape[0]) # pylint: disable=E1136 # pylint/issues/3139
to my pylintrc file.
As of November 2019:
As mentioned by one of the users in the discussion on GitHub you could resolve the problem by downgrading both pylint and astroid, e.g. in requirements.txt
astroid>=2.0, <2.3
pylint>=2.3, <2.4
or
pip install astroid==2.2.5 & pip install pylint==2.3.1
This was finally fixed with the release of astroid 2.4.0 in May 2020.
https://github.com/PyCQA/pylint/issues/3139
I am trying to learn my way around Cython, and I am following the official documentation. Recently, i tried to do the tutorial provided in "http://docs.cython.org/en/latest/src/tutorial/profiling_tutorial.html".
The objective here is to profile a Cython document.
This is where I got into trouble.
The function to be profiles is (file "calc_pi.py"):
def recip_square(i):
return 1./i**2
def approx_pi(n=10000000):
val = 0.
for k in range(1,n+1):
val += recip_square(k)
return (6 * val)**.5
The script to profile the functions (as posted in the document) is:
import pstats, cProfile
import calc_pi
cProfile.runctx("calc_pi.approx_pi()", globals(), locals(), "Profile.prof")
s = pstats.Stats("Profile.prof")
s.strip_dirs().sort_stats("time").print_stats()
I am not exactly sure which command to run, and if this is what raises the error. However, in their page, there is no reference to thisi. So I simply run "python3 profile.py", which yields the follwing error:
AttributeError: module 'cProfile' has no attribute 'runctx'
I know that probably my error is stupid and minimum, but after googleing and checking stackoverflow for a while, I could not find the answer.
Thank you for your help.
I faced the same issue here.
The problem was the name of the file profile.py.
Just use a different name (as suggested in here)