Hello,
I just started the 1st FastAI course in conjunction with the recommended book.
The author advises to use tools like Kaggle or Paperspace instead of using the local environment, for practical reasons (GPU in particular)
What do you recommend? Kaggle or PaperSpace?
What is the general process? git clone the fastai github repository onto a Kaggle notebook and then browse each notebook?
Although I did it, I could not navigate, not being too familiar with the Kaggle platform, I see the .ipnyb file names available, but I canāt access each of the cloned notebooks from the notebook.
Sounds like āGPUā is not selected. See this thread for my note on how to select it.
Hi Saad,
I havenāt checked out PaperSpace so far, so wouldnāt be able to give a comparison. But here is the process to run the notebooks on other platforms.
If you are looking to run the code in the book then you can use colab: https://colab.research.google.com/
-
What you can do is simply replace github.com to Google Colab and the rest of the address. For example: https:// github.com/ fastai/fastbook/blob/master/01_intro.ipynb can be opened on colab with https:// colab.research.google.com/ github/ fastai/fastbook/blob/master/01_intro.ipynb (Note: Iāve added spaces in the URL as it was turning the URL into a hyperlink and the modification wouldnāt be clear)
-
In order to use GPU on colab, you can āchange runtime typeā to add a GPU accelerator
In addition to the text book code, the official notebook for this lecture is on Kaggle already: Is it a bird? Creating a model from your own data | Kaggle
So all you have to do is, copy and run it within Kaggle. Then you can modify it according to the problem of your choice!
Hello,
I just completet lesson 1 and tried to alter the official Kaggle notebook. I added a dataset of chess pieces and want to classify them, but I get bad results quite often.
- Some pieces are classified correctly
- Some easy looking pieces are classified incorrectly (check link for an example)
- Kings are always classified incorrectly
Can someone please help me out? I tried a few different things but I just canāt find the reason⦠https://www.kaggle.com/code/maxwe000/is-it-a-king-creating-a-model-from-your-own-data
Anyone tried toying with image segmentation?
I tried to modify the segmentation code from the textbook so that it could do image segmentation on my choice of images like the streets of Dubai or Paris.
For classification, we do learn.predict()
at the end on our choice of input image and it gives the prediction along with the probabilities.
What to do for segmentation? I tried learn.segment()
but there is no such thing as that.
Please help.
Sharing the NB below.
Segmentation as introduced in lession 1 seems to be connected to classification (classifying different pixels). Is there a different term for regression-segmentation (things like heatmaps etc)
You do learn.predict()
after training your model to classify (or segment) a new image where you donāt have the correct label or segmentation mask (thats called āinferenceā). The .predict()
method is agnostic to what task you are trying to solve.
Here is the relevant segment of the fast.ai documentation for semantic segmentation, this may nudge you in the right direction: fastai - Computer vision intro
Youāve hit the most common issue Iāve seen extrapolating from the bird/forest exampleā¦
Where that example was simplified by hardcoding zero in probs[0]
, you need to use the value ignored by the underscoreā¦
i.e. instead ofā¦
category,_,probs = learn.predict(PILImage.create('king.jpg'))
print(f"This is a: {category}.")
print(f"Probability it's a {category}: {probs[0]:.4f}")
useā¦
category,index,probs = learn.predict(PILImage.create('king.jpg'))
print(f"This is a: {category}.")
print(f"Probability it's a {category}: {probs[index]:.4f}")
Hi guys, I could use some assistance with the code⦠I am not using Jupyter Notebook rather I am using PyCharm (free edition without Jupyter Notebook). I am encountering an issue when trying to download the images from this code
searches = 'forest','bird'
path = Path('bird_or_not')
from time import sleep
#for o in searches:
# dest = (path/o)
# dest.mkdir(exist_ok=True, parents=True)
# download_images(dest, urls=search_images(f'{o} photo'))
# sleep(10) # Pause between searches to avoid over-loading server
# download_images(dest, urls=search_images(f'{o} sun photo'))
# sleep(10)
# download_images(dest, urls=search_images(f'{o} shade photo'))
# sleep(10)
# resize_images(path/o, max_size=400, dest=path/o)
The error that I get is
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.10_3.10.2544.0_x64__qbz5n2kfra8p0\lib\multiprocessing\spawn.py", line 116, in spawn_main
exitcode = _main(fd, parent_sentinel)
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.10_3.10.2544.0_x64__qbz5n2kfra8p0\lib\multiprocessing\spawn.py", line 125, in _main
prepare(preparation_data)
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.10_3.10.2544.0_x64__qbz5n2kfra8p0\lib\multiprocessing\spawn.py", line 236, in prepare
_fixup_main_from_path(data['init_main_from_path'])
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.10_3.10.2544.0_x64__qbz5n2kfra8p0\lib\multiprocessing\spawn.py", line 287, in _fixup_main_from_path
main_content = runpy.run_path(main_path,
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.10_3.10.2544.0_x64__qbz5n2kfra8p0\lib\runpy.py", line 288, in run_path
code, fname = _get_code_from_file(run_name, path_name)
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.10_3.10.2544.0_x64__qbz5n2kfra8p0\lib\runpy.py", line 252, in _get_code_from_file
with io.open_code(decoded_path) as f:
OSError: [Errno 22] Invalid argument:
I cannot for the life of me figure it out so any help would be much appreciated
I canāt see it either. It doesnāt help that you are in the 0.1%** group approaching it like this. I recommend you install WSL Ubuntu on Windows and first get it working with Jupyter the way 99.9%** others do it. Once you are comfortable doing it that way, you will be better positioned to try again on Windows.
**Note, 72% of statistics are made up on the spotā¦
Thanks for the fun stats. The thing is that I want to use PyCharm (free) since that is what I currently use for my job on a company machine with severely draconian restrictions⦠so Jupyter is a bit of a no go for meā¦
On the āwecome to fastaiā page on https://docs.fast.ai/, it is stated that:
You can use fastai without any installation by using Google Colab. In fact, every page of this documentation is also available as an interactive notebook - click āOpen in colabā at the top of any page to open it.
Where is this āopen in colabā button or link? On the top of the cited page, all I see is āCI failingā, āPyPIā, āConda (channel only)ā, āBuild fastaiā, and āimages docsā. What am I missing?
I had the very same issue ā check to see that your model predicts a picture of a forest to be a cow with 99% accuracy. If so, then do what is recommended in the message from bencoman that begins āYouāve hit the most common issue Iāve seen extrapolating ā¦ā
Thank you a lot!
Hi! Very basic question: how do the cells in Jupyter (e.g. in the Is it a bird? file) have access to some libraries without installing them? E.g. from fastcore.all import *
. I never saw a pip install fastcore
.
I tried to reproduce this in my local iPython, but I canāt install fastai
on a Mac m1.
Itās because Kaggle kernels come with fastai library preinstalled
Ah that makes sense, thanks!
I got it working locally now and it seems that the fastai
library makes packages like fastdownload
and fastcore
available.
The fastai
library is installed in the second code block of the Jupyter notebook, so it all makes sense now
If youāre going through Chapter 1 of the book, thereās a section where you need to upload a picture to test your model. This didnāt work for me on Colab, but thereās some workaround to it:
A- Manually by creating a folder in root and name it āimagesā
1- Click on the folders tab on the right, then right click to add a new folder and name it āimagesā
2-Above the folders, click on the first icon on the row to upload a file.
3-Move the photo to the āimagesā folder youāve created.
4-You can either name it āchapter1_cat_example.jpgā or change this cell to the name of your picture. You can skip the upload part and execute this cell:
#hide
# For the book, we can't actually click an upload button, so we fake it
uploader = SimpleNamespace(data = ['images/<your_image_name.jpg>'])
B- This worked for me, by uploading the photos using the upload cell and skip the next cell and jump to prediction cell
Good luck.