arihantvyavhare commited on
Commit
15480d0
1 Parent(s): 8c3c406

added # %% for cell detection

Browse files
Files changed (2) hide show
  1. converter_update.py +5 -0
  2. tips.py +4 -0
converter_update.py CHANGED
@@ -1,6 +1,9 @@
1
  import json
2
  import argparse
3
 
 
 
 
4
  parser = argparse.ArgumentParser(description='Convert .ipynb file to .py file')
5
  parser.add_argument('input_file', help='Path to the input .ipynb file')
6
  args = parser.parse_args()
@@ -13,11 +16,13 @@ py_file = open(f"{filename}.py", "w+")
13
  for cell in code['cells']:
14
  if cell['cell_type'] == 'code':
15
  if cell['source'] and "#| export" in cell['source'][0]:
 
16
  for line in cell['source'][1:]:
17
  py_file.write(line)
18
  py_file.write("\n")
19
  elif cell['cell_type'] == 'markdown':
20
  py_file.write("\n")
 
21
  for line in cell['source']:
22
  if line and line[0] == "#":
23
  py_file.write(line)
 
1
  import json
2
  import argparse
3
 
4
+ #below command for conversion
5
+ # -> python -u "/home/demonhunter/projects/device_detector/converter_update.py" 'tips.ipynb'
6
+
7
  parser = argparse.ArgumentParser(description='Convert .ipynb file to .py file')
8
  parser.add_argument('input_file', help='Path to the input .ipynb file')
9
  args = parser.parse_args()
 
16
  for cell in code['cells']:
17
  if cell['cell_type'] == 'code':
18
  if cell['source'] and "#| export" in cell['source'][0]:
19
+ py_file.write("# %%\n") #you can comment out this line
20
  for line in cell['source'][1:]:
21
  py_file.write(line)
22
  py_file.write("\n")
23
  elif cell['cell_type'] == 'markdown':
24
  py_file.write("\n")
25
+ py_file.write("# %%\n") #you can comment out this line
26
  for line in cell['source']:
27
  if line and line[0] == "#":
28
  py_file.write(line)
tips.py CHANGED
@@ -1,9 +1,11 @@
1
 
 
2
  # Tips:
3
  ## downloading images using duckduckgo and fastbook
4
  #*
5
  #* test
6
 
 
7
  from fastbook import *
8
 
9
  query = "joker"
@@ -13,8 +15,10 @@ urls = search_images_ddg(query, max_images = 5 )
13
  len(urls)
14
 
15
  # for url in urls : print(url)
 
16
  for i,url in enumerate(urls):
17
  download_url(url,f"data/{query}/{query}_{i+1}.jpg")
 
18
  import shutil
19
 
20
  shutil.rmtree(f"data/{query}")
 
1
 
2
+ # %%
3
  # Tips:
4
  ## downloading images using duckduckgo and fastbook
5
  #*
6
  #* test
7
 
8
+ # %%
9
  from fastbook import *
10
 
11
  query = "joker"
 
15
  len(urls)
16
 
17
  # for url in urls : print(url)
18
+ # %%
19
  for i,url in enumerate(urls):
20
  download_url(url,f"data/{query}/{query}_{i+1}.jpg")
21
+ # %%
22
  import shutil
23
 
24
  shutil.rmtree(f"data/{query}")