I am trying to understand the class L and in particular its method .attrgot(). I am working through lecture 2, the bears example.
I have read the docs and understand that L is a fastai class that is basically a modified list. I also understand that .attrgot() creates a new instance of L that contains the attributes specified in the method. But the example uses results.attrgot('content_url'). It’s the “content_url” that is confusing me. That string does not appear in results. Where does this string come from and what is it matching with?
Hi I have had similar problems trying to get the chapter 2 example to work. I get different error messages every time I run it. I know I got it to work once, but I haven’t gotten it to work since.
Why does it do something different every time I run it? Is this a common issue?
@Mark and @msivanes just checked out the ImageObject Class of Azure, the attribute is ‘ContentUrl’, not ‘content_url’. How did it end up as ‘content_url’ in the notebook?
Hi, @mariasimon. It’s been a while since I’ve looked at this. Looking at the docs, you seem to be right.
I don’t have an answer to your question, and I don’t use Azure enough to spend the time to try to figure it out. My guess is that something is generating a dictionary, and that .attrgot() is accessing that dictionary with ‘content_url’ as the key. In this case, it’s not invoking the object attribute directly, but a dictionary that is somehow generated. But it’s just a guess. You can try playing with the results object see what you can find.
Sorry that I’m not more help.
Added: Try results['content_url'] and if it returns anything; if it does, a dictionary must exist.
results is itself from L class. It is similar to a list of dictionaries. print(results) will show you the elements. It has a particular key: ‘contentUrl’. So results.attrgot(‘contentUrl’) will return all the dictionaries with the key ‘contentUrl’.
Honestly, I don’t remember this that well, and haven’t looked in months. But the reason there is a dictionary with the key ‘contentUrl’ is presumably that the Azure api put it there. That’s what I was trying to say. ‘contentUrl’ as a key is not from fastai, it’s from Azure. The L class is a fastai class.
As pointed out, it does not match ‘content_url’ in the notebook.
Yeah, I ran into this same exact problem. Has this been updated? Doesn’t look like it in the most recent version of the notebooks for this lecture (as far as I’ve seen).
Hi
I am reading the chapter 2 of the book
I have some problem when i try to get the microsoft key to download my images
I have downloaded my own images in my latop on google is it possible for me to use these images as my own dataset ?