Skip to content

Commit 3199e10

Browse files
committed
ddg
1 parent 1e551a8 commit 3199e10

File tree

8 files changed

+339
-43
lines changed

8 files changed

+339
-43
lines changed

docs/_data/sidebars/home_sidebar.yml

+30-24
Original file line numberDiff line numberDiff line change
@@ -9,32 +9,11 @@ entries:
99
- output: web,pdf
1010
title: Overview
1111
url: /
12-
output: web
13-
title: Getting started
14-
- folderitems:
15-
- output: web,pdf
16-
title: Colab
17-
url: /start_colab
18-
- output: web,pdf
19-
title: Gradient
20-
url: /start_gradient
21-
- output: web,pdf
22-
title: Sagemaker
23-
url: /start_sagemaker
24-
output: web
25-
title: Notebook Servers
26-
- folderitems:
27-
- output: web,pdf
28-
title: Google Cloud
29-
url: /start_gcp
30-
- output: web,pdf
31-
title: Azure
32-
url: /start_azure_dsvm
3312
- output: web,pdf
34-
title: DataCrunch.io
35-
url: /start_datacrunch
13+
title: Downloading images
14+
url: /images
3615
output: web
37-
title: Full Linux Servers
16+
title: Book and course help
3817
- folderitems:
3918
- output: web,pdf
4019
title: Lesson 1 - Your first models
@@ -62,13 +41,40 @@ entries:
6241
url: videos?lesson=8
6342
output: web
6443
title: Lessons
44+
- folderitems:
45+
- output: web,pdf
46+
title: Colab
47+
url: /start_colab
48+
- output: web,pdf
49+
title: Gradient
50+
url: /start_gradient
51+
- output: web,pdf
52+
title: Sagemaker
53+
url: /start_sagemaker
54+
output: web
55+
title: Notebook Servers
56+
- folderitems:
57+
- output: web,pdf
58+
title: Google Cloud
59+
url: /start_gcp
60+
- output: web,pdf
61+
title: Azure
62+
url: /start_azure_dsvm
63+
- output: web,pdf
64+
title: DataCrunch.io
65+
url: /start_datacrunch
66+
output: web
67+
title: Full Linux Servers
6568
- folderitems:
6669
- output: web,pdf
6770
title: Heroku
6871
url: /deployment_heroku
6972
- output: web,pdf
7073
title: Azure Functions
7174
url: /deployment_azure_functions
75+
- output: web,pdf
76+
title: BentoML
77+
url: /deployment_bento
7278
- output: web,pdf
7379
title: SeeMe.ai
7480
url: /deployment_seeme_ai

docs/images.html

+137
Large diffs are not rendered by default.

docs/images/bear.jpg

2.25 MB
Loading

docs/sidebar.json

+11-10
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,7 @@
11
{
2-
"Getting started": {
3-
"Overview": "/"
4-
}, "Notebook Servers": {
5-
"Colab": "/start_colab",
6-
"Gradient": "/start_gradient",
7-
"Sagemaker": "/start_sagemaker"
8-
}, "Full Linux Servers": {
9-
"Google Cloud": "/start_gcp",
10-
"Azure": "/start_azure_dsvm",
11-
"DataCrunch.io": "/start_datacrunch"
2+
"Book and course help": {
3+
"Overview": "/",
4+
"Downloading images": "/images"
125
}, "Lessons": {
136
"Lesson 1 - Your first models": "videos?lesson=1",
147
"Lesson 2 - Evidence and p values": "videos?lesson=2",
@@ -18,6 +11,14 @@
1811
"Lesson 6 - Collaborative filtering": "videos?lesson=6",
1912
"Lesson 7 - Tabular data": "videos?lesson=7",
2013
"Lesson 8 - Natural language processing": "videos?lesson=8"
14+
}, "Notebook Servers": {
15+
"Colab": "/start_colab",
16+
"Gradient": "/start_gradient",
17+
"Sagemaker": "/start_sagemaker"
18+
}, "Full Linux Servers": {
19+
"Google Cloud": "/start_gcp",
20+
"Azure": "/start_azure_dsvm",
21+
"DataCrunch.io": "/start_datacrunch"
2122
}, "Deployment": {
2223
"Heroku": "/deployment_heroku",
2324
"Azure Functions": "/deployment_azure_functions",

fastbook/__init__.py

+26-8
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
1-
__version__ = "0.0.15"
2-
import matplotlib as mpl, pkgutil, requests
1+
__version__ = "0.0.16"
2+
import matplotlib as mpl, pkgutil, requests, time
33
from fastai.vision.all import *
44
from pandas.api.types import CategoricalDtype
55
from scipy.cluster import hierarchy as hc
66
from io import StringIO, BytesIO
7+
from urllib.error import URLError,HTTPError
78

89
try: from ipywidgets import widgets
910
except ModuleNotFoundError: warn("Missing `ipywidgets` - please install it")
@@ -42,14 +43,31 @@ def gv(s): return graphviz.Source('digraph G{ rankdir="LR"' + s + '; }')
4243
def get_image_files_sorted(path, recurse=True, folders=None):
4344
return get_image_files(path, recurse, folders).sorted()
4445

45-
def search_images_bing(key,earch_images_bing(key, term, min_sz=128, max_images=150):
46-
params = {'q':term, 'count':max_images, 'min_height':min_sz, 'min_width':min_sz}
47-
headers = {"Ocp-Apim-Subscription-Key":key}
46+
def search_images_bing(key, term, min_sz=128, max_images=150):
47+
params = dict(q=term, count=max_images, min_height=min_sz, min_width=min_sz)
4848
search_url = "https://api.bing.microsoft.com/v7.0/images/search"
49-
response = requests.get(search_url, headers=headers, params=params)
49+
response = requests.get(search_url, headers={"Ocp-Apim-Subscription-Key":key}, params=params)
5050
response.raise_for_status()
51-
search_results = response.json()
52-
return L(search_results['value'])term, Min_sz=128):
51+
return L(response.json()['value'])
52+
53+
def search_images_ddg(term, max_images=200):
54+
"Search for `term` with DuckDuckGo and return a unique urls of about `max_images` images"
55+
assert max_images<1000
56+
url = 'https://duckduckgo.com/'
57+
res = urlread(url,data={'q':term}).decode()
58+
searchObj = re.search(r'vqd=([\d-]+)\&', res)
59+
assert searchObj
60+
requestUrl = url + 'i.js'
61+
params = dict(l='us-en', o='json', q=term, vqd=searchObj.group(1), f=',,,', p='1', v7exp='a')
62+
urls,data = set(),{'next':1}
63+
while len(urls)<max_images and 'next' in data:
64+
try:
65+
data = urljson(requestUrl,data=params)
66+
urls.update(L(data['results']).itemgot('image'))
67+
requestUrl = url + data['next']
68+
except (URLError,HTTPError): pass
69+
time.sleep(0.2)
70+
return L(urls)
5371

5472
def plot_function(f, tx=None, ty=None, title=None, min=-2, max=2, figsize=(6,4)):
5573
x = torch.linspace(min,max)

images.ipynb

+134
Large diffs are not rendered by default.

images/bear.jpg

2.25 MB
Loading

settings.ini

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ author = Jeremy Howard and Sylvain Gugger
77
author_email = [email protected]
88
copyright = fast.ai
99
branch = master
10-
version = 0.0.15
10+
version = 0.0.16
1111
min_python = 3.6
1212
audience = Developers
1313
language = English

0 commit comments

Comments
 (0)