nbdevAuto 0.0.95__tar.gz → 0.0.102__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: nbdevAuto
3
- Version: 0.0.95
3
+ Version: 0.0.102
4
4
  Summary: automating nbdev
5
5
  Home-page: https://github.com/bthek1/nbdevAuto
6
6
  Author: Benedict Thekkel
@@ -0,0 +1 @@
1
+ __version__ = "0.0.102"
@@ -33,4 +33,6 @@ d = { 'settings': { 'branch': 'main',
33
33
  'nbdevAuto/functions.py'),
34
34
  'nbdevAuto.functions.read_from_file': ('functions.html#read_from_file', 'nbdevAuto/functions.py'),
35
35
  'nbdevAuto.functions.resize_pics': ('functions.html#resize_pics', 'nbdevAuto/functions.py'),
36
- 'nbdevAuto.functions.verify_pics': ('functions.html#verify_pics', 'nbdevAuto/functions.py')}}}
36
+ 'nbdevAuto.functions.verify_pics': ('functions.html#verify_pics', 'nbdevAuto/functions.py')},
37
+ 'nbdevAuto.pdf': { 'nbdevAuto.pdf.display_pdf_slides': ('pdf_reader.html#display_pdf_slides', 'nbdevAuto/pdf.py'),
38
+ 'nbdevAuto.pdf.show_slides': ('pdf_reader.html#show_slides', 'nbdevAuto/pdf.py')}}}
@@ -47,6 +47,7 @@ def download_pic(
47
47
  import shutil
48
48
  from PIL import Image
49
49
  from pathlib import Path
50
+ from tqdm.notebook import tqdm
50
51
 
51
52
  if folder == '':
52
53
  folder = Path()
@@ -64,10 +65,10 @@ def download_pic(
64
65
  f'{image}',
65
66
  max_images=n_images)
66
67
 
67
- for i in range(n_images):
68
+ for i in tqdm(range(n_images)):
68
69
  try:
69
70
  image_path = f'{folder}/{name}{i}.jpg'
70
- print(f"Downloading image_path.{i}")
71
+ if show_progress == True: print(f"Downloading image_path.{i}")
71
72
  download_url(
72
73
  search_links[i], image_path,
73
74
  show_progress=show_progress
@@ -80,21 +81,29 @@ def download_pic(
80
81
 
81
82
  # %% ../nbs/00_Functions.ipynb 10
82
83
  #|code-fold: true
83
- def create_searches_folder(folder_path, searches):
84
- for i in searches:
84
+ def create_searches_folder(folder_path, searches, show_progress:bool=False):
85
+ from tqdm.notebook import tqdm
86
+ print("Create folder")
87
+ for i in tqdm(searches):
85
88
  dest = (folder_path/i)
86
89
  dest.mkdir(exist_ok=True, parents=True)
87
- print(f'created {i} folder')
90
+ if show_progress == True: print(f'created {i} folder')
88
91
 
89
92
  # %% ../nbs/00_Functions.ipynb 11
90
93
  #|code-fold: true
91
- def download_search_image(folder_path, item, before, after, amount):
94
+ def download_search_image(folder_path,
95
+ item,
96
+ before,
97
+ after,
98
+ amount,
99
+ show_progress:bool=False,
100
+ ):
92
101
  from fastbook import search_images_ddg
93
102
  from fastai.vision.all import download_images
94
103
  imgAmount = amount
95
104
  try:
96
105
  urls=search_images_ddg(f'{before}{item}{after}', imgAmount)
97
- print(f"downloading {imgAmount} images for:{before}{item}{after}")
106
+ if show_progress == True: print(f"downloading {imgAmount} images for:{before}{item}{after}")
98
107
 
99
108
  download_images(
100
109
  folder_path/item,
@@ -104,7 +113,7 @@ def download_search_image(folder_path, item, before, after, amount):
104
113
 
105
114
  except Exception as e:
106
115
  # Code to handle any unhandled exceptions
107
- print(f"Error with {imgAmount} images of {before}{item}{after}:", e)
116
+ if show_progress == True: print(f"Error with {imgAmount} images of {before}{item}{after}:", e)
108
117
  imgAmount -= 20
109
118
  if imgAmount > 0: download_search_image(folder_path, item, before, after, imgAmount)
110
119
 
@@ -113,35 +122,50 @@ def download_search_image(folder_path, item, before, after, amount):
113
122
 
114
123
  # %% ../nbs/00_Functions.ipynb 12
115
124
  #|code-fold: true
116
- def download_search_images(folder_path, searches, before, after, amount):
117
- for item in searches:
125
+ def download_search_images(folder_path,
126
+ searches,
127
+ before,
128
+ after,
129
+ amount,
130
+ show_progress:bool=False,
131
+ ):
132
+ from tqdm.notebook import tqdm
133
+ for item in tqdm(searches):
118
134
  imgAmount = amount
119
- download_search_image(folder_path, item, before, after, amount)
135
+ download_search_image(folder_path, item, before, after, amount, show_progress)
120
136
 
121
137
 
122
138
 
123
139
  # %% ../nbs/00_Functions.ipynb 13
124
140
  #|code-fold: true
125
- def verify_pics(folder_path):
141
+ def verify_pics(folder_path,
142
+ ):
126
143
  from fastai.vision.all import verify_images, get_image_files
127
144
  from pathlib import Path
128
145
 
146
+
129
147
  failed = verify_images(get_image_files(folder_path))
130
148
  failed.map(Path.unlink)
131
149
  print(f"Number of images failed: {len(failed)}")
132
150
 
133
151
  # %% ../nbs/00_Functions.ipynb 14
134
152
  #|code-fold: true
135
- def resize_pics(folder_path, searches,max_size=400):
153
+ def resize_pics(folder_path,
154
+ searches,
155
+ max_size=400,
156
+ show:bool=True,
157
+ ):
136
158
  from fastai.vision.all import resize_images
137
- for k in searches:
159
+ from tqdm.notebook import tqdm
160
+
161
+ for k in tqdm(searches):
138
162
  resize_images(
139
163
  folder_path/k,
140
164
  max_size=max_size,
141
165
  dest=folder_path/k,
142
166
  max_workers=16
143
167
  )
144
- print(f"resizing images for: {k}")
168
+ if show == True: print(f"resizing images for: {k}")
145
169
 
146
170
  # %% ../nbs/00_Functions.ipynb 15
147
171
  #|code-fold: true
@@ -151,7 +175,8 @@ def create_data_folder(
151
175
  before:str='',
152
176
  after:str='',
153
177
  amount:int=200,
154
- recreate:bool=False
178
+ recreate:bool=False,
179
+ show_progress:bool=False,
155
180
  ):
156
181
  'generate image data'
157
182
  assert isinstance(searches, tuple), "searches must be a list."
@@ -176,8 +201,8 @@ def create_data_folder(
176
201
  else:
177
202
  if recreate is True and os.path.exists(folder_path):
178
203
  shutil.rmtree(folder_path)
179
- create_searches_folder(folder_path, searches)
180
- download_search_images(folder_path, searches, before, after, amount)
204
+ create_searches_folder(folder_path, searches, show_progress)
205
+ download_search_images(folder_path, searches, before, after, amount, show_progress)
181
206
  verify_pics(folder_path)
182
207
  resize_pics(folder_path, searches)
183
208
 
@@ -0,0 +1,29 @@
1
+ # AUTOGENERATED! DO NOT EDIT! File to edit: ../nbs/02_PDF_reader.ipynb.
2
+
3
+ # %% auto 0
4
+ __all__ = ['display_pdf_slides', 'show_slides']
5
+
6
+ # %% ../nbs/02_PDF_reader.ipynb 4
7
+ #|code-fold: true
8
+ def display_pdf_slides(pdf_path):
9
+ import matplotlib.pyplot as plt
10
+ # Convert PDF to a list of images
11
+ images = convert_from_path(pdf_path)
12
+
13
+ # Display each image using Matplotlib
14
+
15
+ # %% ../nbs/02_PDF_reader.ipynb 5
16
+ #|code-fold: true
17
+ def show_slides(images, slide, height = 6, width = 4, end = ''):
18
+ from pdf2image import convert_from_path
19
+ import matplotlib.pyplot as plt
20
+
21
+ if end == '' or end < slide:
22
+ end = slide
23
+
24
+ for i, image in enumerate(images[slide:end+1]):
25
+ plt.figure(figsize=(height, width))
26
+ plt.imshow(image)
27
+ plt.title(f'Slide {i + 1}')
28
+ plt.axis('off')
29
+ plt.show()
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: nbdevAuto
3
- Version: 0.0.95
3
+ Version: 0.0.102
4
4
  Summary: automating nbdev
5
5
  Home-page: https://github.com/bthek1/nbdevAuto
6
6
  Author: Benedict Thekkel
@@ -8,6 +8,7 @@ nbdevAuto/_modidx.py
8
8
  nbdevAuto/automate.py
9
9
  nbdevAuto/core.py
10
10
  nbdevAuto/functions.py
11
+ nbdevAuto/pdf.py
11
12
  nbdevAuto.egg-info/PKG-INFO
12
13
  nbdevAuto.egg-info/SOURCES.txt
13
14
  nbdevAuto.egg-info/dependency_links.txt
@@ -1,7 +1,7 @@
1
1
  [DEFAULT]
2
2
  repo = nbdevAuto
3
3
  lib_name = nbdevAuto
4
- version = 0.0.95
4
+ version = 0.0.102
5
5
  min_python = 3.7
6
6
  license = apache2
7
7
  black_formatting = False
@@ -1 +0,0 @@
1
- __version__ = "0.0.95"
File without changes
File without changes
File without changes
File without changes
File without changes