-
My Jedi autocomplete/hints doesn't seem to want to work with the I am trying to figure out if:
Thanks in advance! If someone else could see if they can replicate this issue that would be great. See the code below: from time import sleep
from duckduckgo_search import ddg_images
from fastai.vision.all import *
from fastcore.all import *
from fastdownload import download_url
PATH = Path("./files/classifier/")
TEST_PATH = "./files/classifier/test/"
LEARNER = "bird_classifier.pkl"
def search_images(term, max_images=30):
print(f"Searching for '{term}'")
return L(ddg_images(term, max_results=max_images)).itemgot("image")
def build():
searches = "forest", "bird", "plane"
for o in searches:
dest = PATH / o
dest.mkdir(exist_ok=True, parents=True)
download_images(dest, urls=search_images(f"{o} photo"))
download_images(dest, urls=search_images(f"{o} sun photo"))
download_images(dest, urls=search_images(f"{o} shade photo"))
resize_images(PATH / o, max_size=400, dest=PATH / o)
failed = verify_images(get_image_files(PATH))
failed.map(Path.unlink)
len(failed)
dls = DataBlock(
blocks=(ImageBlock, CategoryBlock),
get_items=get_image_files,
splitter=RandomSplitter(valid_pct=0.2, seed=42),
get_y=parent_label,
item_tfms=[Resize(192, method="squish")],
).dataloaders(PATH, bs=32)
learn = vision_learner(dls, resnet18, metrics=error_rate)
learn.fine_tune(3)
return learn
def classifier_test(learn):
urls = search_images("bird photos", max_images=1)
urls[0]
dest = TEST_PATH + "/bird.jpg"
download_url(urls[0], dest, show_progress=False)
is_bird, _, probs = learn.predict(PILImage.create(dest))
print(f"This is a: {is_bird}.")
print(f"Probability it's a bird: {probs[2]:.4f}")
if __name__ == "__main__":
# if LEARNER exists, skip building
if not Path(LEARNER).exists():
learn = build()
learn.save(LEARNER, with_opt=True)
learn = load_learner(LEARNER)
classifier_test(learn) And the script to run it pip install fastai duckduckgo-search
python3 classifier.py |
Beta Was this translation helpful? Give feedback.
Replies: 6 comments 6 replies
-
Apologies, I do not use Python regularly so might be doing something wrong. I'm testing this in my Terminal on macOS. I ran: pip3 install fastai duckduckgo-search
python3 classifier.py and now I'm getting: Traceback (most recent call last):
File "classifier.py", line 3, in <module>
from duckduckgo_search import ddg_images
ModuleNotFoundError: No module named 'duckduckgo_search' When I tried running Traceback (most recent call last):
File "/usr/local/bin/pip", line 11, in <module>
load_entry_point('pip==21.0.1', 'console_scripts', 'pip')()
File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/pkg_resources/__init__.py", line 489, in load_entry_point
return get_distribution(dist).load_entry_point(group, name)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/pkg_resources/__init__.py", line 2843, in load_entry_point
return ep.load()
File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/pkg_resources/__init__.py", line 2434, in load
return self.resolve()
File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/pkg_resources/__init__.py", line 2440, in resolve
module = __import__(self.module_name, fromlist=['__name__'], level=0)
File "/Library/Python/2.7/site-packages/pip-21.0.1-py2.7.egg/pip/_internal/cli/main.py", line 60
sys.stderr.write(f"ERROR: {exc}")
^
SyntaxError: invalid syntax I followed this but still no luck. Happy to keep trying if you have other tips. |
Beta Was this translation helpful? Give feedback.
-
Huh that is interesting. could you try Also after further debugging, the Jedi typehint info works flawlessly before vscode fully loads, then starts to lag. This makes me think its a code-server problem. I am on 4.5.1 so I am going to try updating and see if that helps. |
Beta Was this translation helpful? Give feedback.
-
So I thought the problem was fixed, but it seems it was only half fixed, i.e the wildcard imports don't work. I am now wondering if this is just a limitaition of Jedi vs pylance |
Beta Was this translation helpful? Give feedback.
-
Okay so a final topic on this. Jedi is extremely slow, and doesn't manage to handle wildcards in this case. Pylance can, but by default PyRight (The open source base of Pylance), it doesn't work. The difference is a single setting that Pylance has "python.analysis.useLibraryCodeForTypes": true, After enabling this, pyright works just like pylance, and you get full highlighting and autocomplete support for wildcard imports. Data Analysts rejoice :)) |
Beta Was this translation helpful? Give feedback.
-
It seems to half be the issue. Pyright still doesn't correctly handle the
wildcard stuff but the pyright team think that might be a bug / because
pylance has better compiled stubs. Obviously testing this is difficult as I
cannot test pylance in code-server but I shall report back my findings.
…On Tue, 30 Aug 2022, 15:53 Joe Previte, ***@***.***> wrote:
interesting! so is that the solution? switching to pyright?
—
Reply to this email directly, view it on GitHub
<#5514 (reply in thread)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ALCTWHTYFO3Z57LJGZIVZN3V3YN7FANCNFSM573Z55TQ>
.
You are receiving this because you authored the thread.Message ID:
***@***.***>
|
Beta Was this translation helpful? Give feedback.
Okay so a final topic on this. Jedi is extremely slow, and doesn't manage to handle wildcards in this case. Pylance can, but by default PyRight (The open source base of Pylance), it doesn't work.
The difference is a single setting that Pylance has
true
by default, but Pyright does not. I think purely due to the fact that the Pyright devs have a grub against this feature ;/After enabling this, pyright works just like pylance, and you get full highlighting and autocomplete support for wildcard imports. Data Analysts rejoice :))